texlive[67416] Build/source/texk/web2c: [CWEB] Use 'kpse_find_file'

commits+ascherer at tug.org commits+ascherer at tug.org
Tue Jun 20 19:40:16 CEST 2023


Revision: 67416
          http://tug.org/svn/texlive?view=revision&revision=67416
Author:   ascherer
Date:     2023-06-20 19:40:15 +0200 (Tue, 20 Jun 2023)
Log Message:
-----------
[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.

Modified Paths:
--------------
    trunk/Build/source/texk/web2c/ChangeLog
    trunk/Build/source/texk/web2c/ctangleboot.cin
    trunk/Build/source/texk/web2c/cwebboot.cin
    trunk/Build/source/texk/web2c/cwebdir/ChangeLog
    trunk/Build/source/texk/web2c/cwebdir/comm-w2c.h
    trunk/Build/source/texk/web2c/cwebdir/ctwill-mini.ch
    trunk/Build/source/texk/web2c/cwebdir/ctwill-w2c.ch
    trunk/Build/source/texk/web2c/cwebdir/ctwill.bux

Modified: trunk/Build/source/texk/web2c/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/ChangeLog	2023-06-19 23:42:55 UTC (rev 67415)
+++ trunk/Build/source/texk/web2c/ChangeLog	2023-06-20 17:40:15 UTC (rev 67416)
@@ -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 at freefriends.org>
 
 	* am/cweb.am (dist_bin_SCRIPTS): new script cwebdir/ctwill-proofsort.

Modified: trunk/Build/source/texk/web2c/ctangleboot.cin
===================================================================
--- trunk/Build/source/texk/web2c/ctangleboot.cin	2023-06-19 23:42:55 UTC (rev 67415)
+++ trunk/Build/source/texk/web2c/ctangleboot.cin	2023-06-20 17:40:15 UTC (rev 67416)
@@ -208,6 +208,7 @@
 
 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 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 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 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 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,7 +388,7 @@
 #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);
@@ -394,7 +395,7 @@
 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 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 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);

Modified: trunk/Build/source/texk/web2c/cwebboot.cin
===================================================================
--- trunk/Build/source/texk/web2c/cwebboot.cin	2023-06-19 23:42:55 UTC (rev 67415)
+++ trunk/Build/source/texk/web2c/cwebboot.cin	2023-06-20 17:40:15 UTC (rev 67416)
@@ -214,6 +214,7 @@
 
 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 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 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 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 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,7 +421,7 @@
 #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);
@@ -427,7 +428,7 @@
 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 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 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);

Modified: trunk/Build/source/texk/web2c/cwebdir/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/cwebdir/ChangeLog	2023-06-19 23:42:55 UTC (rev 67415)
+++ trunk/Build/source/texk/web2c/cwebdir/ChangeLog	2023-06-20 17:40:15 UTC (rev 67416)
@@ -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 at freefriends.org>
 
 	* ctwill-proofsort: die if getopt fails;

Modified: trunk/Build/source/texk/web2c/cwebdir/comm-w2c.h
===================================================================
--- trunk/Build/source/texk/web2c/cwebdir/comm-w2c.h	2023-06-19 23:42:55 UTC (rev 67415)
+++ trunk/Build/source/texk/web2c/cwebdir/comm-w2c.h	2023-06-20 17:40:15 UTC (rev 67416)
@@ -134,6 +134,7 @@
   /* 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 */

Modified: trunk/Build/source/texk/web2c/cwebdir/ctwill-mini.ch
===================================================================
--- trunk/Build/source/texk/web2c/cwebdir/ctwill-mini.ch	2023-06-19 23:42:55 UTC (rev 67415)
+++ trunk/Build/source/texk/web2c/cwebdir/ctwill-mini.ch	2023-06-20 17:40:15 UTC (rev 67416)
@@ -2161,6 +2161,15 @@
 
 Section 328.
 
+ at x l.116 of CTWILL-TEXLIVE.CH
+ at d kpse_find_cweb(name) kpse_find_file(name,kpse_cweb_format,true)
+ at y
+ at d kpse_find_cweb(name) kpse_find_file(name,kpse_cweb_format,true)
+ at -name@>
+ at z
+
+Section 330.
+
 @x
 @** Index.
 If you have read and understood the code for Phase III above, you know what

Modified: trunk/Build/source/texk/web2c/cwebdir/ctwill-w2c.ch
===================================================================
--- trunk/Build/source/texk/web2c/cwebdir/ctwill-w2c.ch	2023-06-19 23:42:55 UTC (rev 67415)
+++ trunk/Build/source/texk/web2c/cwebdir/ctwill-w2c.ch	2023-06-20 17:40:15 UTC (rev 67416)
@@ -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 @@
 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 @@
 @ @<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}
+ at .CWEBINPUTS@>
+
+ at s const_string int
+ at s string int
+
+ at 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
 

Modified: trunk/Build/source/texk/web2c/cwebdir/ctwill.bux
===================================================================
--- trunk/Build/source/texk/web2c/cwebdir/ctwill.bux	2023-06-19 23:42:55 UTC (rev 67415)
+++ trunk/Build/source/texk/web2c/cwebdir/ctwill.bux	2023-06-20 17:40:15 UTC (rev 67416)
@@ -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@>



More information about the tex-live-commits mailing list.