summaryrefslogtreecommitdiff
path: root/Build/source
diff options
context:
space:
mode:
authorAndreas Scherer <andreas_tex@freenet.de>2023-06-20 17:40:15 +0000
committerAndreas Scherer <andreas_tex@freenet.de>2023-06-20 17:40:15 +0000
commit45ad44f1f1e6a06556bfbe72bfe081ba5956d036 (patch)
tree56827e03245563325ec15a5411c8182f7a042d04 /Build/source
parent2e0423849863e80e149201c272e4964f556dc2f3 (diff)
[CWEB] Use 'kpse_find_file' for '*.bux' files.
In addition to '*.aux' files that CTWILL creates dynamically on the first run ("Prime the pump"), it uses several '*.bux' files to resolve external definitions, e.g., in other CWEB modules or in system headers. The '*.aux' file(s) are always created in the "current" directory, but the auxiliary '*.bux' file(s) can reside elsewhere in the file system. Just like other '@i'nclude files, these '*.bux' files can be addressed through the CWEBINPUTS environment variable. git-svn-id: svn://tug.org/texlive/trunk@67416 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
-rw-r--r--Build/source/texk/web2c/ChangeLog5
-rw-r--r--Build/source/texk/web2c/ctangleboot.cin19
-rw-r--r--Build/source/texk/web2c/cwebboot.cin19
-rw-r--r--Build/source/texk/web2c/cwebdir/ChangeLog7
-rw-r--r--Build/source/texk/web2c/cwebdir/comm-w2c.h1
-rw-r--r--Build/source/texk/web2c/cwebdir/ctwill-mini.ch9
-rw-r--r--Build/source/texk/web2c/cwebdir/ctwill-w2c.ch50
-rw-r--r--Build/source/texk/web2c/cwebdir/ctwill.bux3
8 files changed, 93 insertions, 20 deletions
diff --git a/Build/source/texk/web2c/ChangeLog b/Build/source/texk/web2c/ChangeLog
index 3a79c0082ec..80a19fb4de6 100644
--- a/Build/source/texk/web2c/ChangeLog
+++ b/Build/source/texk/web2c/ChangeLog
@@ -1,3 +1,8 @@
+2023-06-20 Andreas Scherer <https://ascherer.github.io>
+
+ * ctangleboot.cin,
+ * cwebboot.cin: Changes in cwebdir/comm-w2c.h.
+
2023-06-18 Karl Berry <karl@freefriends.org>
* am/cweb.am (dist_bin_SCRIPTS): new script cwebdir/ctwill-proofsort.
diff --git a/Build/source/texk/web2c/ctangleboot.cin b/Build/source/texk/web2c/ctangleboot.cin
index bf92f400178..eeed1da09a4 100644
--- a/Build/source/texk/web2c/ctangleboot.cin
+++ b/Build/source/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/Build/source/texk/web2c/cwebboot.cin b/Build/source/texk/web2c/cwebboot.cin
index 679cd46640c..c6b426ba47d 100644
--- a/Build/source/texk/web2c/cwebboot.cin
+++ b/Build/source/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/Build/source/texk/web2c/cwebdir/ChangeLog b/Build/source/texk/web2c/cwebdir/ChangeLog
index 9e1f65103c0..a58efbcd741 100644
--- a/Build/source/texk/web2c/cwebdir/ChangeLog
+++ b/Build/source/texk/web2c/cwebdir/ChangeLog
@@ -1,3 +1,10 @@
+2023-06-20 Andreas Scherer <https://ascherer.github.io>
+
+ * comm-w2c.h,
+ * ctwill-mini.ch,
+ * ctwill-w2c.ch,
+ * ctwill.bux: Use 'kpse_find_file' for '*.bux' files.
+
2023-06-18 Karl Berry <karl@freefriends.org>
* ctwill-proofsort: die if getopt fails;
diff --git a/Build/source/texk/web2c/cwebdir/comm-w2c.h b/Build/source/texk/web2c/cwebdir/comm-w2c.h
index 1046149331c..96197a49c9d 100644
--- a/Build/source/texk/web2c/cwebdir/comm-w2c.h
+++ b/Build/source/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/Build/source/texk/web2c/cwebdir/ctwill-mini.ch b/Build/source/texk/web2c/cwebdir/ctwill-mini.ch
index b9dc31516a6..55a7a7b29cf 100644
--- a/Build/source/texk/web2c/cwebdir/ctwill-mini.ch
+++ b/Build/source/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/Build/source/texk/web2c/cwebdir/ctwill-w2c.ch b/Build/source/texk/web2c/cwebdir/ctwill-w2c.ch
index 93ebf3f40a4..9df19c7b0a9 100644
--- a/Build/source/texk/web2c/cwebdir/ctwill-w2c.ch
+++ b/Build/source/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"))) ) {
+ @<Set up |cur_file_name| for opened |cur_file|@>@;
+ 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"))) ) {
+ @<Set up |cur_file_name| for opened |cur_file|@>@;
+ 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[];
@ @<Set init...@>=
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 files@>=
+#include <kpathsea/kpathsea.h> /* include every \Kpathsea/ header;
+ for |@!kpse_find_file| */
+
+@ @<Set up |cur_file_name|...@>=
+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/Build/source/texk/web2c/cwebdir/ctwill.bux b/Build/source/texk/web2c/cwebdir/ctwill.bux
index 9c0c43595a9..1203af59540 100644
--- a/Build/source/texk/web2c/cwebdir/ctwill.bux
+++ b/Build/source/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 "<kpathsea/types.h>" \zip@>
+@$kpse_find_file "<kpathsea/tex-file.h>" \zip@>
@$versionstring "<lib/lib.h>" \zip@>