texlive[71530] Build/source/texk/web2c: [WEB] Output '@x' with

commits+ascherer at tug.org commits+ascherer at tug.org
Sat Jun 15 11:19:04 CEST 2024


Revision: 71530
          https://tug.org/svn/texlive?view=revision&revision=71530
Author:   ascherer
Date:     2024-06-15 11:19:04 +0200 (Sat, 15 Jun 2024)
Log Message:
-----------
[WEB] Output '@x' with optional information.

E.g., 'fix-changefile-lines -hlp dvicopy.{wen,ch}' prints only
'@x [section] text' lines. ('[137/138]' was replaced with '[137]'.)

Modified Paths:
--------------
    trunk/Build/source/texk/web2c/ChangeLog
    trunk/Build/source/texk/web2c/dvicopy.ch
    trunk/Build/source/texk/web2c/tests/fix-changefile-lines.py

Modified: trunk/Build/source/texk/web2c/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/ChangeLog	2024-06-14 23:41:57 UTC (rev 71529)
+++ trunk/Build/source/texk/web2c/ChangeLog	2024-06-15 09:19:04 UTC (rev 71530)
@@ -1,3 +1,8 @@
+2024-06-15  Andreas Scherer  <https://ascherer.github.io>
+
+	* tests/fix-changefile-lines.py,
+	* dvicopy.ch: Output '@x' with optional information.
+
 2024-06-05  Andreas Scherer  <https://ascherer.github.io>
 
 	* tests/fix-changefile-lines.py,

Modified: trunk/Build/source/texk/web2c/dvicopy.ch
===================================================================
--- trunk/Build/source/texk/web2c/dvicopy.ch	2024-06-14 23:41:57 UTC (rev 71529)
+++ trunk/Build/source/texk/web2c/dvicopy.ch	2024-06-15 09:19:04 UTC (rev 71530)
@@ -36,7 +36,7 @@
 @y
 calls the `|jump_out|' procedure.
 @z
- at x
+ at x [3]
 label final_end;
 @y
 @z
@@ -85,7 +85,7 @@
 % [7] Rename the integer types, as they collide with names used by C99.
 % Rather than change the code all over the place, we use macros to do
 % the renaming.  This could also be done at C preprocessor level.
- at x
+ at x [7]
 @d int_32 == integer {signed 32~bit integers}
 @y
 @d int_32 == integer {signed 32~bit integers}
@@ -103,7 +103,7 @@
 
 % [11] Redirect output, so it can go to either stdout or stderr,
 % depending on where the output dvi file is going.
- at x
+ at x [11]
 @d print(#)==write(output,#)
 @d print_ln(#)==write_ln(output,#)
 @d new_line==write_ln(output) {start new line}
@@ -122,7 +122,7 @@
 % [15] The text_char type is used as an array index into xord.  The
 % default type `char' produces signed integers, which are bad array
 % indices in C.
- at x
+ at x [15]
 @d text_char == char {the data type of characters in text files}
 @d first_text_char=0 {ordinal number of the smallest element of |text_char|}
 @d last_text_char=127 {ordinal number of the largest element of |text_char|}
@@ -143,7 +143,7 @@
 @y
 so a procedure called |jump_out| has been introduced.
 @z
