Showing the changes to ctangle.w (1 of 16 files). Show all
Unified · Split
| @@ -2,7 +2,7 @@ · 1 unmodified line | |||
| 2 | % This program by Silvio Levy and Donald E. Knuth | 2 | % This program by Silvio Levy and Donald E. Knuth |
| 3 | % is based on a program by Knuth. | 3 | % is based on a program by Knuth. |
| 4 | % It is distributed WITHOUT ANY WARRANTY, express or implied. | 4 | % It is distributed WITHOUT ANY WARRANTY, express or implied. |
| 5 | % Version 3.2 --- July 1994 | 5 | % Version 3.3 --- December 1994 |
| 6 | 6 | ||
| 7 | % Copyright (C) 1987,1990,1993 Silvio Levy and Donald E. Knuth | 7 | % Copyright (C) 1987,1990,1993 Silvio Levy and Donald E. Knuth |
| 8 | 8 | ||
| @@ -22,11 +22,11 @@ · 13 unmodified lines | |||
| 22 | \mathchardef\RA="3221 % right arrow | 22 | \mathchardef\RA="3221 % right arrow |
| 23 | \mathchardef\BA="3224 % double arrow | 23 | \mathchardef\BA="3224 % double arrow |
| 24 | 24 | ||
| 25 | \def\title{CTANGLE (Version 3.2)} | 25 | \def\title{CTANGLE (Version 3.3)} |
| 26 | \def\topofcontents{\null\vfill | 26 | \def\topofcontents{\null\vfill |
| 27 | \centerline{\titlefont The {\ttitlefont CTANGLE} processor} | 27 | \centerline{\titlefont The {\ttitlefont CTANGLE} processor} |
| 28 | \vskip 15pt | 28 | \vskip 15pt |
| 29 | \centerline{(Version 3.2)} | 29 | \centerline{(Version 3.3)} |
| 30 | \vfill} | 30 | \vfill} |
| 31 | \def\botofcontents{\vfill | 31 | \def\botofcontents{\vfill |
| 32 | \noindent | 32 | \noindent |
| @@ -56,7 +56,7 @@ Joachim Schrod, Lee Wittenberg, and others who have contributed improvements. · 23 unmodified lines | |||
| 56 | The ``banner line'' defined here should be changed whenever \.{CTANGLE} | 56 | The ``banner line'' defined here should be changed whenever \.{CTANGLE} |
| 57 | is modified. | 57 | is modified. |
| 58 | 58 | ||
| 59 | @d banner "This is CTANGLE (Version 3.2)\n" | 59 | @d banner "This is CTANGLE (Version 3.3)\n" |
| 60 | 60 | ||
| 61 | @c | 61 | @c |
| 62 | @<Include files@>@/ | 62 | @<Include files@>@/ |
| @@ -640,10 +640,10 @@ is not called if |out_state==verbatim|, except perhaps with arguments · 577 unmodified lines | |||
| 640 | (end the constant). | 640 | (end the constant). |
| 641 | 641 | ||
| 642 | @<Predecl...@>= | 642 | @<Predecl...@>= |
| 643 | void out_char(); | 643 | static void out_char(); |
| 644 | 644 | ||
| 645 | @ @c | 645 | @ @c |
| 646 | void | 646 | static void |
| 647 | out_char(cur_char) | 647 | out_char(cur_char) |
| 648 | eight_bits cur_char; | 648 | eight_bits cur_char; |
| 649 | { | 649 | { |
| @@ -827,7 +827,7 @@ newline. The boolean argument |is_long_comment| distinguishes between · 177 unmodified lines | |||
| 827 | the two types of comments. | 827 | the two types of comments. |
| 828 | 828 | ||
| 829 | If |skip_comment| comes to the end of the section, it prints an error message. | 829 | If |skip_comment| comes to the end of the section, it prints an error message. |
| 830 | No comment, long or short, is allowed to contain `\.{@@ }' or `\.{@@*}'. | 830 | No comment, long or short, is allowed to contain `\.{@@\ }' or `\.{@@*}'. |
| 831 | 831 | ||
| 832 | @<Global...@>= | 832 | @<Global...@>= |
| 833 | boolean comment_continues=0; /* are we scanning a comment? */ | 833 | boolean comment_continues=0; /* are we scanning a comment? */ |
| @@ -870,6 +870,7 @@ boolean is_long_comment; · 36 unmodified lines | |||
| 870 | 870 | ||
| 871 | @<Global...@>= | 871 | @<Global...@>= |
| 872 | name_pointer cur_section_name; /* name of section just scanned */ | 872 | name_pointer cur_section_name; /* name of section just scanned */ |
| 873 | int no_where; /* suppress |print_where|? */ | ||
| 873 | 874 | ||
| 874 | @ @<Include...@>= | 875 | @ @<Include...@>= |
| 875 | #include <ctype.h> /* definition of |isalpha|, |isdigit| and so on */ | 876 | #include <ctype.h> /* definition of |isalpha|, |isdigit| and so on */ |
| @@ -892,7 +893,7 @@ get_next() /* produces the next input token */ · 16 unmodified lines | |||
| 892 | if (loc>limit) { | 893 | if (loc>limit) { |
| 893 | if (preprocessing && *(limit-1)!='\\') preprocessing=0; | 894 | if (preprocessing && *(limit-1)!='\\') preprocessing=0; |
| 894 | if (get_line()==0) return(new_section); | 895 | if (get_line()==0) return(new_section); |
| 895 | else if (print_where) { | 896 | else if (print_where && !no_where) { |
| 896 | print_where=0; | 897 | print_where=0; |
| 897 | @<Insert the line number into |tok_mem|@>; | 898 | @<Insert the line number into |tok_mem|@>; |
| 898 | } | 899 | } |
| @@ -1170,6 +1171,9 @@ the name of the current section. · 271 unmodified lines | |||
| 1170 | \item{b)}The symbols \.{@@d} and \.{@@f} and \.{@@c} are not allowed after | 1171 | \item{b)}The symbols \.{@@d} and \.{@@f} and \.{@@c} are not allowed after |
| 1171 | section names, while they terminate macro definitions. | 1172 | section names, while they terminate macro definitions. |
| 1172 | 1173 | ||
| 1174 | \item{c)}Spaces are inserted after right parentheses in macros, because the | ||
| 1175 | ANSI \CEE/ preprocessor sometimes requires it. | ||
| 1176 | |||
| 1173 | \yskip Therefore there is a single procedure |scan_repl| whose parameter | 1177 | \yskip Therefore there is a single procedure |scan_repl| whose parameter |
| 1174 | |t| specifies either |macro| or |section_name|. After |scan_repl| has | 1178 | |t| specifies either |macro| or |section_name|. After |scan_repl| has |
| 1175 | acted, |cur_text| will point to the replacement text just generated, and | 1179 | acted, |cur_text| will point to the replacement text just generated, and |
| @@ -1194,6 +1198,9 @@ eight_bits t; · 18 unmodified lines | |||
| 1194 | |section_name|, etc.), either process it and change |a| to a byte | 1198 | |section_name|, etc.), either process it and change |a| to a byte |
| 1195 | that should be stored, or |continue| if |a| should be ignored, | 1199 | that should be stored, or |continue| if |a| should be ignored, |
| 1196 | or |goto done| if |a| signals the end of this replacement text@>@; | 1200 | or |goto done| if |a| signals the end of this replacement text@>@; |
| 1201 | case ')': app_repl(a); | ||
| 1202 | if (t==macro) app_repl(' '); | ||
| 1203 | break; | ||
| 1197 | default: app_repl(a); /* store |a| in |tok_mem| */ | 1204 | default: app_repl(a); /* store |a| in |tok_mem| */ |
| 1198 | } | 1205 | } |
| 1199 | done: next_control=(eight_bits) a; | 1206 | done: next_control=(eight_bits) a; |
| @@ -1212,11 +1219,11 @@ else id_first=cur_file_name; · 12 unmodified lines | |||
| 1212 | id_loc=id_first+strlen(id_first); | 1219 | id_loc=id_first+strlen(id_first); |
| 1213 | if (changing) store_two_bytes((sixteen_bits)change_line); | 1220 | if (changing) store_two_bytes((sixteen_bits)change_line); |
| 1214 | else store_two_bytes((sixteen_bits)cur_line); | 1221 | else store_two_bytes((sixteen_bits)cur_line); |
| 1215 | {int a=id_lookup(id_first,id_loc)-name_dir; app_repl((a / 0400)+0200); | 1222 | {int a=id_lookup(id_first,id_loc,0)-name_dir; app_repl((a / 0400)+0200); |
| 1216 | app_repl(a % 0400);} | 1223 | app_repl(a % 0400);} |
| 1217 | 1224 | ||
| 1218 | @ @<In cases that |a| is...@>= | 1225 | @ @<In cases that |a| is...@>= |
| 1219 | case identifier: a=id_lookup(id_first,id_loc)-name_dir; | 1226 | case identifier: a=id_lookup(id_first,id_loc,0)-name_dir; |
| 1220 | app_repl((a / 0400)+0200); | 1227 | app_repl((a / 0400)+0200); |
| 1221 | app_repl(a % 0400); break; | 1228 | app_repl(a % 0400); break; |
| 1222 | case section_name: if (t!=section_name) goto done; | 1229 | case section_name: if (t!=section_name) goto done; |
| @@ -1339,7 +1346,7 @@ scan_section() · 116 unmodified lines | |||
| 1339 | name_pointer p; /* section name for the current section */ | 1346 | name_pointer p; /* section name for the current section */ |
| 1340 | text_pointer q; /* text for the current section */ | 1347 | text_pointer q; /* text for the current section */ |
| 1341 | sixteen_bits a; /* token for left-hand side of definition */ | 1348 | sixteen_bits a; /* token for left-hand side of definition */ |
| 1342 | section_count++; | 1349 | section_count++; @+ no_where=1; |
| 1343 | if (*(loc-1)=='*' && show_progress) { /* starred section */ | 1350 | if (*(loc-1)=='*' && show_progress) { /* starred section */ |
| 1344 | printf("*%d",section_count); update_terminal; | 1351 | printf("*%d",section_count); update_terminal; |
| 1345 | } | 1352 | } |
| @@ -1361,6 +1368,7 @@ scan_section() · 15 unmodified lines | |||
| 1361 | } | 1368 | } |
| 1362 | return; /* \.{@@\ } or \.{@@*} */ | 1369 | return; /* \.{@@\ } or \.{@@*} */ |
| 1363 | } | 1370 | } |
| 1371 | no_where=print_where=0; | ||
| 1364 | @<Scan the \CEE/ part of the current section@>; | 1372 | @<Scan the \CEE/ part of the current section@>; |
| 1365 | } | 1373 | } |
| 1366 | 1374 | ||
| @@ -1384,13 +1392,13 @@ while (next_control<definition) · 17 unmodified lines | |||
| 1384 | @.Definition flushed...@> | 1392 | @.Definition flushed...@> |
| 1385 | continue; | 1393 | continue; |
| 1386 | } | 1394 | } |
| 1387 | app_repl(((a=id_lookup(id_first,id_loc)-name_dir) / 0400)+0200); | 1395 | app_repl(((a=id_lookup(id_first,id_loc,0)-name_dir) / 0400)+0200); |
| 1388 | /* append the lhs */ | 1396 | /* append the lhs */ |
| 1389 | app_repl(a % 0400); | 1397 | app_repl(a % 0400); |
| 1390 | if (*loc!='(') { /* identifier must be separated from replacement text */ | 1398 | if (*loc!='(') { /* identifier must be separated from replacement text */ |
| 1391 | app_repl(string); app_repl(' '); app_repl(string); | 1399 | app_repl(string); app_repl(' '); app_repl(string); |
| 1392 | } | 1400 | } |
| 1393 | print_where=0; scan_repl(macro); | 1401 | scan_repl(macro); |
| 1394 | cur_text->text_link=0; /* |text_link==0| characterizes a macro */ | 1402 | cur_text->text_link=0; /* |text_link==0| characterizes a macro */ |
| 1395 | } | 1403 | } |
| 1396 | 1404 | ||