[KoCo-CVS] [Commit] cjkcodecs/tools genmap_japanese.py genmap_support.py
Brought to you by:
perky
From: Hye-Shik C. <pe...@us...> - 2003-04-22 21:04:39
|
perky 03/04/22 14:04:36 Modified: tools genmap_japanese.py genmap_support.py Log: Add dummy map providers for japanese. Revision Changes Path 1.2 +9 -9 cjkcodecs/tools/genmap_japanese.py Index: genmap_japanese.py =================================================================== RCS file: /cvsroot/koco/cjkcodecs/tools/genmap_japanese.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- genmap_japanese.py 22 Apr 2003 19:24:24 -0000 1.1 +++ genmap_japanese.py 22 Apr 2003 21:04:36 -0000 1.2 @@ -26,7 +26,7 @@ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # -# $Id: genmap_japanese.py,v 1.1 2003/04/22 19:24:24 perky Exp $ +# $Id: genmap_japanese.py,v 1.2 2003/04/22 21:04:36 perky Exp $ # from genmap_support import * @@ -92,28 +92,28 @@ printcopyright(omap) print "Generating JIS X 0208 decode map..." -genmap_decode(omap, "jisx0208_decode", JISX0208_C1, JISX0208_C2, jisx0208decmap) +genmap_decode(omap, "jisx0208", JISX0208_C1, JISX0208_C2, jisx0208decmap) print "Generating JIS X 0208 decode map index..." -print_decmapindex(omap, "jisx0208_decode", jisx0208decmap, rng=(0, 128)) +print_decmapindex(omap, "jisx0208", jisx0208decmap, rng=(0, 128)) omap = open("map_jisx0212.h", "w") printcopyright(omap) print "Generating JIS X 0212 decode map..." -genmap_decode(omap, "jisx0212_decode", JISX0212_C1, JISX0212_C2, jisx0212decmap) +genmap_decode(omap, "jisx0212", JISX0212_C1, JISX0212_C2, jisx0212decmap) print "Generating JIS X 0212 decode map index..." -print_decmapindex(omap, "jisx0212_decode", jisx0212decmap, rng=(0, 128)) +print_decmapindex(omap, "jisx0212", jisx0212decmap, rng=(0, 128)) omap = open("map_cp932.h", "w") printcopyright(omap) print "Generating CP932 decode map..." -genmap_decode(omap, "cp932_decode", CP932P0_C1, CP932P0_C2, cp932decmap) -genmap_decode(omap, "cp932_decode", CP932P1_C1, CP932P1_C2, cp932decmap) -genmap_decode(omap, "cp932_decode", CP932P2_C1, CP932P2_C2, cp932decmap) +genmap_decode(omap, "cp932", CP932P0_C1, CP932P0_C2, cp932decmap) +genmap_decode(omap, "cp932", CP932P1_C1, CP932P1_C2, cp932decmap) +genmap_decode(omap, "cp932", CP932P2_C1, CP932P2_C2, cp932decmap) print "Generating CP932 decode map index..." -print_decmapindex(omap, "cp932_decode", cp932decmap) +print_decmapindex(omap, "cp932", cp932decmap) print "Generating CP932 Tweaks..." if difmap: 1.3 +27 -18 cjkcodecs/tools/genmap_support.py Index: genmap_support.py =================================================================== RCS file: /cvsroot/koco/cjkcodecs/tools/genmap_support.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- genmap_support.py 22 Apr 2003 19:24:25 -0000 1.2 +++ genmap_support.py 22 Apr 2003 21:04:36 -0000 1.3 @@ -26,14 +26,14 @@ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # -# $Id: genmap_support.py,v 1.2 2003/04/22 19:24:25 perky Exp $ +# $Id: genmap_support.py,v 1.3 2003/04/22 21:04:36 perky Exp $ # import re COPYRIGHT_HEADER = """\ /* - * $Id: genmap_support.py,v 1.2 2003/04/22 19:24:25 perky Exp $ + * $Id: genmap_support.py,v 1.3 2003/04/22 21:04:36 perky Exp $ */ """ re_UNIMAPDATE = re.compile('Date:\s*([ a-zA-Z0-9/]*)') @@ -50,21 +50,22 @@ if not dmap.has_key(c1) or (onlymask and c1 not in onlymask): continue c2map = dmap[c1] - for c2 in c2values: - if c2map.has_key(c2): - break - else: + rc2values = [n for n in c2values if c2map.has_key(n)] + if not rc2values: continue + rc2values = range(rc2values[0], rc2values[-1] + 1) + rc2width = len(rc2values) - print >> fo, ("static const Py_UNICODE %s_%02X[%d] = {" + print >> fo, ("static const Py_UNICODE __%s_decmap_%02X[%d] = {" " /* %02X::%02X-%02X */" - % (prefix, c1, c2width, c1, c2range[0], c2range[1])) + % (prefix, c1, rc2width, c1, rc2values[0], rc2values[-1])) c2map[prefix] = True + c2map['min'] = rc2values[0] + c2map['max'] = rc2values[-1] - c2s = c2values[:] - while c2s: - dp = c2s[:8] - del c2s[:8] + while rc2values: + dp = rc2values[:8] + del rc2values[:8] print >> fo, ' ', ' '.join([ c2map.has_key(i) and ("0x%04x," % c2map[i]) or "UNIINV," @@ -73,16 +74,22 @@ print >> fo, "};" print >> fo -def print_decmapindex(fo, prefix, fmap, +def print_decmapindex(fo, fmapprefix, fmap, f2map={}, f2mapprefix='', rng=(0x80, 0x100)): - print >> fo, "static const Py_UNICODE *%s_map[128] = {" % (prefix) + print >> fo, "static const struct dbcs_index %s_decmap[128] = {" % (fmapprefix) for i in range(*rng): - if fmap.has_key(i) and fmap[i].has_key(prefix): - print >> fo, " %s_%02X, /* 0x%02X */" % (prefix, i, i) + if fmap.has_key(i) and fmap[i].has_key(fmapprefix): + map = fmap + prefix = fmapprefix elif f2map.has_key(i) and f2map[i].has_key(f2mapprefix): - print >> fo, " %s_%02X, /* 0x%02X */" % (f2mapprefix, i, i) + map = f2map + prefix = f2mapprefix else: - print >> fo, " 0, /* 0x%02X */" % i + print >> fo, "/* 0x%02X */ {0, 0, 0}," % i + continue + + print >> fo, "/* 0x%02X */ {__%s_decmap_%02X, 0x%02x, 0x%02x}," % ( + i, prefix, i, map[i]['min'], map[i]['max']) print >> fo, "};" print >> fo @@ -109,3 +116,5 @@ decmap[(loc >> 8)|sethighbit][(loc & 0xff)|sethighbit] = uni return mapdatever, decmap + +# ex: ts=8 sts=4 et |