- at x
+ at x [23]
 @d abort(#)==begin print_ln(' ',#,'.'); jump_out;
     end
 
@@ -175,7 +175,7 @@
 @y
 says |confusion|(indication of where we are).
 @z
- at x
+ at x [24]
 procedure confusion(@!p:pckt_pointer);
 @y
 noreturn procedure confusion(@!p:pckt_pointer);
@@ -229,12 +229,12 @@
 
 % [67] No conversion of filenames in lower case, and initialize and
 % terminate for C strings.  Eliminate now unused variable.
- at x
+ at x [67]
 @!c:char; {a character to be appended to |cur_name|}
 @y
 @z
 
- at x
+ at x [67]
 cur_loc:=pckt_start[n]; cur_limit:=pckt_start[n+1];
 @y
 cur_name := xmalloc_array (char, pckt_length (n) + pckt_length (e));
@@ -241,12 +241,12 @@
 cur_loc:=pckt_start[n]; cur_limit:=pckt_start[n+1];
 @z
 
- at x
+ at x [67]
   if (b>="a")and(b<="z") then Decr(b)(("a"-"A")); {convert to upper case}
 @y
 @z
 
- at x
+ at x [67]
 cur_loc:=pckt_start[e]; cur_limit:=pckt_start[e+1];
 while cur_loc<cur_limit do
   begin pckt_extract(b); append_res_to_name(xchr[b]);
@@ -380,7 +380,7 @@
 id3(".")("v")("f")(vf_ext); {file name extension for \.{VF} files}
 @z
 
- at x [137/138] Set default directory name
+ at x [137] Set default directory name
 @ If no font directory has been specified, \.{\title} is supposed to use
 the default \.{VF} directory, which is a system-dependent place where
 the \.{VF} files for standard fonts are kept.
@@ -488,7 +488,7 @@
 dialog; {get options}
 @y
 @z
- at x
+ at x [241]
 final_end:end.
 @y
 end.

Modified: trunk/Build/source/texk/web2c/tests/fix-changefile-lines.py
===================================================================
--- trunk/Build/source/texk/web2c/tests/fix-changefile-lines.py	2024-06-14 23:41:57 UTC (rev 71529)
+++ trunk/Build/source/texk/web2c/tests/fix-changefile-lines.py	2024-06-15 09:19:04 UTC (rev 71530)
@@ -7,22 +7,49 @@
 potentially corrected part, section and line numbers.
 Written by Tyge Tiessen, 2024. Public domain.
 """
+import getopt
 import re
 import sys
 
 USAGE = f"{sys.argv[0]} <web file> <change file>"
 
+# Optional elements of "@x [{part}.{section}] l.{line} {-(hyphen)} {text}
+part_b, section_b, line_b, hyphen_b, text_b = True, True, True, True, True
 
+
 def main():
-    if len(sys.argv) != 3:
+    try:
+        opts, args = getopt.getopt(sys.argv[1:], "pslht",
+            ["parts", "sections", "lines", "hyphens", "texts"])
+    except getopt.GetoptErr as err:
         print(USAGE)
         sys.exit(1)
 
+    global part_b, section_b, line_b, hyphen_b, text_b
+
+    for opt, _ in opts:
+        if opt in ("-p", "--parts"):
+            part_b = False
+        elif opt in ("-s", "--sections"):
+            section_b = False
+        elif opt in ("-l", "--lines"):
+            line_b = False
+        elif opt in ("-h", "--hyphens"):
+            hyphen_b = False
+        elif opt in ("-t", "--texts"):
+            text_b = False
+        else:
+            assert False, f"Unhandled option {opt}"
+
+    if len(args) != 2:
+        print(USAGE)
+        sys.exit(1)
+
     # Read WEB file
-    web_reader = WebReader(sys.argv[1])
+    web_reader = WebReader(args[0])
 
     # Read change file
-    ch_reader = ChangeReader(sys.argv[2])
+    ch_reader = ChangeReader(args[1])
 
     # Run through the two files in parallel
     ch_reader.traverse(web_reader)
@@ -189,11 +216,24 @@
                     if re.match(pattern, text):
                         text = re.sub(pattern, "", text, 1).strip()
 
-            # Create line with standard tag.
-            new_line = f"@x [{part}.{section}] l.{line_number}"
+            # Create line with standard tag and optional information.
+            new_line = f"@x"
+            if part_b or section_b:
+                new_line += f" ["
+                if part_b:
+                    new_line += f"{part}"
+                if part_b and section_b:
+                    new_line += f"."
+                if section_b:
+                    new_line += f"{section}"
+                new_line += f"]"
+            if line_b:
+                new_line += f" l.{line_number}"
 
-            if text:
-                new_line += f" - {text}"
+            if text_b and text:
+                if hyphen_b:
+                    new_line += f" -"
+                new_line += f" {text}"
 
             ch_line = self._lines[self._chunk_start]
             if new_line[:10] != ch_line[:10]:



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