Skip to content

Commit

Permalink
[CWEB] Syntactic sugar.
Browse files Browse the repository at this point in the history
See 'too_long()' macro in common.w.

git-svn-id: svn://tug.org/texlive/trunk/Build/source@67762 c570f23f-e606-0410-a88d-b1316a301751
  • Loading branch information
Andreas Scherer committed Jul 29, 2023
1 parent 2102a5e commit 5610852
Show file tree
Hide file tree
Showing 16 changed files with 141 additions and 125 deletions.
24 changes: 12 additions & 12 deletions texk/web2c/ctangleboot.cin
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@
#define harmless_message 1
#define error_message 2
#define fatal_message 3
#define mark_harmless if(history==spotless) history= harmless_message
#define mark_error history= error_message
#define mark_harmless() if(history==spotless) history= harmless_message
#define mark_error() history= error_message
#define confusion(s) fatal(_("! This can't happen: ") ,s) \
\

Expand All @@ -95,8 +95,8 @@
#define make_xrefs flags['x']
#define check_for_change flags['c'] \

#define update_terminal fflush(stdout)
#define new_line putchar('\n')
#define update_terminal() fflush(stdout)
#define new_line() putchar('\n')
#define term_write(a,b) fflush(stdout) ,fwrite(a,sizeof(char) ,b,stdout) \

#define buf_size 1000
Expand Down Expand Up @@ -693,7 +693,7 @@ C_putc('\n');
if(cur_line%100==0&&show_progress){
putchar('.');
if(cur_line%500==0)printf("%d",cur_line);
update_terminal;
update_terminal();
}
cur_line++;
}
Expand Down Expand Up @@ -726,7 +726,7 @@ output_defs();

if(text_info->text_link==macro&&cur_out_file==end_output_files){
#line 97 "cwebdir/ctang-w2c.ch"
fputs(_("\n! No program text was specified."),stdout);mark_harmless;
fputs(_("\n! No program text was specified."),stdout);mark_harmless();
#line 519 "cwebdir/ctangle.w"

}
Expand All @@ -736,7 +736,7 @@ if(show_progress){
#line 103 "cwebdir/ctang-w2c.ch"
printf(_("\nWriting the output file (%s):"),C_file_name);
#line 525 "cwebdir/ctangle.w"
update_terminal;
update_terminal();
}
}
else{
Expand All @@ -746,7 +746,7 @@ fputs(_("\nWriting the output files:"),stdout);
#line 531 "cwebdir/ctangle.w"

printf(" (%s)",C_file_name);
update_terminal;
update_terminal();
}
if(text_info->text_link==macro)goto writeloop;
}
Expand Down Expand Up @@ -833,7 +833,7 @@ if((C_file= fopen(output_file_name,"wb"))==NULL)
fatal(_("! Cannot open output file "),output_file_name);

}
if(show_progress){printf("\n(%s)",output_file_name);update_terminal;}
if(show_progress){printf("\n(%s)",output_file_name);update_terminal();}
cur_line= 1;
stack_ptr= stack+1;
cur_name= *an_output_file;
Expand Down Expand Up @@ -1012,7 +1012,7 @@ strcpy(check_file_name,"");
#line 539 "cwebdir/ctangle.w"

if(show_happiness){
if(show_progress)new_line;
if(show_progress)new_line();
#line 115 "cwebdir/ctang-w2c.ch"
fputs(_("Done."),stdout);
#line 543 "cwebdir/ctangle.w"
Expand Down Expand Up @@ -1451,7 +1451,7 @@ fputs(_("\n! Section name too long: "),stdout);
#line 1123 "cwebdir/ctangle.w"

term_write(section_text+1,25);
printf("...");mark_harmless;
printf("...");mark_harmless();
}
if(*k==' '&&k> section_text)k--;

Expand Down Expand Up @@ -1809,7 +1809,7 @@ text_pointer q;
sixteen_bits a;
section_count++;no_where= true;
if(*(loc-1)=='*'&&show_progress){
printf("*%d",(int)section_count);update_terminal;
printf("*%d",(int)section_count);update_terminal();
}
next_control= ignore;
while(true){
Expand Down
14 changes: 7 additions & 7 deletions texk/web2c/cwebboot.cin
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@
#define harmless_message 1
#define error_message 2
#define fatal_message 3
#define mark_harmless if(history==spotless) history= harmless_message
#define mark_error history= error_message
#define mark_harmless() if(history==spotless) history= harmless_message
#define mark_error() history= error_message
#define confusion(s) fatal(_("! This can't happen: ") ,s) \
\

Expand All @@ -119,8 +119,8 @@
#define make_xrefs flags['x']
#define check_for_change flags['c'] \

#define update_terminal fflush(stdout)
#define new_line putchar('\n')
#define update_terminal() fflush(stdout)
#define new_line() putchar('\n')
#define term_write(a,b) fflush(stdout) ,fwrite(a,sizeof(char) ,b,stdout) \

#define buf_size 1000
Expand Down Expand Up @@ -1326,7 +1326,7 @@ if(l> buffer){
for(k= buffer;k<l;k++)
if(*k=='\t')putchar(' ');
else putchar(*k);
new_line;
new_line();
for(k= buffer;k<l;k++)putchar(' ');
}
for(k= l;k<limit;k++)putchar(*k);
Expand All @@ -1337,14 +1337,14 @@ putchar(' ');
/*:67*/
#line 1019 "cwebdir/common.w"

update_terminal;mark_error;
update_terminal();mark_error();
}

