diff --git a/texk/web2c/ChangeLog b/texk/web2c/ChangeLog index 3a79c0082e..80a19fb4de 100644 --- a/texk/web2c/ChangeLog +++ b/texk/web2c/ChangeLog @@ -1,3 +1,8 @@ +2023-06-20 Andreas Scherer + + * ctangleboot.cin, + * cwebboot.cin: Changes in cwebdir/comm-w2c.h. + 2023-06-18 Karl Berry * am/cweb.am (dist_bin_SCRIPTS): new script cwebdir/ctwill-proofsort. diff --git a/texk/web2c/ctangleboot.cin b/texk/web2c/ctangleboot.cin index bf92f40017..eeed1da09a 100644 --- a/texk/web2c/ctangleboot.cin +++ b/texk/web2c/ctangleboot.cin @@ -208,6 +208,7 @@ extern char file_name[][max_file_name_length]; extern char change_file_name[]; extern char check_file_name[]; +extern char*found_filename; extern int line[]; extern int change_line; extern int change_depth; @@ -216,7 +217,7 @@ extern boolean changing; extern boolean web_file_open; /*:7*//*9:*/ -#line 150 "cwebdir/comm-w2c.h" +#line 151 "cwebdir/comm-w2c.h" extern sixteen_bits section_count; extern boolean changed_section[]; @@ -224,7 +225,7 @@ extern boolean change_pending; extern boolean print_where; /*:9*//*10:*/ -#line 164 "cwebdir/comm-w2c.h" +#line 165 "cwebdir/comm-w2c.h" typedef struct name_info{ char*byte_start; @@ -249,12 +250,12 @@ extern hash_pointer hash_end; extern hash_pointer h; /*:10*//*12:*/ -#line 208 "cwebdir/comm-w2c.h" +#line 209 "cwebdir/comm-w2c.h" extern int history; /*:12*//*14:*/ -#line 225 "cwebdir/comm-w2c.h" +#line 226 "cwebdir/comm-w2c.h" extern int argc; extern char**argv; @@ -266,7 +267,7 @@ extern boolean flags[]; extern const char*use_language; /*:14*//*15:*/ -#line 240 "cwebdir/comm-w2c.h" +#line 241 "cwebdir/comm-w2c.h" extern FILE*C_file; extern FILE*tex_file; @@ -387,14 +388,14 @@ static eight_bits next_control; #line 71 "cwebdir/ctangle.w" /*8:*/ -#line 144 "cwebdir/comm-w2c.h" +#line 145 "cwebdir/comm-w2c.h" extern boolean get_line(void); extern void check_complete(void); extern void reset_input(void); /*:8*//*11:*/ -#line 187 "cwebdir/comm-w2c.h" +#line 188 "cwebdir/comm-w2c.h" extern boolean names_match(name_pointer,const char*,size_t,eight_bits); extern name_pointer id_lookup(const char*,const char*,eight_bits); @@ -407,7 +408,7 @@ extern void print_section_name(name_pointer); extern void sprint_section_name(char*,name_pointer); /*:11*//*13:*/ -#line 211 "cwebdir/comm-w2c.h" +#line 212 "cwebdir/comm-w2c.h" extern int wrap_up(void); extern void err_print(const char*); @@ -415,7 +416,7 @@ extern void fatal(const char*,const char*); extern void overflow(const char*); /*:13*//*16:*/ -#line 249 "cwebdir/comm-w2c.h" +#line 250 "cwebdir/comm-w2c.h" extern void common_init(void); extern void print_stats(void); diff --git a/texk/web2c/cwebboot.cin b/texk/web2c/cwebboot.cin index 679cd46640..c6b426ba47 100644 --- a/texk/web2c/cwebboot.cin +++ b/texk/web2c/cwebboot.cin @@ -214,6 +214,7 @@ extern char file_name[][max_file_name_length]; extern char change_file_name[]; extern char check_file_name[]; +extern char*found_filename; extern int line[]; extern int change_line; extern int change_depth; @@ -222,7 +223,7 @@ extern boolean changing; extern boolean web_file_open; /*:6*//*8:*/ -#line 150 "cwebdir/comm-w2c.h" +#line 151 "cwebdir/comm-w2c.h" extern sixteen_bits section_count; extern boolean changed_section[]; @@ -230,7 +231,7 @@ extern boolean change_pending; extern boolean print_where; /*:8*//*9:*/ -#line 164 "cwebdir/comm-w2c.h" +#line 165 "cwebdir/comm-w2c.h" typedef struct name_info{ char*byte_start; @@ -255,12 +256,12 @@ extern hash_pointer hash_end; extern hash_pointer h; /*:9*//*11:*/ -#line 208 "cwebdir/comm-w2c.h" +#line 209 "cwebdir/comm-w2c.h" extern int history; /*:11*//*13:*/ -#line 225 "cwebdir/comm-w2c.h" +#line 226 "cwebdir/comm-w2c.h" extern int argc; extern char**argv; @@ -272,7 +273,7 @@ extern boolean flags[]; extern const char*use_language; /*:13*//*14:*/ -#line 240 "cwebdir/comm-w2c.h" +#line 241 "cwebdir/comm-w2c.h" extern FILE*C_file; extern FILE*tex_file; @@ -420,14 +421,14 @@ string texmf_locale; #line 66 "cwebdir/common.w" /*7:*/ -#line 144 "cwebdir/comm-w2c.h" +#line 145 "cwebdir/comm-w2c.h" extern boolean get_line(void); extern void check_complete(void); extern void reset_input(void); /*:7*//*10:*/ -#line 187 "cwebdir/comm-w2c.h" +#line 188 "cwebdir/comm-w2c.h" extern boolean names_match(name_pointer,const char*,size_t,eight_bits); extern name_pointer id_lookup(const char*,const char*,eight_bits); @@ -440,7 +441,7 @@ extern void print_section_name(name_pointer); extern void sprint_section_name(char*,name_pointer); /*:10*//*12:*/ -#line 211 "cwebdir/comm-w2c.h" +#line 212 "cwebdir/comm-w2c.h" extern int wrap_up(void); extern void err_print(const char*); @@ -448,7 +449,7 @@ extern void fatal(const char*,const char*); extern void overflow(const char*); /*:12*//*15:*/ -#line 249 "cwebdir/comm-w2c.h" +#line 250 "cwebdir/comm-w2c.h" extern void common_init(void); extern void print_stats(void); diff --git a/texk/web2c/cwebdir/ChangeLog b/texk/web2c/cwebdir/ChangeLog index 9e1f65103c..a58efbcd74 100644 --- a/texk/web2c/cwebdir/ChangeLog +++ b/texk/web2c/cwebdir/ChangeLog @@ -1,3 +1,10 @@ +2023-06-20 Andreas Scherer + + * comm-w2c.h, + * ctwill-mini.ch, + * ctwill-w2c.ch, + * ctwill.bux: Use 'kpse_find_file' for '*.bux' files. + 2023-06-18 Karl Berry * ctwill-proofsort: die if getopt fails; diff --git a/texk/web2c/cwebdir/comm-w2c.h b/texk/web2c/cwebdir/comm-w2c.h index 1046149331..96197a49c9 100644 --- a/texk/web2c/cwebdir/comm-w2c.h +++ b/texk/web2c/cwebdir/comm-w2c.h @@ -134,6 +134,7 @@ extern char file_name[][max_file_name_length]; /* stack of non-change file names */ extern char change_file_name[]; /* name of change file */ extern char check_file_name[]; /* name of |check_file| */ +extern char *found_filename; /* filename found by |kpse_find_file| */ extern int line[]; /* number of current line in the stacked files */ extern int change_line; /* number of current line in change file */ extern int change_depth; /* where \.{@@y} originated during a change */ diff --git a/texk/web2c/cwebdir/ctwill-mini.ch b/texk/web2c/cwebdir/ctwill-mini.ch index b9dc31516a..55a7a7b29c 100644 --- a/texk/web2c/cwebdir/ctwill-mini.ch +++ b/texk/web2c/cwebdir/ctwill-mini.ch @@ -2161,6 +2161,15 @@ Section 322. Section 328. +@x l.116 of CTWILL-TEXLIVE.CH +@d kpse_find_cweb(name) kpse_find_file(name,kpse_cweb_format,true) +@y +@d kpse_find_cweb(name) kpse_find_file(name,kpse_cweb_format,true) +@-name@> +@z + +Section 330. + @x @** Index. If you have read and understood the code for Phase III above, you know what diff --git a/texk/web2c/cwebdir/ctwill-w2c.ch b/texk/web2c/cwebdir/ctwill-w2c.ch index 93ebf3f40a..9df19c7b0a 100644 --- a/texk/web2c/cwebdir/ctwill-w2c.ch +++ b/texk/web2c/cwebdir/ctwill-w2c.ch @@ -37,6 +37,7 @@ @x \def\title{CWEAVE (Version 4.9)} @y +\def\Kpathsea/{{\mc KPATHSEA\spacefactor1000}} \ifacro\sanitizecommand\Kpathsea{KPATHSEA}\fi \def\title{CTWILL (Version 4.9 [\TeX~Live])} @z @@ -1787,12 +1788,20 @@ memcpy(aux_file_name,tex_file_name,strlen(tex_file_name)-4); strcat(aux_file_name,".bux"); include_depth=1; /* we simulate \.{@@i} */ strcpy(cur_file_name,aux_file_name); /* first in, third out */ -if ((cur_file=fopen(cur_file_name,"r"))) { cur_line=0; include_depth++; } +if ( (found_filename = kpse_find_cweb(cur_file_name)) @| + && ((cur_file=fopen(found_filename,"r"))) ) { + @@; + cur_line=0; include_depth++; +} strcpy(aux_file_name+strlen(aux_file_name)-4,".aux");@/ strcpy(cur_file_name,aux_file_name); /* second in, second out */ if ((cur_file=fopen(cur_file_name,"r"))) { cur_line=0; include_depth++; } strcpy(cur_file_name,"system.bux"); /* third in, first out */ -if ((cur_file=fopen(cur_file_name,"r"))) cur_line=0; +if ( (found_filename = kpse_find_cweb(cur_file_name)) @| + && ((cur_file=fopen(found_filename,"r"))) ) { + @@; + cur_line=0; +} else include_depth--; if (include_depth) { /* at least one new file was opened */ while (get_next()==meaning) ; /* new meaning is digested */ @@ -2036,6 +2045,43 @@ extern char cb_banner[]; @ @= strncpy(cb_banner,banner,max_banner-1); +@* File lookup with \Kpathsea/. The \.{CTANGLE} and \.{CWEAVE} programs from +the original \.{CWEB} package use the compile-time default directory or the +value of the environment variable \.{CWEBINPUTS} as an alternative place to be +searched for files, if they could not be found in the current directory. + +This version uses the \Kpathsea/ mechanism for searching files. +The directories to be searched for come from three sources: +\smallskip +{\parindent1em +\item{(a)} a user-set environment variable \.{CWEBINPUTS} + (overridden by \.{CWEBINPUTS\_cweb}); +\item{(b)} a line in \Kpathsea/ configuration file \.{texmf.cnf},\hfil\break + e.g., \.{CWEBINPUTS=\$TEXMFDOTDIR:\$TEXMF/texmf/cweb//}\hfil\break + or \.{CWEBINPUTS.cweb=\$TEXMFDOTDIR:\$TEXMF/texmf/cweb//}; +\item{(c)} compile-time default directories (specified in + \.{texmf.in}),\hfil\break + i.e., \.{\$TEXMFDOTDIR:\$TEXMF/texmf/cweb//}.\par} +@.CWEBINPUTS@> + +@s const_string int +@s string int + +@d kpse_find_cweb(name) kpse_find_file(name,kpse_cweb_format,true) + +@= +#include /* include every \Kpathsea/ header; + for |@!kpse_find_file| */ + +@ @= +if (strlen(found_filename) < max_file_name_length) { + if (strcmp(cur_file_name,found_filename)) { + strcpy(cur_file_name,found_filename + @| + ((strncmp(found_filename,"./",2)==0) ? 2 : 0)); /* Strip path prefix */ + free(found_filename); + } +}@+else fatal(_("! Filename too long\n"), found_filename); + @** Index. @z diff --git a/texk/web2c/cwebdir/ctwill.bux b/texk/web2c/cwebdir/ctwill.bux index 9c0c43595a..1203af5954 100644 --- a/texk/web2c/cwebdir/ctwill.bux +++ b/texk/web2c/cwebdir/ctwill.bux @@ -79,6 +79,7 @@ @$scn_file {COMMON.W}83 \&{FILE} ${*}$@> @$check_file {COMMON.W}83 \&{FILE} ${*}$@> @$active_file {COMMON.W}83 \&{FILE} ${*}$@> +@$found_filename {COMMON.W}83 \&{char} ${*}$@> @$use_language {COMMON.W}86 \&{const char} ${*}$@> @@ -86,4 +87,6 @@ @$cb_show_banner {COMMON.W}99 \&{void} (\,)@> +@$kpse_cweb_format "" \zip@> +@$kpse_find_file "" \zip@> @$versionstring "" \zip@>