summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/c-pascal
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-01-09 00:56:57 +0000
committerKarl Berry <karl@freefriends.org>2006-01-09 00:56:57 +0000
commitf07bb53970ee2ecc53f81a206a3d3a67ef665e4a (patch)
tree6f57a1d62971db79e5ff023bdfd83b22cb971dc9 /Master/texmf-dist/doc/generic/c-pascal
parent007f67a693e4d031fd3d792df8e4d5f43e2cb2e7 (diff)
doc 6
git-svn-id: svn://tug.org/texlive/trunk@85 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/generic/c-pascal')
-rw-r--r--Master/texmf-dist/doc/generic/c-pascal/demo1.tex42
-rw-r--r--Master/texmf-dist/doc/generic/c-pascal/demo2.tex49
-rw-r--r--Master/texmf-dist/doc/generic/c-pascal/prog/guess.pas26
-rw-r--r--Master/texmf-dist/doc/generic/c-pascal/prog/sun.c39
-rw-r--r--Master/texmf-dist/doc/generic/c-pascal/readme.eng90
-rw-r--r--Master/texmf-dist/doc/generic/c-pascal/readme.pol92
6 files changed, 338 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/generic/c-pascal/demo1.tex b/Master/texmf-dist/doc/generic/c-pascal/demo1.tex
new file mode 100644
index 00000000000..76d349b1de2
--- /dev/null
+++ b/Master/texmf-dist/doc/generic/c-pascal/demo1.tex
@@ -0,0 +1,42 @@
+\input cap_c
+\magnification 1440
+
+
+\BeginC
+// this is a short demo program
+/* both kinds of comment are recognised */
+
+// some compiler directives
+#pragma hdrfile "hello.sym"
+#include <stdio.h>
+#include <sys/stat.h>
+#pragma hdrstop
+
+void hello(int n)
+{
+ // obviously, keywords inside comments or
+ // texts are not emphasized:
+ // void return switch for double
+ for (; n>0; n--)
+ printf("Hello, void world!\n");
+ /* ^ isn't that beautiful? */
+}
+
+float silly_funct()
+{
+ #define max(a,b) ((a)>(b))?(a):(b)
+ printf("%7.4lf\n", max(3.14, 012));
+}
+
+// words not recognised as keywords are considered
+// to be identifiers and are typeset in italic
+void main()
+{
+ int n;
+ hello(0x1C);
+ silly_funct();
+}
+\EndC
+
+
+\bye
diff --git a/Master/texmf-dist/doc/generic/c-pascal/demo2.tex b/Master/texmf-dist/doc/generic/c-pascal/demo2.tex
new file mode 100644
index 00000000000..bd26d89b713
--- /dev/null
+++ b/Master/texmf-dist/doc/generic/c-pascal/demo2.tex
@@ -0,0 +1,49 @@
+\input cap
+
+
+A short program in C. It was inserted directly into the \TeX\ source file.
+
+\medskip
+\BeginC
+#include <stdio.h>
+
+void main()
+{
+ a=~a;
+ printf("Hello, world!\n");
+ // printf("Hello, world!\n");
+}
+\EndC
+
+\hrule
+\bigskip
+
+And now a program inserted from a separate file.
+
+\medskip
+\InputC{prog/sun.c}
+
+\vfill\eject
+
+
+And now programs written in Pascal. This one was typed directly into this
+file.
+
+\medskip
+\BeginPascal
+program Hello_world;
+begin
+ writeln('Hello, world!');
+ { writeln('Hello, world!'); }
+end.
+\EndPascal
+
+\hrule
+\bigskip
+
+This one was imported from another file.
+
+\medskip
+\InputPascal{prog/guess.pas}
+
+\bye
diff --git a/Master/texmf-dist/doc/generic/c-pascal/prog/guess.pas b/Master/texmf-dist/doc/generic/c-pascal/prog/guess.pas
new file mode 100644
index 00000000000..743f297622e
--- /dev/null
+++ b/Master/texmf-dist/doc/generic/c-pascal/prog/guess.pas
@@ -0,0 +1,26 @@
+program guess;
+
+var
+ num1, num2: integer;
+
+begin
+ randomize;
+ num2 := random(100);
+
+ repeat
+ { make user guess }
+ write('Guess my number: ');
+ readln(num1);
+
+ { check the relation }
+ if num1 = num2 then
+ writeln('Very well!');
+ if num1 < num2 then
+ writeln('Too small.');
+ if num1 > num2 then
+ writeln('Too big.');
+ until num1 = num2;
+
+ { pause }
+ readln;
+end.
diff --git a/Master/texmf-dist/doc/generic/c-pascal/prog/sun.c b/Master/texmf-dist/doc/generic/c-pascal/prog/sun.c
new file mode 100644
index 00000000000..889341b5b9d
--- /dev/null
+++ b/Master/texmf-dist/doc/generic/c-pascal/prog/sun.c
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <math.h>
+
+int months[]={0, 31, 28, 31, 30, 31, 30,
+ 31, 31, 30, 31, 30, 31};
+char weekdays[7][15]={"Sunday", "Monday", "Tuesday", "Wednesday",
+ "Thursday", "Friday", "Sunday"};
+
+/* this program calculates the latidude
+ where polar day begins/ends */
+void main()
+{
+ int day=24, month=6, weekday=2;
+ double angle=0;
+ double latitude;
+
+ do
+ {
+ latitude=atan(tan((23+27.0/60)*M_PI/180)*cos(angle))*180/M_PI;
+ latitude=(latitude>0)? 90-latitude : -90-latitude;
+ printf("%2d.%02d %12s : %d %02d'\n", day, month,
+ weekdays[weekday], (int)latitude,
+ (int)fabs((latitude-(int)latitude)*60));
+ if (weekday==0)
+ printf("\n");
+
+ angle+=2*M_PI/365;
+ day++;
+ if (day>months[month])
+ {
+ day=1;
+ month++;
+ if (month>12)
+ month=1;
+ }
+ if (++weekday>6)
+ weekday=0;
+ } while (month!=1);
+}
diff --git a/Master/texmf-dist/doc/generic/c-pascal/readme.eng b/Master/texmf-dist/doc/generic/c-pascal/readme.eng
new file mode 100644
index 00000000000..170acaa2a54
--- /dev/null
+++ b/Master/texmf-dist/doc/generic/c-pascal/readme.eng
@@ -0,0 +1,90 @@
+======================================================================
+
+ CAP --- macro package for typesetting programs in C and Pascal
+
+======================================================================
+
+
+ Contents
+----------
+This macro package consists of three files:
+ cap_c.tex -- macros for typesetting programs in C
+ cap_pas.tex -- macros for typesetting programs in Pascal
+ cap_comm.tex -- helpful macros and declarations used for typesetting
+ programs in both languages; this file does not contain
+ any macros useful for a user
+
+
+ Programs in C
+---------------
+There are two macros available in the cap_c.tex file:
+
+ 1. \BeginC ... \EndC
+ Between these commands you may insert sorce code of any program
+ written in the C language. The text of the program will be
+ formatted using appropriate fonts. The macro recognises the
+ following elements of a program:
+ * keywords --- by default typeset in boldface
+ * texts --- everything inside single quotes; by default slanted
+ * comments --- both /*these...*/ and //these... , but not nested;
+ italic typewriter
+ * symbols --- operators, brackets, etc.; typewriter
+ * compiler directives --- typeset using slanted typewriter font
+ * identifiers --- everything that is none of the above; italic
+ The macro does not change the layout of a program. All
+ indentations are left as they are in the source program. No line
+ breaks are inserted.
+ NOTE: While compiling, the \BeginC ... \EndC macro reads the whole
+ program into TeX's memory. Therefore, you may expect problems when
+ typesetting huge programs in this way. In my configuration
+ (emTeX under DOS) everything works fine if the program is not bigger
+ than about 15KB. If you REALLY need to insert a vast program
+ directly into your TeX source file you will have to split
+ the program into smaller pieces, each inserted into a separate
+ pair \BeginC ... \EndC.
+
+ 2. \InsertC{filename}
+ Inserts a C program from a separate file. The program is formatted
+ as above. If you use DOS you need to remember that all backslashes
+ in the pathname should be replaced by slashes.
+ This macro has NO limitations for the size of the program --- it reads
+ the file line by line, so TeX should never run out of memory.
+
+The list of keywords can be easily found in the cap_c.tex file. I do not
+guarantee that it is complete, so fell free to correct it if necessary.
+
+
+ Programs in Pascal
+--------------------
+In order to typeset programs in Pascal you need to \input the cap_pas.tex
+file. It contains two macros, as well:
+
+ 1. \BeginPascal ... \EndPascal
+
+ 2. \InsertPascal{filename}
+
+They work similarly. They recognise the same elements of a Pascal program.
+Both {this} and (*this*) kind of comment is accepted, but they cannot
+be nested. In case of \BeginPascal ... \EndPascal size limitations are
+similar as in C.
+
+The list of keywords was taken from Borland Delphi Help. If you need, you
+may modify it.
+
+
+ Common
+--------
+Fonts used to typeset programs are declared in the beginning of
+the cap_comm.tex file. They are easy to redefine if necessary.
+
+
+ Note
+------
+If you modify aby of the files in any way, mark your changes, please.
+I do not want to take responsibility for other people's modifications.
+
+
+------------
+
+ Michal Gulczynski
+ mgulcz@we.tuniv.szczecin.pl
diff --git a/Master/texmf-dist/doc/generic/c-pascal/readme.pol b/Master/texmf-dist/doc/generic/c-pascal/readme.pol
new file mode 100644
index 00000000000..baa1bb3c1f5
--- /dev/null
+++ b/Master/texmf-dist/doc/generic/c-pascal/readme.pol
@@ -0,0 +1,92 @@
+Polskie robaczki w standardzie ISO-Latin2.
+=======================================================================
+
+ CAP (C albo Pascal) --- makra do składu programów w C i Pascalu
+
+=======================================================================
+
+
+ Zawartość
+-----------
+Ten pakiet makr składa się z trzech plików:
+ cap_c.tex --- makra do składu programów w języku C
+ cap_pas.tex --- makra do składu programów w Pascalu
+ cap_comm.tex --- pomocnicze makra i deklaracje używane do składania
+ programów w obu językach; ten plik nie zawiera
+ żadnych makr pożytecznych dla użytkownika
+
+
+ Programy w C
+--------------
+W pliku cap_c.tex znajdują się definicje dwóch makr:
+
+ 1. \BeginC ... \EndC
+ Pomiędzy te komendy należy wstawić dowolny program źródłowy
+ w języku C. Treść programu zostanie sformatowana z wykorzystaniem
+ odpowiednich czcionek. Rozpoznawane są następujące elementy
+ programu:
+ * słowa kluczowe --- domyślnie wyróżniane są pogrubieniem
+ * teksty --- wszystko to, co wewnątrz apostrofów; domyślnie pochylone
+ * komentarze --- zarówno /*takie...*/ jak i //takie... ,
+ ale nie zagnieżdżone; kursywa typewriter
+ * symbole --- operatory, nawiasy, itp.; typewriter
+ * dyrektywy kompilatora --- składane pochyloną czcionką typewriter
+ * identyfikatory --- wszystko, co nie jest żadnym z powyższych;
+ kursywa
+ Makro nie ingeruje w układ programu. Wcięcia są pozostawione takie,
+ jakie są w programie źródłowym. Podział na linie również nie jest
+ zmieniany.
+ UWAGA: W trakcie kompilacji makro \BeginC ... \EndC wczytuje cały
+ program do pamięci TeXa. Z tego powodu można spodziewać się kłopotów
+ składając tym makrem bardzo duży program. W mojej konfiguracji
+ (emTeX pod DOSem) wszystko działa bez zarzutu jeśli program jest
+ nie większy niż około 15KB. Jeśli NAPRAWDĘ konieczne jest wstawnienie
+ ogromnego programu bezpośrednio do pliku TeXowego, konieczny będzie
+ podział programu na mniejsze części, z których każda będzie ujęta
+ w komendy \BeginC ... \EndC.
+
+ 2. \InsertC{nazwapliku}
+ Wstawia program w języku C z pliku zewnętrznego. Program zostanie
+ sformatowany jak w poprzednim przypadku. Przypomnienie dla pracujących
+ pod DOSem: w nazwie pliku wszystkie wtyłciachy należy zastąpić
+ ciachami.
+ To makro nie nakłada ŻADNYCH ograniczeń na rozmiar programu --- czyta
+ wskazany plik linia po linii, więc nie grozi mu wyczerpanie pamięci.
+
+Lista słów kluczowych znajduje się w pliku cap_c.tex. Nie gwarantuję, że
+jest kompletna, więc w razie potrzeby można ją poprawić.
+
+
+ Programy w Pascalu
+--------------------
+Aby składać programy w Pascalu należy załączyć plik cap_pas.tex. Zawiera
+on również dwa makra:
+
+ 1. \BeginPascal ... \EndPascal
+
+ 2. \InsertPascal{nazwapliku}
+
+Działają one analogicznie. W przypadku \BeginPascal ... \EndPascal
+obowiązują podobne ograniczenia na wielkość formatowanego programu.
+W programie rozpoznawane są zarówno {takie} jak i (*takie*) komentarze.
+
+Lista słów kluczowych pochodzi z Pomocy Borland Delphi. W razie potrzeby
+można ją zmodyfikować.
+
+
+ Wspólne
+---------
+Czcionki używane do składania programów są zadeklarowane na początku
+pliku cap_comm.tex. W razie potrzeby można je łatwo przedefiniować.
+
+
+ Uwaga
+-------
+Jeśli modyfikujesz któryś z plików, zaznacz wyraźnie swoje zmiany. Nie
+chcę brać odpowiedzialności na modyfikacje wprowadzone przez innych.
+
+
+------------
+
+ Michał Gulczyński
+ mgulcz@we.tuniv.szczecin.pl