texlive[56330] trunk: dviasm (12sep20)

commits+karl at tug.org commits+karl at tug.org
Sat Sep 12 23:05:47 CEST 2020


Revision: 56330
          http://tug.org/svn/texlive?view=revision&revision=56330
Author:   karl
Date:     2020-09-12 23:05:47 +0200 (Sat, 12 Sep 2020)
Log Message:
-----------
dviasm (12sep20)

Modified Paths:
--------------
    trunk/Build/source/texk/texlive/linked_scripts/dviasm/dviasm.py
    trunk/Master/texmf-dist/doc/latex/dviasm/README
    trunk/Master/texmf-dist/scripts/dviasm/dviasm.py

Modified: trunk/Build/source/texk/texlive/linked_scripts/dviasm/dviasm.py
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/dviasm/dviasm.py	2020-09-12 04:05:50 UTC (rev 56329)
+++ trunk/Build/source/texk/texlive/linked_scripts/dviasm/dviasm.py	2020-09-12 21:05:47 UTC (rev 56330)
@@ -145,14 +145,7 @@
   return (0, PutByte(q))
 
 def PutSigned(q):
-  if 0 <= q < 0x800000:               return PutUnsigned(q)
   if q < -0x800000 or q >= 0x800000:  return (3, PutSignedQuad(q))
-  if q < -0x8000:     q += 0x1000000; return (2, Put3Bytes(q))
-  if q < -0x80:       q += 0x10000;   return (1, Put2Bytes(q))
-  return (0, PutByte(q))
-
-def PutSignedLength(q):
-  if q < -0x800000 or q >= 0x800000:  return (3, PutSignedQuad(q))
   if q >= 0x8000:                     return (2, Put3Bytes(q))
   if q < -0x8000:     q += 0x1000000; return (2, Put3Bytes(q))
   if q >= 0x80:                       return (1, Put2Bytes(q))
@@ -239,7 +232,7 @@
   s = ''
   if is_subfont:
     for o in t:
-      s += chr((subfont_idx << 8) + o).encode('utf8')
+      s += chr((subfont_idx << 8) + o)
   else: # not the case of subfont
     for o in t:
       if o == 92:         s += '\\\\'
@@ -250,16 +243,6 @@
       else:               s += chr(o)
   return "'%s'" % s
 
-def PutStrSJIS(t): # used in Dump()
-  s = ''
-  for o in t:
-    if o == 92:         s += '\\\\'
-    elif 32 <= o < 127: s += chr(o)
-    elif o < 128:       s += ('\\x%02x' % o)
-    else:
-      s += DecodeISO2022JP(o).encode('sjis')
-  return "'%s'" % s
-
 def IsFontChanged(f, z):
   global cur_font, cur_ssize, subfont_idx, is_subfont
   for n in subfont_list:
@@ -633,13 +616,13 @@
         if cmd[0] == SET1:
           for o in cmd[1]:
             if o < 128: s.append(bytes.fromhex('%02x' % (SET_CHAR_0 + o)))
-            else:       s.append(self.CmdPair([SET1, o]))
+            else:       s.append(self.CmdPairU([SET1, o]))
         elif cmd[0] in (SET_RULE, PUT_RULE):
           s.append(bytes.fromhex('%02x' % cmd[0]) + PutSignedQuad(cmd[1][0]) + PutSignedQuad(cmd[1][1]))
         elif cmd[0] == PUT1:
-          s.append(self.CmdPair([PUT1, cmd[1][0]]))
+          s.append(self.CmdPairU([PUT1, cmd[1][0]]))
         elif cmd[0] in (RIGHT1, DOWN1):
-          s.append(self.CmdPairLength(cmd))
+          s.append(self.CmdPair(cmd))
         elif cmd[0] in (W0, X0, Y0, Z0):
           s.append(bytes.fromhex('%02x' % cmd[0]))
         elif cmd[0] == PUSH:
@@ -650,16 +633,16 @@
           s.append(bytes.fromhex('%02x' % POP))
           w, x, y, z = stack.pop()
         elif cmd[0] == W1:
-          w = cmd[1]; s.append(self.CmdPairLength(cmd))
+          w = cmd[1]; s.append(self.CmdPair(cmd))
         elif cmd[0] == X1:
-          x = cmd[1]; s.append(self.CmdPairLength(cmd))
+          x = cmd[1]; s.append(self.CmdPair(cmd))
         elif cmd[0] == Y1:
-          y = cmd[1]; s.append(self.CmdPairLength(cmd))
+          y = cmd[1]; s.append(self.CmdPair(cmd))
         elif cmd[0] == Z1:
