texlive[74552] Build/source/texk/web2c: [TANGLE] Force case changes

commits+ascherer at tug.org commits+ascherer at tug.org
Mon Mar 10 17:32:27 CET 2025


Revision: 74552
          https://tug.org/svn/texlive?view=revision&revision=74552
Author:   ascherer
Date:     2025-03-10 17:32:27 +0100 (Mon, 10 Mar 2025)
Log Message:
-----------
[TANGLE] Force case changes for letters only.

In message <https://tug.org/pipermail/tex-k/2025-March/004161.html>,
Benjamin Gray reported incorrect behavior of TANGLE with command-line
option '--lowercase'.

His suggested patch is extended to other places in TANGLE.CH (only;
plain TANGLE.WEB does not have such an option) to apply case changes
(both uppercase and lowercase) to ASCII letters only.

Modified Paths:
--------------
    trunk/Build/source/texk/web2c/ChangeLog
    trunk/Build/source/texk/web2c/tangle.ch
    trunk/Build/source/texk/web2c/tangleboot.pin

Modified: trunk/Build/source/texk/web2c/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/ChangeLog	2025-03-10 10:33:14 UTC (rev 74551)
+++ trunk/Build/source/texk/web2c/ChangeLog	2025-03-10 16:32:27 UTC (rev 74552)
@@ -1,3 +1,8 @@
+2025-03-10  Andreas Scherer  <https://ascherer.github.io>
+
+	* texk/web2c/tangle.ch,
+	* texk/web2c/tangleboot.pin: Change case for letters only.
+
 2025-02-01  Karl Berry  <karl at freefriends.org>
 
 	* tex.ch (24.336): comment out this patch for interactive deletion

Modified: trunk/Build/source/texk/web2c/tangle.ch
===================================================================
--- trunk/Build/source/texk/web2c/tangle.ch	2025-03-10 10:33:14 UTC (rev 74551)
+++ trunk/Build/source/texk/web2c/tangle.ch	2025-03-10 16:32:27 UTC (rev 74552)
@@ -295,7 +295,8 @@
     begin if buffer[i]>="a" then chopped_id[s]:=buffer[i]-@'40
 @y
   begin if (buffer[i]<>"_") or (allow_underlines and not strict_mode) then
-    begin if (strict_mode or force_uppercase) and (buffer[i]>="a") then
+    begin if (strict_mode or force_uppercase)
+           and (buffer[i]>="a") and (buffer[i]<="z") then
       chopped_id[s]:=buffer[i]-@'40
     else if (not strict_mode and force_lowercase)
            and (buffer[i]>="A") and (buffer[i]<="Z") then
@@ -313,7 +314,9 @@
     begin if c>="a" then c:=c-@'40; {merge lowercase with uppercase}
 @y
   if c<>"_" or (allow_underlines and not strict_mode) then
-    begin if (strict_mode or force_uppercase) and (c>="a") then c:=c-@'40
+    begin if (strict_mode or force_uppercase)
+           and (c>="a") and (c<="z") then
+      c:=c-@'40
     else if (not strict_mode and force_lowercase)
            and (c>="A") and (c<="Z") then
       c:=c+@'40;
@@ -482,9 +485,11 @@
 identifier: begin k:=0; j:=byte_start[cur_val]; w:=cur_val mod ww;
   while (k<max_id_length)and(j<byte_start[cur_val+ww]) do
     begin incr(k); out_contrib[k]:=byte_mem[w,j]; incr(j);
-    if force_uppercase and (out_contrib[k]>="a") then
+    if force_uppercase
+          and (out_contrib[k]>="a") and (out_contrib[k]<="z") then
       out_contrib[k]:=out_contrib[k]-@'40
-    else if force_lowercase and (out_contrib[k]<="Z") then
+    else if force_lowercase
+          and (out_contrib[k]>="A") and (out_contrib[k]<="Z") then
       out_contrib[k]:=out_contrib[k]+@'40
     else if not allow_underlines and (out_contrib[k]="_") then decr(k);
     end;

