texlive[64255] Build/source/texk: ptexenc,(u)ptex,mendex: initialize

commits+takuji at tug.org commits+takuji at tug.org
Thu Sep 1 15:49:56 CEST 2022


Revision: 64255
          http://tug.org/svn/texlive?view=revision&revision=64255
Author:   takuji
Date:     2022-09-01 15:49:56 +0200 (Thu, 01 Sep 2022)
Log Message:
-----------
ptexenc,(u)ptex,mendex: initialize inflie_enc_auto when firstly used (by H.Kitagawa)

Modified Paths:
--------------
    trunk/Build/source/texk/mendexk/ChangeLog
    trunk/Build/source/texk/mendexk/main.c
    trunk/Build/source/texk/ptexenc/ChangeLog
    trunk/Build/source/texk/ptexenc/ptexenc.c
    trunk/Build/source/texk/web2c/ptexdir/ChangeLog
    trunk/Build/source/texk/web2c/ptexdir/kanji.c
    trunk/Build/source/texk/web2c/uptexdir/ChangeLog
    trunk/Build/source/texk/web2c/uptexdir/kanji.c

Modified: trunk/Build/source/texk/mendexk/ChangeLog
===================================================================
--- trunk/Build/source/texk/mendexk/ChangeLog	2022-08-31 23:52:28 UTC (rev 64254)
+++ trunk/Build/source/texk/mendexk/ChangeLog	2022-09-01 13:49:56 UTC (rev 64255)
@@ -1,3 +1,11 @@
+2022-09-01 Hironori Kitagawa <h_kitagawa2001 at yahoo.co.jp>
+
+	* main.c:
+	Initialization of infile_enc_auto is moved to ptexenc.
+	Moved calls of KP_entry_filetype() (after checking options).
+	These changes prevent unwanted looking for texmf.cnf.
+	https://github.com/texjporg/tex-jp-build/pull/144
+
 2022-06-12  TANAKA Takuji  <ttk at t-lab.opal.ne.jp>
 
 	* main.c:

Modified: trunk/Build/source/texk/mendexk/main.c
===================================================================
--- trunk/Build/source/texk/mendexk/main.c	2022-08-31 23:52:28 UTC (rev 64254)
+++ trunk/Build/source/texk/mendexk/main.c	2022-09-01 13:49:56 UTC (rev 64255)
@@ -40,22 +40,6 @@
 			fprintf (stderr, "Ignoring bad kanji encoding \"%s\".\n", p);
 	}
 
-	p = kpse_var_value ("guess_input_kanji_encoding");
-	if (p) {
-		if (*p == '1' || *p == 'y' || *p == 't')
-			infile_enc_auto = 1;
-		free(p);
-	}
-
-	kp_ist.var_name = "INDEXSTYLE";
-	kp_ist.path = DEFAULT_INDEXSTYLES; /* default path. */
-	kp_ist.suffix = "ist";
-	KP_entry_filetype(&kp_ist);
-	kp_dict.var_name = "INDEXDICTIONARY";
-	kp_dict.path = DEFAULT_INDEXDICTS; /* default path */
-	kp_dict.suffix = "dict";
-	KP_entry_filetype(&kp_dict);
-
 /*   check options   */
 
 	for (i=1,j=k=0;i<argc && j<256;i++) {
@@ -230,6 +214,15 @@
 	}
 	idxcount=j+fsti;
 
+	kp_ist.var_name = "INDEXSTYLE";
+	kp_ist.path = DEFAULT_INDEXSTYLES; /* default path. */
+	kp_ist.suffix = "ist";
+	KP_entry_filetype(&kp_ist);
+	kp_dict.var_name = "INDEXDICTIONARY";
+	kp_dict.path = DEFAULT_INDEXDICTS; /* default path */
+	kp_dict.suffix = "dict";
+	KP_entry_filetype(&kp_dict);
+
 /*   check option errors   */
 
 	if (idxcount==0) idxcount=fsti=1;

Modified: trunk/Build/source/texk/ptexenc/ChangeLog
===================================================================
--- trunk/Build/source/texk/ptexenc/ChangeLog	2022-08-31 23:52:28 UTC (rev 64254)
+++ trunk/Build/source/texk/ptexenc/ChangeLog	2022-09-01 13:49:56 UTC (rev 64255)
@@ -1,3 +1,9 @@
+2022-09-01  Hironori Kitagawa  <h_kitagawa2001 at yahoo.co.jp>
+
+	* ptexenc.c: Initialize infile_enc_auto only when this variable
+	is first used (input_line2).
+	https://github.com/texjporg/tex-jp-build/pull/144
+
 2022-06-12  TANAKA Takuji  <ttk at t-lab.opal.ne.jp>
 
 	* ptexenc.c, unicode.c, ptexenc/ptexenc.h, ptexenc/unicode.h:

Modified: trunk/Build/source/texk/ptexenc/ptexenc.c
===================================================================
--- trunk/Build/source/texk/ptexenc/ptexenc.c	2022-08-31 23:52:28 UTC (rev 64254)
+++ trunk/Build/source/texk/ptexenc/ptexenc.c	2022-09-01 13:49:56 UTC (rev 64255)
@@ -42,7 +42,8 @@
 #if defined(WIN32)
 FILE *Poptr;
 #endif
