diff options
author | Andreas Scherer <andreas_tex@freenet.de> | 2021-02-24 18:19:47 +0000 |
---|---|---|
committer | Andreas Scherer <andreas_tex@freenet.de> | 2021-02-24 18:19:47 +0000 |
commit | 5f6231423ff11a042181be707faa0db6012b8e35 (patch) | |
tree | 1aa670b8921584ddbc3c972cb6016d4bbb670606 /Build/source/texk/web2c/cwebdir/common.w | |
parent | 180bb00c12d352e3d1c374a1587d4dc898300c5f (diff) |
[CWEB] Code review.
Compactify single function declarations.
git-svn-id: svn://tug.org/texlive/trunk@57874 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/cwebdir/common.w')
-rw-r--r-- | Build/source/texk/web2c/cwebdir/common.w | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/Build/source/texk/web2c/cwebdir/common.w b/Build/source/texk/web2c/cwebdir/common.w index 2b90275437d..d8ce0be34cd 100644 --- a/Build/source/texk/web2c/cwebdir/common.w +++ b/Build/source/texk/web2c/cwebdir/common.w @@ -68,7 +68,7 @@ The file begins with a few basic definitions. @h @<Common code for \.{CWEAVE} and \.{CTANGLE}@>@/ @<Global variables@>@/ -@<Predeclaration of procedures@>@/ +@<Predeclaration of procedures@> @ The details will be filled in due course. The interface of this module is included first. It is also used by the main programs. @@ -89,7 +89,8 @@ produces the \TEX/ output file, and finally it sorts and outputs the index. Similarly, \.{CTANGLE} operates in two phases. The global variable |phase| tells which phase we are in. -@<Global var...@>= int phase; /* which phase are we in? */ +@<Global var...@>= +int phase; /* which phase are we in? */ @ There's an initialization procedure that gets both \.{CTANGLE} and \.{CWEAVE} off to a good start. We will fill in the details of this @@ -156,10 +157,7 @@ char *limit=buffer; /* points to the last character in the buffer */ support |feof|, |getc|, and |ungetc| you may have to change things here. @^system dependencies@> -@<Predecl...@>= -static boolean input_ln(FILE *);@/ - -@ @c +@c static boolean input_ln(@t\1\1@> /* copies a line into |buffer| or returns |false| */ FILE *fp@t\2\2@>) /* what file to read from */ { @@ -179,6 +177,8 @@ FILE *fp@t\2\2@>) /* what file to read from */ return true; } +@ @<Predecl...@>=@+static boolean input_ln(FILE *); + @ Now comes the problem of deciding which file to read from next. Recall that the actual text that \.{CWEB} should process comes from two streams: a |web_file|, which can contain possibly nested include @@ -228,10 +228,7 @@ Since blank lines in the change file are not used for matching, we have the change file is exhausted. This procedure is called only when |changing| is |true|; hence error messages will be reported correctly. -@<Predecl...@>= -static void prime_the_change_buffer(void);@/ - -@ @c +@c static void prime_the_change_buffer(void) { @@ -241,6 +238,8 @@ prime_the_change_buffer(void) @<Move |buffer| and |limit| to |change_buffer| and |change_limit|@>@; } +@ @<Predecl...@>=@+static void prime_the_change_buffer(void); + @ While looking for a line that begins with \.{@@x} in the change file, we allow lines that begin with \.{@@}, as long as they don't begin with \.{@@y}, \.{@@z}, or \.{@@i} (which would probably mean that the change file is fouled up). @@ -300,10 +299,7 @@ current line is nonempty. if (*loc=='@@' && (xisspace(*(loc+1)) || *(loc+1)=='*')) change_pending=b; } -@<Predecl...@>= -static void check_change(void);@/ - -@ @c +@c static void check_change(void) /* switches to |change_file| if the buffers match */ { @@ -341,6 +337,8 @@ check_change(void) /* switches to |change_file| if the buffers match */ } } +@ @<Predecl...@>=@+static void check_change(void); + @ @<If the current line starts with \.{@@y}...@>= if (xyz_code=='x' || xyz_code=='z') { loc=buffer+2; err_print("! Where is the matching @@y?"); @@ -776,7 +774,7 @@ are null-terminated, and we keep an eye open for prefixes and extensions. @<Predecl...@>= static int web_strcmp(char *,int,char *,int);@/ static name_pointer add_section_name(name_pointer,int,char *,char *,int);@/ -static void extend_section_name(name_pointer,char *,char *,int);@/ +static void extend_section_name(name_pointer,char *,char *,int); @ @c static int web_strcmp(@t\1\1@> /* fuller comparison than |strcmp| */ @@ -969,10 +967,7 @@ us to regard \.{@@<foo...@@>} as an ``extension'' of itself. @d bad_extension 5 -@<Predec...@>= -static int section_name_cmp(char **,int,name_pointer);@/ - -@ @c +@c static int section_name_cmp(@t\1\1@> char **pfirst, /* pointer to beginning of comparison string */ int len, /* length of string */ @@ -1004,6 +999,8 @@ name_pointer r@t\2\2@>) /* section name being compared */ } } +@ @<Predec...@>=@+static int section_name_cmp(char **,int,name_pointer); + @** Reporting errors to the user. A global variable called |history| will contain one of four values at the end of every run: |spotless| means that no unusual messages were @@ -1150,7 +1147,7 @@ should be set before calling |common_init|. @<Set the default options common to \.{CTANGLE} and \.{CWEAVE}@>= show_banner=show_happiness=show_progress=make_xrefs=true;@/ -show_stats=false;@/ +show_stats=false; @ We now must look at the command line arguments and set the file names accordingly. At least one file name must be present: the \.{CWEB} @@ -1167,10 +1164,7 @@ when no changes are desired. If there's a third file name, it will be the output file. -@<Pred...@>= -static void scan_args(void);@/ - -@ @c +@c static void scan_args(void) { @@ -1200,6 +1194,8 @@ scan_args(void) if (!found_web) @<Print usage error message and quit@>@; } +@ @<Pred...@>=@+static void scan_args(void); + @ We use all of |*argv| for the |web_file_name| if there is a |'.'| in it, otherwise we add |".w"|. If this file can't be opened, we prepare an |alt_web_file_name| by adding |"web"| after the dot. |