/*:66*//*68:*/
#line 1065 "cwebdir/common.w"

int wrap_up(void){
if(show_progress)new_line;
if(show_progress)new_line();
if(show_stats)
print_stats();
#line 400 "cwebdir/comm-w2c.ch"
Expand Down
16 changes: 16 additions & 0 deletions texk/web2c/cwebdir/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
2023-07-29 Andreas Scherer <https://ascherer.github.io>

* comm-bs.ch,
* comm-w2c.h,
* common.c,
* common.h,
* common.w,
* ctang-bs.ch,
* ctang-w2c.ch,
* ctangle.c,
* ctangle.w,
* ctwill-w2c.ch,
* cweav-bs.ch,
* cweav-w2c.ch,
* cweave.w: Syntactic sugar.

2023-07-28 Andreas Scherer <https://ascherer.github.io>

* comm-w2c.h,
Expand Down
4 changes: 2 additions & 2 deletions texk/web2c/cwebdir/comm-bs.ch
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ typedef struct name_info {
union {
struct name_info *Rlink; /* right link in binary search tree for section
names */
char Ilk; /* used by identifiers in \.{CWEAVE} only */
eight_bits Ilk; /* used by identifiers in \.{CWEAVE} only */
} dummy;
void *equiv_or_xref; /* info corresponding to names */
} name_info; /* contains information about an identifier or section name */
Expand All @@ -45,7 +45,7 @@ typedef struct name_info {
union {
struct name_info *Rlink; /* right link in binary search tree for section
names */
char Ilk; /* used by identifiers in \.{CWEAVE} only */
eight_bits Ilk; /* used by identifiers in \.{CWEAVE} only */
} dummy;
union {
void huge* equiv_member;
Expand Down
8 changes: 4 additions & 4 deletions texk/web2c/cwebdir/comm-w2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ extern void init_node(name_pointer);@/
@d harmless_message 1 /* |history| value when non-serious info was printed */
@d error_message 2 /* |history| value when an error was noted */
@d fatal_message 3 /* |history| value when we had to stop prematurely */
@d mark_harmless if (history==spotless) history=harmless_message
@d mark_error history=error_message
@d mark_harmless() if (history==spotless) history=harmless_message
@d mark_error() history=error_message
@d confusion(s) fatal(_("! This can't happen: "),s)
@.This can't happen@>

Expand Down Expand Up @@ -242,8 +242,8 @@ extern boolean flags[]; /* an option for each 7-bit code */
extern const char *use_language; /* prefix to \.{cwebmac.tex} in \TEX/ output */

@ Code related to output:
@d update_terminal fflush(stdout) /* empty the terminal output buffer */
@d new_line putchar('\n')
@d update_terminal() fflush(stdout) /* empty the terminal output buffer */
@d new_line() putchar('\n')
@d term_write(a,b) fflush(stdout),fwrite(a,sizeof(char),b,stdout)

@<Common code...@>=
Expand Down
14 changes: 7 additions & 7 deletions texk/web2c/cwebdir/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
#define harmless_message 1
#define error_message 2
#define fatal_message 3
#define mark_harmless if(history==spotless) history= harmless_message
#define mark_error history= error_message
#define mark_harmless() if(history==spotless) history= harmless_message
#define mark_error() history= error_message
#define confusion(s) fatal("! This can't happen: ",s) \
\

Expand All @@ -79,8 +79,8 @@
#define show_stats flags['s']
#define make_xrefs flags['x'] \

#define update_terminal fflush(stdout)
#define new_line putchar('\n')
#define update_terminal() fflush(stdout)
#define new_line() putchar('\n')
#define term_write(a,b) fflush(stdout) ,fwrite(a,sizeof(char) ,b,stdout) \

#define buf_size 200
Expand Down Expand Up @@ -1101,7 +1101,7 @@ if(l> buffer){
for(k= buffer;k<l;k++)
if(*k=='\t')putchar(' ');
else putchar(*k);
new_line;
new_line();
for(k= buffer;k<l;k++)putchar(' ');
}
for(k= l;k<limit;k++)putchar(*k);
Expand All @@ -1112,14 +1112,14 @@ putchar(' ');
/*:67*/
#line 1019 "common.w"

update_terminal;mark_error;
update_terminal();mark_error();
}

/*:66*//*68:*/
#line 1065 "common.w"

int wrap_up(void){
if(show_progress)new_line;
if(show_progress)new_line();
if(show_stats)
print_stats();
/*69:*/
Expand Down
8 changes: 4 additions & 4 deletions texk/web2c/cwebdir/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ extern void init_node(name_pointer);@/
@d harmless_message 1 /* |history| value when non-serious info was printed */
@d error_message 2 /* |history| value when an error was noted */
@d fatal_message 3 /* |history| value when we had to stop prematurely */
@d mark_harmless if (history==spotless) history=harmless_message
@d mark_error history=error_message
@d mark_harmless() if (history==spotless) history=harmless_message
@d mark_error() history=error_message
@d confusion(s) fatal("! This can't happen: ",s)
@.This can't happen@>

Expand Down Expand Up @@ -217,8 +217,8 @@ extern char scn_file_name[]; /* name of |scn_file| */
extern boolean flags[]; /* an option for each 7-bit code */

@ Code related to output:
@d update_terminal fflush(stdout) /* empty the terminal output buffer */
@d new_line putchar('\n')
@d update_terminal() fflush(stdout) /* empty the terminal output buffer */
@d new_line() putchar('\n')
@d term_write(a,b) fflush(stdout),fwrite(a,sizeof(char),b,stdout)

@<Common code...@>=
Expand Down
6 changes: 3 additions & 3 deletions texk/web2c/cwebdir/common.w
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ const char *s)
{
*s=='!'? printf("\n%s",s) : printf("%s",s);
if (web_file_open) @<Print error location based on input buffer@>@;
update_terminal; mark_error;
update_terminal(); mark_error();
}

@ The error locations can be indicated by using the global variables
Expand All @@ -1040,7 +1040,7 @@ if (l>buffer) {
for (k=buffer; k<l; k++)
if (*k=='\t') putchar(' ');
else putchar(*k); /* print the characters already read */
new_line;
new_line();
for (k=buffer; k<l; k++) putchar(' '); /* space out the next line */
}
for (k=l; k<limit; k++) putchar(*k); /* print the part not yet read */
Expand All @@ -1064,7 +1064,7 @@ a status of |EXIT_SUCCESS| if and only if only harmless messages were printed.

@c
int wrap_up(void) {
if (show_progress) new_line;
if (show_progress) new_line();
if (show_stats)
print_stats(); /* print statistics about memory usage */
@<Print the job |history|@>@;
Expand Down
8 changes: 4 additions & 4 deletions texk/web2c/cwebdir/ctang-bs.ch
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ is modified.


@x Section 10.
for section names */
@d ilk dummy.Ilk /* used by \.{CWEAVE} only */

@<Common code...@>=
typedef struct name_info {
Expand All @@ -36,7 +36,7 @@ typedef struct name_info {
union {
struct name_info *Rlink; /* right link in binary search tree for section
names */
char Ilk; /* used by identifiers in \.{CWEAVE} only */
eight_bits Ilk; /* used by identifiers in \.{CWEAVE} only */
} dummy;
void *equiv_or_xref; /* info corresponding to names */
} name_info; /* contains information about an identifier or section name */
Expand All @@ -52,7 +52,7 @@ extern name_pointer hash[]; /* heads of hash lists */
extern hash_pointer hash_end; /* end of |hash| */
extern hash_pointer h; /* index into hash-head array */
@y
for section names */
@d ilk dummy.Ilk /* used by \.{CWEAVE} only */

@f huge extern

Expand All @@ -63,7 +63,7 @@ typedef struct name_info {
union {
struct name_info *Rlink; /* right link in binary search tree for section
names */
char Ilk; /* used by identifiers in \.{CWEAVE} only */
eight_bits Ilk; /* used by identifiers in \.{CWEAVE} only */
} dummy;
union {
char *equiv_member;
Expand Down
8 changes: 4 additions & 4 deletions texk/web2c/cwebdir/ctang-w2c.ch
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@
@z

@x
fputs("\n! No program text was specified.",stdout); mark_harmless;
fputs("\n! No program text was specified.",stdout); mark_harmless();
@y
fputs(_("\n! No program text was specified."),stdout); mark_harmless;
fputs(_("\n! No program text was specified."),stdout); mark_harmless();
@z

@x
Expand Down Expand Up @@ -124,7 +124,7 @@ for (an_output_file=end_output_files; an_output_file>cur_out_file;) {
if ((C_file=fopen(output_file_name,"wb"))==NULL)
fatal("! Cannot open output file ",output_file_name);
@.Cannot open output file@>
if (show_progress) { printf("\n(%s)",output_file_name); update_terminal; }
if (show_progress) { printf("\n(%s)",output_file_name); update_terminal(); }
cur_line=1;
stack_ptr=stack+1;
cur_name=*an_output_file;
Expand All @@ -149,7 +149,7 @@ for (an_output_file=end_output_files; an_output_file>cur_out_file;) {
fatal(_("! Cannot open output file "),output_file_name);
@.Cannot open output file@>
}
if (show_progress) { printf("\n(%s)",output_file_name); update_terminal; }
if (show_progress) { printf("\n(%s)",output_file_name); update_terminal(); }
cur_line=1;
stack_ptr=stack+1;
cur_name=*an_output_file;
Expand Down
Loading

0 comments on commit 5610852

Please sign in to comment.