-          z = cmd[1]; s.append(self.CmdPairLength(cmd))
+          z = cmd[1]; s.append(self.CmdPair(cmd))
         elif cmd[0] == FNT1:
           if cmd[1] < 64: s.append(bytes.fromhex('%02x' % (FNT_NUM_0 + cmd[1])))
-          else:           s.append(self.CmdPair(cmd))
+          else:           s.append(self.CmdPairU(cmd))
         elif cmd[0] == XXX1:
           cmd1 = cmd[1].encode('utf8')
           l = len(cmd[1])
@@ -722,19 +705,19 @@
         s.append(self.font_def[e]['name'].encode('utf8'))
     fp.write(b''.join(s))
 
+  def CmdPairU(self, cmd):
+    l, q = PutUnsigned(cmd[1])
+    return bytes.fromhex('%02x' % (cmd[0] + l)) + q
+
   def CmdPair(self, cmd):
     l, q = PutSigned(cmd[1])
     return bytes.fromhex('%02x' % (cmd[0] + l)) + q
 
-  def CmdPairLength(self, cmd):
-    l, q = PutSignedLength(cmd[1])
-    return bytes.fromhex('%02x' % (cmd[0] + l)) + q
-
   ##########################################################
   # Parse: Text -> Internal Format
   ##########################################################
   def Parse(self, fn, encoding=''):
-    fp = open(fn, 'r')
+    fp = open(fn, 'r', encoding=encoding)
     s = fp.read()
     fp.close()
     self.ParseFromString(s, encoding=encoding)
@@ -911,7 +894,7 @@
   # Dump: Internal Format -> Text
   ##########################################################
   def Dump(self, fn, tabsize=2, encoding=''):
-    fp = open(fn, 'w')
+    fp = open(fn, 'w', encoding=encoding)
     self.DumpToFile(fp, tabsize=tabsize, encoding=encoding)
     fp.close()
 
@@ -919,7 +902,6 @@
     global PutStr
     if   encoding == 'ascii':  PutStr = PutStrASCII
     elif encoding == 'latin1': PutStr = PutStrLatin1
-    elif encoding == 'sjis':   PutStr = PutStrSJIS
     else:                      PutStr = PutStrUTF8
     # DumpPreamble
     fp.write("[preamble]\n")
@@ -937,10 +919,10 @@
     # DumpFontDefinitions
     fp.write("\n[font definitions]\n")
     for e in sorted(self.font_def.keys()):
-      fp.write("fntdef: %s" % self.font_def[e]['name'])
+      fp.write("fntdef: %s " % self.font_def[e]['name'])
       if self.font_def[e]['design_size'] != self.font_def[e]['scaled_size']:
-        fp.write(" (%s) " % self.byconv(self.font_def[e]['design_size']))
-      fp.write(" at %s\n" % self.byconv(self.font_def[e]['scaled_size']))
+        fp.write("(%s) " % self.byconv(self.font_def[e]['design_size']))
+      fp.write("at %s\n" % self.byconv(self.font_def[e]['scaled_size']))
     # DumpPages
     for page in self.pages:
       fp.write("\n[page" + (" %d"*10 % tuple(page['count'])) + "]\n")
@@ -1108,7 +1090,6 @@
       f['slant'] = slant
       f['embolden'] = embolden
     else:
-      f['native'] = False
       f['name'] = n
 
     if q[:2] == "at": q = q[2:]
@@ -1166,7 +1147,7 @@
 Please report bugs to
   https://github.com/aminophen/dviasm"""
 
-  version = """This is %prog-20200905
+  version = """This is %prog-20200912
 
 Copyright (C) 2007-2008 by Jin-Hwan Cho <chofchof at ktug.or.kr>
 Copyright (C) 2011-2017 by Khaled Hosny <khaledhosny at eglug.org>
@@ -1208,12 +1189,12 @@
     parser.error("invalid unit name '%s'!" % options.unit)
   if options.tabsize < 0:
     parser.error("negative tabsize!")
-  if not options.encoding in ['ascii', 'latin1', 'utf8', 'sjis']:
+  if not options.encoding in ['ascii', 'latin1', 'utf8', 'sjis', 'eucjp']:
     parser.error("invalid encoding '%s'!" % options.encoding)
   if options.ptex:
     global is_ptex
     is_ptex = True
-    if not options.encoding in ['utf8', 'sjis']:
+    if not options.encoding in ['utf8', 'sjis', 'eucjp']:
       parser.error("invalid encoding '%s' for Japanese pTeX!" % options.encoding)
   if options.subfont:
     global subfont_list