Modified: trunk/Build/source/texk/web2c/tangleboot.pin
===================================================================
--- trunk/Build/source/texk/web2c/tangleboot.pin	2025-03-10 10:33:14 UTC (rev 74551)
+++ trunk/Build/source/texk/web2c/tangleboot.pin	2025-03-10 16:32:27 UTC (rev 74552)
@@ -197,11 +197,11 @@
 idfirst;s:=0;h:=0;
 while(i<idloc)and(s<unambiglength)do begin if(buffer[i]<>95)or(
 allowunderlines and not strictmode)then begin if(strictmode or
-forceuppercase)and(buffer[i]>=97)then choppedid[s]:=buffer[i]-32 else if
-(not strictmode and forcelowercase)and(buffer[i]>=65)and(buffer[i]<=90)
-then choppedid[s]:=buffer[i]+32 else choppedid[s]:=buffer[i];
-h:=(h+h+choppedid[s])mod hashsize;s:=s+1;end;i:=i+1;end;choppedid[s]:=0;
-end{:58};
+forceuppercase)and(buffer[i]>=97)and(buffer[i]<=122)then choppedid[s]:=
+buffer[i]-32 else if(not strictmode and forcelowercase)and(buffer[i]>=65
+)and(buffer[i]<=90)then choppedid[s]:=buffer[i]+32 else choppedid[s]:=
+buffer[i];h:=(h+h+choppedid[s])mod hashsize;s:=s+1;end;i:=i+1;end;
+choppedid[s]:=0;end{:58};
 if p<>nameptr then{59:}begin if ilk[p]=0 then begin if t=1 then begin
 writeln(stdout);write(stdout,'! This identifier has already appeared');
 error;end;{60:}q:=chophash[h];
@@ -214,8 +214,8 @@
 w:=q mod 3;
 while(k<bytestart[q+3])and(s<unambiglength)do begin c:=bytemem[w,k];
 if c<>95 or(allowunderlines and not strictmode)then begin if(strictmode
-or forceuppercase)and(c>=97)then c:=c-32 else if(not strictmode and
-forcelowercase)and(c>=65)and(c<=90)then c:=c+32;
+or forceuppercase)and(c>=97)and(c<=122)then c:=c-32 else if(not
+strictmode and forcelowercase)and(c>=65)and(c<=90)then c:=c+32;
 if choppedid[s]<>c then goto 32;s:=s+1;end;k:=k+1;end;
 if(k=bytestart[q+3])and(choppedid[s]<>0)then goto 32;
 begin writeln(stdout);write(stdout,'! Identifier conflict with ');end;
@@ -469,11 +469,11 @@
 130:begin k:=0;j:=bytestart[curval];w:=curval mod 3;
 while(k<maxidlength)and(j<bytestart[curval+3])do begin k:=k+1;
 outcontrib[k]:=bytemem[w,j];j:=j+1;
-if forceuppercase and(outcontrib[k]>=97)then outcontrib[k]:=outcontrib[k
-]-32 else if forcelowercase and(outcontrib[k]<=90)then outcontrib[k]:=
-outcontrib[k]+32 else if not allowunderlines and(outcontrib[k]=95)then k
-:=k-1;end;sendout(2,k);end;
-{:116}{119:}48,49,50,51,52,53,54,55,56,57:begin n:=0;
+if forceuppercase and(outcontrib[k]>=97)and(outcontrib[k]<=122)then
+outcontrib[k]:=outcontrib[k]-32 else if forcelowercase and(outcontrib[k]
+>=65)and(outcontrib[k]<=90)then outcontrib[k]:=outcontrib[k]+32 else if
+not allowunderlines and(outcontrib[k]=95)then k:=k-1;end;sendout(2,k);
+end;{:116}{119:}48,49,50,51,52,53,54,55,56,57:begin n:=0;
 repeat curchar:=curchar-48;if n>=214748364 then begin writeln(stdout);
 write(stdout,'! Constant too big');error;end else n:=10*n+curchar;
 curchar:=getoutput;until(curchar>57)or(curchar<48);sendval(n);k:=0;



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