-int infile_enc_auto = 0;
+int infile_enc_auto = 2;
+/* 0: guess disabled, 1: guess enabled, 2: unspecified */
 
 static int     file_enc = ENC_UNKNOWN;
 static int internal_enc = ENC_UNKNOWN;
@@ -990,6 +991,19 @@
     return enc;
 }
 
+void ptenc_set_infile_enc_auto(void)
+{
+   char *p;
+   if (infile_enc_auto == 2) {
+     p = kpse_var_value ("guess_input_kanji_encoding");
+     if (p) {
+       if (*p == '1' || *p == 'y' || *p == 't')  infile_enc_auto = 1;
+       free(p);
+     }
+   }
+   if (infile_enc_auto == 2) infile_enc_auto = 0;
+}
+
 /* input line with encoding conversion */
 long input_line2(FILE *fp, unsigned char *buff, unsigned char *buff2,
                  long pos, const long buffsize, int *lastchar)
@@ -1009,7 +1023,9 @@
             fprintf(stderr, "Detect UTF-8 with BOM #%d\n", fd);
 #endif /* DEBUG */
         }
-        else if (infile_enc_auto && fd != fileno(stdin)) {
+        else {
+          if (infile_enc_auto == 2) ptenc_set_infile_enc_auto();
+          if (infile_enc_auto && fd != fileno(stdin)) {
             char *enc;
             getc4(fp);
             getc4(fp);
@@ -1024,8 +1040,9 @@
                 infile_enc[fd] = get_file_enc();
             }
             if (enc) free(enc);
+          }
+          else infile_enc[fd] = get_file_enc();
         }
-        else infile_enc[fd] = get_file_enc();
     }
 
     while (last < buffsize-30 && (i=getc4(fp)) != EOF && i!='\n' && i!='\r') {

Modified: trunk/Build/source/texk/web2c/ptexdir/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/ptexdir/ChangeLog	2022-08-31 23:52:28 UTC (rev 64254)
+++ trunk/Build/source/texk/web2c/ptexdir/ChangeLog	2022-09-01 13:49:56 UTC (rev 64255)
@@ -1,3 +1,9 @@
+2022-09-01  Hironori Kitagawa  <h_kitagawa2001 at yahoo.co.jp>
+
+	* kanji.c: Initialization of infile_enc_auto is moved to ptexenc.
+	This change prevents unwanted looking for texmf.cnf.
+	https://github.com/texjporg/tex-jp-build/pull/144
+
 2022-06-12  TANAKA Takuji  <ttk at t-lab.opal.ne.jp>
 
 	* kanji.[ch], pbibtex.ch:

Modified: trunk/Build/source/texk/web2c/ptexdir/kanji.c
===================================================================
--- trunk/Build/source/texk/web2c/ptexdir/kanji.c	2022-08-31 23:52:28 UTC (rev 64254)
+++ trunk/Build/source/texk/web2c/ptexdir/kanji.c	2022-09-01 13:49:56 UTC (rev 64255)
@@ -95,11 +95,4 @@
         if (!set_enc_string (p, NULL))
             fprintf (stderr, "Ignoring bad kanji encoding \"%s\".\n", p);
     }
-
-    p = kpse_var_value ("guess_input_kanji_encoding");
-    if (p) {
-        if (*p == '1' || *p == 'y' || *p == 't')
-            infile_enc_auto = 1;
-        free(p);
-    }
 }

Modified: trunk/Build/source/texk/web2c/uptexdir/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/uptexdir/ChangeLog	2022-08-31 23:52:28 UTC (rev 64254)
+++ trunk/Build/source/texk/web2c/uptexdir/ChangeLog	2022-09-01 13:49:56 UTC (rev 64255)
@@ -1,3 +1,9 @@
+2022-09-01  Hironori Kitagawa  <h_kitagawa2001 at yahoo.co.jp>
+
+	* kanji.c: Initialization of infile_enc_auto is moved to ptexenc.
+	This change prevents unwanted looking for texmf.cnf.
+	https://github.com/texjporg/tex-jp-build/pull/144
+
 2022-07-23  TANAKA Takuji  <ttk at t-lab.opal.ne.jp>
 
 	* uptex-m.ch, upbibtex.ch, updvitype.ch, uppltotf.ch, uptftopl.ch,

Modified: trunk/Build/source/texk/web2c/uptexdir/kanji.c
===================================================================
--- trunk/Build/source/texk/web2c/uptexdir/kanji.c	2022-08-31 23:52:28 UTC (rev 64254)
+++ trunk/Build/source/texk/web2c/uptexdir/kanji.c	2022-09-01 13:49:56 UTC (rev 64255)
@@ -519,13 +519,6 @@
         if (!set_enc_string (p, NULL))
             fprintf (stderr, "Ignoring bad kanji encoding \"%s\".\n", p);
     }
-
-    p = kpse_var_value ("guess_input_kanji_encoding");
-    if (p) {
-        if (*p == '1' || *p == 'y' || *p == 't')
-            infile_enc_auto = 1;
-        free(p);
-    }
 }
 
 void init_default_kanji_select(void)



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