Modified: trunk/Master/texmf-dist/doc/latex/dviasm/README
===================================================================
--- trunk/Master/texmf-dist/doc/latex/dviasm/README	2020-09-12 04:05:50 UTC (rev 56329)
+++ trunk/Master/texmf-dist/doc/latex/dviasm/README	2020-09-12 21:05:47 UTC (rev 56330)
@@ -3,7 +3,8 @@
 
 It consists of a single Python program, dviasm.py, in a human readable
 text format and it runs on any platform in which Python is installed.
-Licensed under GNU General Public License Version 3 or later.
+It is licensed under GNU General Public License Version 3 or later.
+Other support files (test cases etc.) are not copyrighted.
 
 All revisions of DVIasm can be downloaded at
 

Modified: trunk/Master/texmf-dist/scripts/dviasm/dviasm.py
===================================================================
--- trunk/Master/texmf-dist/scripts/dviasm/dviasm.py	2020-09-12 04:05:50 UTC (rev 56329)
+++ trunk/Master/texmf-dist/scripts/dviasm/dviasm.py	2020-09-12 21:05:47 UTC (rev 56330)
@@ -145,14 +145,7 @@
   return (0, PutByte(q))
 
 def PutSigned(q):
-  if 0 <= q < 0x800000:               return PutUnsigned(q)
   if q < -0x800000 or q >= 0x800000:  return (3, PutSignedQuad(q))
-  if q < -0x8000:     q += 0x1000000; return (2, Put3Bytes(q))
-  if q < -0x80:       q += 0x10000;   return (1, Put2Bytes(q))
-  return (0, PutByte(q))
-
-def PutSignedLength(q):
-  if q < -0x800000 or q >= 0x800000:  return (3, PutSignedQuad(q))
   if q >= 0x8000:                     return (2, Put3Bytes(q))
   if q < -0x8000:     q += 0x1000000; return (2, Put3Bytes(q))
   if q >= 0x80:                       return (1, Put2Bytes(q))
@@ -239,7 +232,7 @@
   s = ''
   if is_subfont:
     for o in t:
-      s += chr((subfont_idx << 8) + o).encode('utf8')
+      s += chr((subfont_idx << 8) + o)
   else: # not the case of subfont
     for o in t:
       if o == 92:         s += '\\\\'
@@ -250,16 +243,6 @@
       else:               s += chr(o)
   return "'%s'" % s
 
-def PutStrSJIS(t): # used in Dump()
-  s = ''
-  for o in t:
-    if o == 92:         s += '\\\\'
-    elif 32 <= o < 127: s += chr(o)
-    elif o < 128:       s += ('\\x%02x' % o)
-    else:
-      s += DecodeISO2022JP(o).encode('sjis')
-  return "'%s'" % s
-
 def IsFontChanged(f, z):
   global cur_font, cur_ssize, subfont_idx, is_subfont
   for n in subfont_list:
@@ -633,13 +616,13 @@
         if cmd[0] == SET1:
           for o in cmd[1]:
             if o < 128: s.append(bytes.fromhex('%02x' % (SET_CHAR_0 + o)))
-            else:       s.append(self.CmdPair([SET1, o]))
+            else:       s.append(self.CmdPairU([SET1, o]))
         elif cmd[0] in (SET_RULE, PUT_RULE):
           s.append(bytes.fromhex('%02x' % cmd[0]) + PutSignedQuad(cmd[1][0]) + PutSignedQuad(cmd[1][1]))
         elif cmd[0] == PUT1:
-          s.append(self.CmdPair([PUT1, cmd[1][0]]))
+          s.append(self.CmdPairU([PUT1, cmd[1][0]]))
         elif cmd[0] in (RIGHT1, DOWN1):
-          s.append(self.CmdPairLength(cmd))
+          s.append(self.CmdPair(cmd))
         elif cmd[0] in (W0, X0, Y0, Z0):
           s.append(bytes.fromhex('%02x' % cmd[0]))
         elif cmd[0] == PUSH:
@@ -650,16 +633,16 @@
           s.append(bytes.fromhex('%02x' % POP))
           w, x, y, z = stack.pop()
         elif cmd[0] == W1:
-          w = cmd[1]; s.append(self.CmdPairLength(cmd))
+          w = cmd[1]; s.append(self.CmdPair(cmd))
         elif cmd[0] == X1:
-          x = cmd[1]; s.append(self.CmdPairLength(cmd))
+          x = cmd[1]; s.append(self.CmdPair(cmd))
         elif cmd[0] == Y1:
-          y = cmd[1]; s.append(self.CmdPairLength(cmd))
+          y = cmd[1]; s.append(self.CmdPair(cmd))
         elif cmd[0] == Z1:
