diff options
Diffstat (limited to 'Build/source/texk/web2c/cwebdir/cweave.w')
-rw-r--r-- | Build/source/texk/web2c/cwebdir/cweave.w | 86 |
1 files changed, 45 insertions, 41 deletions
diff --git a/Build/source/texk/web2c/cwebdir/cweave.w b/Build/source/texk/web2c/cwebdir/cweave.w index ffd835e76dc..71e5ee3df8a 100644 --- a/Build/source/texk/web2c/cwebdir/cweave.w +++ b/Build/source/texk/web2c/cwebdir/cweave.w @@ -2,7 +2,7 @@ % This program by Silvio Levy and Donald E. Knuth % is based on a program by Knuth. % It is distributed WITHOUT ANY WARRANTY, express or implied. -% Version 4.4 --- June 2021 +% Version 4.5 --- July 2021 % Copyright (C) 1987,1990,1993,2000 Silvio Levy and Donald E. Knuth @@ -32,11 +32,11 @@ \def\skipxTeX{\\{skip\_\TEX/}} \def\copyxTeX{\\{copy\_\TEX/}} -\def\title{CWEAVE (Version 4.4)} +\def\title{CWEAVE (Version 4.5)} \def\topofcontents{\null\vfill \centerline{\titlefont The {\ttitlefont CWEAVE} processor} \vskip 15pt - \centerline{(Version 4.4)} + \centerline{(Version 4.5)} \vfill} \def\botofcontents{\vfill \noindent @@ -67,7 +67,7 @@ Crusius, and others who have contributed improvements. The ``banner line'' defined here should be changed whenever \.{CWEAVE} is modified. -@d banner "This is CWEAVE (Version 4.4)" +@d banner "This is CWEAVE (Version 4.5)" @c @<Include files@>@/ @@ -245,7 +245,7 @@ If one were careful, one could probably make more changes around section 115 to avoid a lot of identifier looking up. @d append_xref(c) if (xref_ptr==xmem_end) overflow("cross-reference"); - else (++xref_ptr)->num=c; + else (++xref_ptr)->num=c @d no_xref !make_xrefs @d is_tiny(p) length(p)==1 @d unindexed(a) ((a)<res_wd_end && (a)->ilk>=custom) @@ -650,7 +650,7 @@ skip_TeX(void) /* skip past pure \TEX/ code */ if (loc>limit && get_line()==false) return new_section; *(limit+1)='@@'; while (*loc!='@@' && *loc!='|') loc++; - if (*loc++ =='|') return '|'; + if (*loc++ =='|') return (eight_bits)'|'; if (loc<=limit) return ccode[(eight_bits)*(loc++)]; } } @@ -711,13 +711,13 @@ get_next(void) /* produces the next input token */ @<Check if we're at the end of a preprocessor command@>@; if (loc>limit && get_line()==false) return new_section; c=*(loc++); - if (xisdigit(c) || c=='.') @<Get a constant@>@; + if (xisdigit((int)c) || c=='.') @<Get a constant@>@; else if (c=='\'' || c=='"'@| || ((c=='L' || c=='u' || c=='U')&&(*loc=='\'' || *loc=='"'))@| || ((c=='u' && *loc=='8')&&(*(loc+1)=='\'' || *(loc+1)=='"'))@| || (c=='<' && sharp_include_line==true)) @<Get a string@>@; - else if (isalpha(c) || isxalpha(c) || ishigh(c)) + else if (isalpha((int)c) || isxalpha(c) || ishigh(c)) @<Get an identifier@>@; else if (c=='@@') @<Get control code and possible section name@>@; else if (xisspace(c)) continue; /* ignore spaces and tabs */ @@ -811,8 +811,8 @@ switch(c) { id_first=--loc; do ++loc; - while (isalpha((eight_bits)*loc) || isdigit((eight_bits)*loc) @| - || isxalpha((eight_bits)*loc) || ishigh((eight_bits)*loc)); + while (isalpha((int)*loc) || isdigit((int)*loc) @| + || isxalpha(*loc) || ishigh(*loc)); id_loc=loc; return identifier; } @@ -832,7 +832,7 @@ are pointers into the array |section_text|, not into |buffer|. @d gather_digits_while(t) while ((t) || *loc=='\'') if (*loc=='\'') { /* \CPLUSPLUS/-style digit separator */ *id_loc++=' '; loc++; /* insert a little bit of space */ - }@+else *id_loc++=*loc++; + }@+else *id_loc++=*loc++ @<Get a constant@>= { id_first=id_loc=section_text+1; @@ -857,7 +857,7 @@ get_exponent: digit_suffix: while (*loc=='u' || *loc=='U' || *loc=='l' || *loc=='L' || *loc=='f' || *loc=='F') { - *id_loc++='$'; *id_loc++=toupper((eight_bits)*loc); loc++; + *id_loc++='$'; *id_loc++=toupper((int)*loc); loc++; } return constant; } @@ -947,7 +947,7 @@ switch(ccode[(eight_bits)(c=*loc++)]) { case verbatim: @<Scan a verbatim string@>@; case ord: @<Get a string@>@; case xref_roman: case xref_wildcard: case xref_typewriter: case noop: - case TeX_string: skip_restricted(); + case TeX_string: skip_restricted(); /* fall through */ default: return ccode[(eight_bits)c]; } @@ -1085,7 +1085,7 @@ phase_one(void) { changed_section[section_count]=changing; /* it will become |true| if any line changes */ if (*(loc-1)=='*' && show_progress) { - printf("*%d",section_count); + printf("*%d",(int)section_count); update_terminal; /* print a progress report */ } @<Store cross-references in the \TEX/ part of a section@>@; @@ -1490,7 +1490,7 @@ out_section( sixteen_bits n) { char s[6]; - sprintf(s,"%d",n); out_str(s); + sprintf(s,"%d",(int)n); out_str(s); if (changed_section[n]) out_str("\\*"); @.\\*@> } @@ -2240,8 +2240,8 @@ text_pointer p) case section_flag: putchar('<'); print_section_name((name_dir+r)); putchar('>'); break; - case tok_flag: printf("[[%d]]",r); break; - case inner_tok_flag: printf("|[[%d]]|",r); break; + case tok_flag: printf("[[%d]]",(int)r); break; + case inner_tok_flag: printf("|[[%d]]|",(int)r); break; default: @<Print token |r| in symbolic form@>@; } } @@ -2267,7 +2267,7 @@ switch (r) { case quoted_char: j++; printf("[%o]",(unsigned int)*j); break; case end_translation: printf("[quit]"); break; case inserted: printf("[inserted]"); break; - default: putchar(r); + default: putchar((int)r); } @ The production rules listed above are embedded directly into \.{CWEAVE}, @@ -2642,7 +2642,7 @@ to be performed, followed by |goto found|. @<Cases for |exp|@>= if (cat1==lbrace || cat1==int_like || cat1==decl) { - make_underlined(pp); big_app(dindent); big_app1(pp); + make_underlined(pp); big_app1(pp); big_app(dindent); reduce(pp,1,fn_decl,0,1); } else if (cat1==unop) squash(pp,2,exp,-2,2); @@ -3341,7 +3341,7 @@ freeze_text; return text_ptr-1; @ @<If semi-tracing, show the irreducible scraps@>= if (lo_ptr>scrap_base && tracing==partly) { - printf("\nIrreducible scrap sequence in section %d:",section_count); + printf("\nIrreducible scrap sequence in section %d:",(int)section_count); @.Irreducible scrap sequence...@> mark_harmless; for (j=scrap_base; j<=lo_ptr; j++) { @@ -3748,8 +3748,8 @@ currently in progress. The end of output occurs when an |end_translation| token is found, so the stack is never empty except when we first begin the output process. -@d inner 0 /* value of |mode| for \CEE/ texts within \TEX/ texts */ -@d outer 1 /* value of |mode| for \CEE/ texts in sections */ +@d inner false /* value of |mode| for \CEE/ texts within \TEX/ texts */ +@d outer true /* value of |mode| for \CEE/ texts in sections */ @<Typed...@>= typedef int mode; typedef struct { @@ -3913,17 +3913,21 @@ make_output(void) /* outputs the equivalents of tokens */ case end_translation: return; case identifier: case res_word: @<Output an identifier@>@; break; case section_code: @<Output a section name@>@; break; - case math_rel: out_str("\\MRL{"@q}@>); + case math_rel: out_str("\\MRL{"@q}@>); /* fall through */ @.\\MRL@> case noop: case inserted: break; case cancel: case big_cancel: c=0; b=a; while (true) { a=get_output(); if (a==inserted) continue; - if ((a<indent && !(b==big_cancel&&a==' ')) || a>big_force) break; - if (a==indent) c++; - else if (a==outdent) c--; - else if (a==opt) a=get_output(); + if ((a<indent && !(b==big_cancel&&a==' ')) @| + || (a>big_force && a!=dindent)) break; + switch (a) { + case indent: c++; break; + case outdent: c--; break; + case dindent: c+=2; break; + case opt: a=get_output(); + } } @<Output saved |indent| or |outdent| tokens@>@; goto reswitch; @@ -3935,7 +3939,7 @@ make_output(void) /* outputs the equivalents of tokens */ case indent: case outdent: case opt: case backup: case break_space: case force: case big_force: case preproc_line: @<Output a control, look ahead in case of line breaks, possibly |goto reswitch|@>@; break; - case quoted_char: out(*(cur_tok++)); + case quoted_char: out(*(cur_tok++)); /* fall through */ case qualifier: break; default: out(a); /* otherwise |a| is an ordinary character */ } @@ -4236,7 +4240,7 @@ else { @.\\N@> {@+ char s[32];@+sprintf(s,"{%d}",sec_depth+1);@+out_str(s);@+} if (show_progress) - printf("*%d",section_count); update_terminal; /* print a progress report */ + printf("*%d",(int)section_count); update_terminal; /* print a progress report */ } out('{'); out_section(section_count); out('}'); @@ -4604,7 +4608,7 @@ for (h=hash; h<=hash_end; h++) { while (next_name) { cur_name=next_name; next_name=cur_name->link; if (cur_name->xref!=(void *)xmem) { - c=(eight_bits)((cur_name->byte_start)[0]); + c=(cur_name->byte_start)[0]; if (xisupper(c)) c=tolower(c); blink[cur_name-name_dir]=bucket[c]; bucket[c]=cur_name; } @@ -4732,14 +4736,14 @@ while (sort_ptr>scrap_info) { } @ @<Split the list...@>= { - eight_bits c; + int c; next_name=sort_ptr->head; do { cur_name=next_name; next_name=blink[cur_name-name_dir]; cur_byte=cur_name->byte_start+cur_depth; if (cur_byte==(cur_name+1)->byte_start) c=0; /* hit end of the name */ else { - c=(eight_bits) *cur_byte; + c=*cur_byte; if (xisupper(c)) c=tolower(c); } blink[cur_name-name_dir]=bucket[c]; bucket[c]=cur_name; @@ -4845,30 +4849,30 @@ name_pointer p) @ @<Output all the section names@>=section_print(root); @ Because on some systems the difference between two pointers is a |ptrdiff_t| -rather than an |int|, we use \.{\%ld} to print these quantities. +rather than an |int|, we use \.{\%td} to print these quantities. @c void print_stats(void) { puts("\nMemory usage statistics:"); @.Memory usage statistics:@> - printf("%ld names (out of %ld)\n", + printf("%td names (out of %ld)\n", (ptrdiff_t)(name_ptr-name_dir),(long)max_names); - printf("%ld cross-references (out of %ld)\n", + printf("%td cross-references (out of %ld)\n", (ptrdiff_t)(xref_ptr-xmem),(long)max_refs); - printf("%ld bytes (out of %ld)\n", + printf("%td bytes (out of %ld)\n", (ptrdiff_t)(byte_ptr-byte_mem),(long)max_bytes); puts("Parsing:"); - printf("%ld scraps (out of %ld)\n", + printf("%td scraps (out of %ld)\n", (ptrdiff_t)(max_scr_ptr-scrap_info),(long)max_scraps); - printf("%ld texts (out of %ld)\n", + printf("%td texts (out of %ld)\n", (ptrdiff_t)(max_text_ptr-tok_start),(long)max_texts); - printf("%ld tokens (out of %ld)\n", + printf("%td tokens (out of %ld)\n", (ptrdiff_t)(max_tok_ptr-tok_mem),(long)max_toks); - printf("%ld levels (out of %ld)\n", + printf("%td levels (out of %ld)\n", (ptrdiff_t)(max_stack_ptr-stack),(long)stack_size); puts("Sorting:"); - printf("%ld levels (out of %ld)\n", + printf("%td levels (out of %ld)\n", (ptrdiff_t)(max_sort_ptr-scrap_info),(long)max_scraps); } |