-          z = cmd[1]; s.append(self.CmdPairLength(cmd))
+          z = cmd[1]; s.append(self.CmdPair(cmd))
         elif cmd[0] == FNT1:
           if cmd[1] < 64: s.append(bytes.fromhex('%02x' % (FNT_NUM_0 + cmd[1])))
-          else:           s.append(self.CmdPair(cmd))
+          else:           s.append(self.CmdPairU(cmd))
         elif cmd[0] == XXX1:
           cmd1 = cmd[1].encode('utf8')
           l = len(cmd[1])
@@ -722,19 +705,19 @@
         s.append(self.font_def[e]['name'].encode('utf8'))
     fp.write(b''.join(s))
 
+  def CmdPairU(self, cmd):
+    l, q = PutUnsigned(cmd[1])
+    return bytes.fromhex('%02x' % (cmd[0] + l)) + q
+
   def CmdPair(self, cmd):
     l, q = PutSigned(cmd[1])
     return bytes.fromhex('%02x' % (cmd[0] + l)) + q
 
-  def CmdPairLength(self, cmd):
-    l, q = PutSignedLength(cmd[1])
-    return bytes.fromhex('%02x' % (cmd[0] + l)) + q
-
   ##########################################################
   # Parse: Text -> Internal Format
   ##########################################################
   def Parse(self, fn, encoding=''):
-    fp = open(fn, 'r')
+    fp = open(fn, 'r', encoding=encoding)
     s = fp.read()
     fp.close()
     self.ParseFromString(s, encoding=encoding)
@@ -911,7 +894,7 @@
   # Dump: Internal Format -> Text
   ##########################################################
   def Dump(self, fn, tabsize=2, encoding=''):
-    fp = open(fn, 'w')
+    fp = open(fn, 'w', encoding=encoding)
     self.DumpToFile(fp, tabsize=tabsize, encoding=encoding)
     fp.close()
 
@@ -919,7 +902,6 @@
     global PutStr
     if   encoding == 'ascii':  PutStr = PutStrASCII
     elif encoding == 'latin1': PutStr = PutStrLatin1
-    elif encoding == 'sjis':   PutStr = PutStrSJIS
     else:                      PutStr = PutStrUTF8
     # DumpPreamble
     fp.write("[preamble]\n")
@@ -937,10 +919,10 @@
     # DumpFontDefinitions
     fp.write("\n[font definitions]\n")
     for e in sorted(self.font_def.keys()):
-      fp.write("fntdef: %s" % self.font_def[e]['name'])
+      fp.write("fntdef: %s " % self.font_def[e]['name'])
       if self.font_def[e]['design_size'] != self.font_def[e]['scaled_size']:
-        fp.write(" (%s) " % self.byconv(self.font_def[e]['design_size']))
-      fp.write(" at %s\n" % self.byconv(self.font_def[e]['scaled_size']))
+        fp.write("(%s) " % self.byconv(self.font_def[e]['design_size']))
+      fp.write("at %s\n" % self.byconv(self.font_def[e]['scaled_size']))
     # DumpPages
     for page in self.pages:
       fp.write("\n[page" + (" %d"*10 % tuple(page['count'])) + "]\n")
@@ -1108,7 +1090,6 @@
       f['slant'] = slant
       f['embolden'] = embolden
     else:
-      f['native'] = False
       f['name'] = n
 
     if q[:2] == "at": q = q[2:]
@@ -1166,7 +1147,7 @@
 Please report bugs to
   https://github.com/aminophen/dviasm"""
 
-  version = """This is %prog-20200905
+  version = """This is %prog-20200912
 
 Copyright (C) 2007-2008 by Jin-Hwan Cho <chofchof at ktug.or.kr>
 Copyright (C) 2011-2017 by Khaled Hosny <khaledhosny at eglug.org>
@@ -1208,12 +1189,12 @@
     parser.error("invalid unit name '%s'!" % options.unit)
   if options.tabsize < 0:
     parser.error("negative tabsize!")
-  if not options.encoding in ['ascii', 'latin1', 'utf8', 'sjis']:
+  if not options.encoding in ['ascii', 'latin1', 'utf8', 'sjis', 'eucjp']:
     parser.error("invalid encoding '%s'!" % options.encoding)
   if options.ptex:
     global is_ptex
     is_ptex = True
-    if not options.encoding in ['utf8', 'sjis']:
+    if not options.encoding in ['utf8', 'sjis', 'eucjp']:
       parser.error("invalid encoding '%s' for Japanese pTeX!" % options.encoding)
   if options.subfont:
     global subfont_list



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