Index: kanjiencoding.c =================================================================== --- jmpost-0.04b.orig/kanjiencoding.c +++ jmpost-0.04b/kanjiencoding.c 1970-01-01 09:00:00 +0900 @@ -1,9 +0,0 @@ -#include "../kanji.h" - -#if TERM_CODE == JIS -char prockanjicode = JIS; -#elif TERM_CODE == SJIS -char prockanjicode = SJIS; -#else -char prockanjicode = EUC; -#endif Index: ext.defines =================================================================== --- jmpost-0.04b.orig/ext.defines +++ jmpost-0.04b/ext.defines 1970-01-01 09:00:00 +0900 @@ -1 +0,0 @@ -@define const PDVITOMPHELP; Index: prockanji.defines =================================================================== --- jmpost-0.04b.orig/prockanji.defines +++ jmpost-0.04b/prockanji.defines 1970-01-01 09:00:00 +0900 @@ -1 +0,0 @@ -@define var prockanjicode; Index: jmp.ch =================================================================== --- jmpost-0.04b.orig/jmp.ch +++ jmpost-0.04b/jmp.ch @@ -18,12 +18,9 @@ wterm (version_string); @y wterm (banner); -case proc_kanji_code of - 0: wterm(' (JIS)'); - 1: wterm(' (EUC)'); - 2: wterm(' (SJIS)'); - othercases wterm(' (?)'); -endcases; +wterm(' ('); +wterm(stringcast(get_enc_string)); +wterm(')'); wterm (version_string); @z @@ -90,9 +87,9 @@ wlog (version_string); @y begin wlog(banner); -ifdef('OUTJIS') wlog(' (JIS)'); endif('OUTJIS')@/ -ifdef('OUTSJIS') wlog(' (SJIS)'); endif('OUTSJIS')@/ -ifdef('OUTEUC') wlog(' (EUC)'); endif('OUTEUC')@/ +wlog(' ('); +wlog(stringcast(get_enc_string)); +wlog(')'); wlog (version_string); @z @@ -257,8 +254,8 @@ lost_warning(f,k) else begin if (not font_jfm_p(f)) then cc:=char_info(f)(str_pool[k]) - else begin incr(k); - cc:=char_info(f)(lookup_ctype(f,str_pool[k-1]*256+str_pool[k])) + else begin + cc:=char_info(f)(lookup_ctype(f,fromBUFF(str_pool,limit,k))); incr(k) end; @z @@ -291,19 +288,12 @@ print("<"); while imax_print_line then print_ln; - k:=so(str_pool[i]);@/ - incr(i); - if (proc_kanji_code=1) then - c:=EUCtoJIS(k*@'400+so(str_pool[i])) - else if(proc_kanji_code=2) then - c:=SJIStoJIS(k*@'400+so(str_pool[i])); - k:=(c div @'400); - hex_digit_out(k div 16); - hex_digit_out(k mod 16); - k:=c mod @'400; - hex_digit_out(k div 16); - hex_digit_out(k mod 16); - incr(i); + c:=toDVI(fromBUFF(str_pool, i+2, i)); + i:=i+2; + hex_digit_out(Hi(c) div 16); + hex_digit_out(Hi(c) mod 16); + hex_digit_out(Lo(c) div 16); + hex_digit_out(Lo(c) mod 16); end; print(">"); end; Index: configure =================================================================== --- jmpost-0.04b.orig/configure +++ jmpost-0.04b/configure @@ -6,11 +6,7 @@ echo "please make orignal Web2c programs before make jMetaPost." exit 1 fi -if [ ! -f ../kanji.o ]; then - echo "../kanji.o not found." - echo "please do configure Ascii pTeX before make jMetaPost." - exit 1 -fi + CONFIG_FILES=Makefile CONFIG_HEADERS=.. export CONFIG_FILES CONFIG_HEADERS Index: Makefile.in =================================================================== --- jmpost-0.04b.orig/Makefile.in +++ jmpost-0.04b/Makefile.in @@ -5,7 +5,7 @@ version = @WEB2CVERSION@ -default: programs formats +default all: programs fmtutil.cnf programs=jmpost pdvitomp @@ -14,6 +14,7 @@ .SUFFIXES: # get rid of .p.o ac_include ../../../make/common.mk ac_include ../../../make/programs.mk +ac_include ../../../ptexenc/programs.mk @MAINT@ifeq ($(CC), gcc) @MAINT@XDEFS = -Wimplicit -Wreturn-type -Wcomment -Wformat @@ -28,13 +29,12 @@ $(makevars) $(common_makeargs) proglib = ../../lib/lib.a -XCFLAGS = -I.. # The sh script that does the conversion: web2c = srcdir=$(thisdir) $(SHELL) $(thisdir)/jconvert # Additional dependencies: web2c_aux = $(thisdir)/jconvert $(cwebdir)/common.defines \ - ../kanji.defines ./ext.defines + $(thisdir)/kanji.defines web2c_programs = $(cwebdir)/fixwrites $(cwebdir)/splitup $(cwebdir)/web2c # Unfortunately, suffix rules can't have dependencies, or multiple @@ -44,8 +44,11 @@ $(web2c) $* ### .ch.p: # really depends on $(srcdir)/tangle; for ptex, also generates .pool ### $(srcdir)/tangle $(thisdir)/$*.web $< -plib_o = ../kanji.o version.o kanjiencoding.o +jmp_c = mpini.c mp0.c mp1.c mp2.c +jmp_o = mpini.o mp0.o mp1.o mp2.o jmpextra.o version.o +plib_o = version.o + # Prevent Make from deleting the intermediate forms. .PRECIOUS: %.p %.c @@ -60,17 +63,11 @@ kpathsea_parent = $(top_srcdir) kpathsea_srcdir_parent = $(kpathsea_parent) -jmp_c = mpini.c mp0.c mp1.c mp2.c -jmp_o = mpini.o mp0.o mp1.o mp2.o jmpextra.o ../kanji.o version.o kanjiencoding.o - programs: $(programs) -all_mems = jmpost.mem -formats: mems -mems: $(all_mems) ### jMetaPost -jmpost: $(jmp_o) - $(kpathsea_link) $(jmp_o) $(LOADLIBES) +jmpost: $(jmp_o) $(kpathsea) $(ptexenc) + $(kpathsea_link) $(jmp_o) $(ptexenc) $(LOADLIBES) $(jmp_c) mpcoerce.h mpd.h: jmp.p $(web2c_aux) $(web2c_programs) $(cwebdir)/cvtmf1.sed $(cwebdir)/cvtmf2.sed $(web2c) jmp ###mpextra.c: ../../lib/texmfmp.c @@ -81,10 +78,9 @@ $(srcdir)/tie -m jmp.web $(srcdir)/mp.web $(srcdir)/mp.ch jmp.ch ### pDVItoMP -pdvitomp: pdvitomp.o $(plib_o) $(kpathsea) $(proglib) - $(kpathsea_link) pdvitomp.o $(plib_o) $(LOADLIBES) -kanjiencoding.o: kanjiencoding.c -pdvitomp.o: pdvitomp.c ../kanji.h +pdvitomp: pdvitomp.o $(plib_o) $(ptexenc) $(kpathsea) $(proglib) + $(kpathsea_link) pdvitomp.o $(plib_o) $(ptexenc) $(LOADLIBES) +pdvitomp.o: pdvitomp.c kanji.h pdvitomp.c: pdvitomp.p $(web2c_aux) pdvitomp.p: pdvitomp.web $(srcdir)/tangle $(srcdir)/tangle pdvitomp.web @@ -92,9 +88,7 @@ $(srcdir)/tie -m pdvitomp.web $(srcdir)/dvitomp.web \ $(srcdir)/dvitomp.ch pdvitomp.ch -../kanji.o: ../kanji.c ../kanji.h - cd .. && $(MAKE) kanji.o -version.o: version.c ../kanji.h +version.o: version.c kanji.h # Additional dependencies for recompiling the C code are generated # automatically, included at the end. @@ -109,19 +103,36 @@ $(proglib): cd $(srcdir)/lib && $(MAKE) lib.a $(kpathsea): - cd $(kpathsea_dir) && $(MAKE) libkpathsea.a + cd $(kpathsea_dir) && $(MAKE) libkpathsea.la +$(ptexenc): + cd $(ptexenc_dir) && $(MAKE) libptexenc.la +# +# Making formats and bases. +all_mems = jmpost.mem +formats: mems +mems: $(all_mems) + +fmtutil.cnf: ../fmtutil.cnf + cat ../fmtutil.cnf > $@ + echo 'jmpost jmpost - mpost.mp' >> $@ + +dumpenv = TEXMFCNF=$(thisdir) + +jmpost.mem: jmpost + $(dumpenv) $(MAKE) $(makeargs) progname=jmpost files=plain.mp prereq-check + $(dumpenv) ./jmpost --ini --jobname=jmpost \\input plain dump /dev/null \ - || $(MAKE) prereq-lose >/dev/null + $(dumpenv) $(kpathsea_dir)/kpsewhich --progname=$(progname) $(files) >/dev/null || $(MAKE) prereq-lose >/dev/null prereq-lose: @echo "You seem to be missing input files necessary to make the" >&2 @echo "basic formats (some or all of: $(files))." >&2 @echo "Perhaps you've defined the default paths incorrectly, or" >&2 @echo "perhaps you have environment variables set pointing" >&2 - @echo "to an incorrect location. See ../kpathsea/BUGS." >&2 + @echo "to an incorrect location. See $(srcdir)/kpathsea/BUGS." >&2 @echo >&2 @echo "If you simply do not have the files, you can" >&2 @echo "retrieve a minimal set of input files from" >&2 @@ -134,7 +145,6 @@ # install: install-exec install-data install-exec:: install-links -install-data:: install-formats # Installation directories. $(bindir):: @@ -144,25 +154,26 @@ # The actual binary executables and pool files. install-programs: $(programs) pmakempx $(bindir) - for p in $(programs); do $(INSTALL_LIBTOOL_PROG) $$p $(bindir); done - $(INSTALL_PROGRAM) pmakempx $(bindir)/pmakempx + for p in $(programs) pmakempx; do $(INSTALL_LIBTOOL_PROG) $$p $(bindir); done install-links: install-programs $(bindir) cd $(bindir) && (rm -f inijmpost virjmpost) -install-formats: install-fmts -install-fmts: $(all_mems) $(web2cdir) - for f in $(all_mems); do $(INSTALL_DATA) $$f $(web2cdir)/$$f; done -# +install-formats: install-data + - TEXMFMAIN=$(texmf) PATH=$(scriptdir):$(bindir):$(PATH) \ + $(scriptdir)/fmtutil-sys --byfmt jmpost + - TEXMFMAIN=$(texmf) PATH=$(scriptdir):$(bindir):$(PATH) \ + $(scriptdir)/mktexlsr + - TEXMFMAIN=$(texmf) PATH=$(scriptdir):$(bindir):$(PATH) \ + $(scriptdir)/texlinks + # Auxiliary files. -install-data:: - $(SHELL) $(top_srcdir)/mkinstalldirs $(web2cdir) +install-data:: $(web2cdir) fmtutil.cnf $(INSTALL_DATA) jmp.pool $(web2cdir)/jmp.pool - -jmpost.mem: jmpost - $(dumpenv) $(MAKE) $(makeargs) progname=jmpost files=plain.mp prereq-check - $(dumpenv) ./jmpost --ini --jobname=jmpost \\input plain dump + +#define KANJI + +/* functions */ +#define Hi(x) (((x) >> 8) & 0xff) +#define Lo(x) ((x) & 0xff) + +#ifndef PRESERVE_PUTC +#undef putc +#define putc(c,fp) putc2(c,fp) +#endif /* !PRESERVE_PUTC */ + +#ifdef TeX +#undef TEXMFPOOLNAME +#undef TEXMFENGINENAME +#define TEXMFPOOLNAME "ptex.pool" +#define TEXMFENGINENAME "ptex" +#endif /* TeX */ + +#ifdef MP +#undef TEXMFPOOLNAME +#undef TEXMFENGINENAME +#define TEXMFPOOLNAME "jmp.pool" +#define TEXMFENGINENAME "jmpost" +#endif /* MP */ + +#endif /* not KANJI_H */ Index: version.c =================================================================== --- jmpost-0.04b.orig/version.c +++ jmpost-0.04b/version.c @@ -30,18 +30,12 @@ extern const_string local_maintainer; /* from maintain.h */ extern string versionstring; /* from web2c/lib/version.c */ extern KPSEDLL string kpathsea_version_string;/* from kpathsea/version.c */ - string prog_name, term_code; + string prog_name; extern string based_prog_name; unsigned len; const_string prog_name_end; const_string prog_version; - switch (prockanjicode) { - case JIS: term_code=" (JIS)"; break; - case SJIS: term_code=" (SJIS)"; break; - default: term_code=" (EUC)"; break; - } - prog_name_end = strchr (banner, ','); prog_version = prog_name_end + sizeof("Version") + 2; len = prog_name_end - banner - sizeof ("This is"); @@ -50,8 +44,8 @@ prog_name[len] = 0; /* The Web2c version string starts with a space. */ - fprintf (stdout, "%s %s%s%s\n", - prog_name, prog_version, term_code, versionstring); + fprintf (stdout, "%s %s (%s)%s\n", + prog_name, prog_version, get_enc_string(), versionstring); fputs (kpathsea_version_string, stdout); putc('\n', stdout); Index: kanji.defines =================================================================== --- jmpost-0.04b.orig/kanji.defines +++ jmpost-0.04b/kanji.defines @@ -0,0 +1,17 @@ +{ defined at kanji.c, kanji.h, ptexenc/ptexenc.h } +@define function Hi (); +@define function Lo (); + +@define function getencstring; +@define function setencstring (); + +@define function multistrlen (); +@define function fromBUFF (); +@define function toBUFF (); + +@define function fromDVI (); +@define function toDVI (); +@define function putc2 (); +@define function inputline2 (); + +@define const PDVITOMPHELP; Index: jconvert =================================================================== --- jmpost-0.04b.orig/jconvert +++ jmpost-0.04b/jconvert @@ -19,8 +19,7 @@ convert_jmp () { cat $web2cdir/common.defines $web2cdir/texmf.defines \ - $web2cdir/mfmp.defines ./prockanji.defines \ - ../kanji.defines ./jmp.p \ + $web2cdir/mfmp.defines kanji.defines ./jmp.p \ | sed -f $web2cdir/cvtmf1.sed \ | $web2cdir/web2c -h../../texmfmp.h -m -cmpcoerce \ | sed -f $web2cdir/cvtmf2.sed \ @@ -34,8 +33,7 @@ } convert_tool () { - cat $web2cdir/common.defines ./prockanji.defines \ - ../kanji.defines ext.defines $target.p \ + cat $web2cdir/common.defines kanji.defines $target.p \ | $web2cdir/web2c -hjmpost.h -c$target \ | $web2cdir/fixwrites > $target.c } Index: jmpextra.c =================================================================== --- jmpost-0.04b.orig/jmpextra.c +++ jmpost-0.04b/jmpextra.c @@ -1030,18 +1030,13 @@ } else { WARNING1 ("Ignoring unknown argument `%s' to --interaction", optarg); } - +#ifdef KANJI } else if (ARGUMENT_IS ("kanji")) { /* These numbers match @d's in *.ch */ - if (STREQ (optarg, "jis")) { - prockanjicode = 0; - } else if (STREQ (optarg, "euc")) { - prockanjicode = 1; - } else if (STREQ (optarg, "sjis")) { - prockanjicode = 2; - } else { + if (!set_enc_string(optarg,optarg)) { WARNING1 ("Ignoring unknown argument `%s' to --kanji", optarg); } +#endif /* KANJI */ } else if (ARGUMENT_IS ("help")) { usagehelp (PROGRAM_HELP, BUG_ADDRESS); @@ -1153,7 +1148,7 @@ if (d_name && kpse_readable_file (d_name)) { dump_name = xstrdup (part[0]); kpse_reset_program_name (dump_name); - /* Tell TeX/MF/MP we have a %&name line... */ + /* Tell TeX/MF/MP we have a %&name line... */ dumpline = true; } free (f_name); @@ -1438,47 +1433,9 @@ /* Recognize either LF or CR as a line terminator. */ last = first; -#if defined(KANJI) - while (last < bufsize-3 && (i = getc (f)) != EOF && i != '\n' && i != '\r') { - static int injis=0; - if (i == '\033') { /* ESC */ - if ((i = getc(f)) == '$') { /* Kanji-In */ - i = getc(f); - if (i == '@' || i == 'B') { - injis = 1; - } else { - buffer[last++] = '\033'; - buffer[last++] = '$'; - buffer[last++] = i; - } - } else if (i == '(') { /* Kanji-out */ - i = getc(f); - if (i == 'J' || i == 'B' || i == 'H') { - injis = 0; - } else { - buffer[last++] = '\033'; - buffer[last++] = '('; - buffer[last++] = i; - } - } else { - buffer[last++] = '\033'; - buffer[last++] = i; - } - } else { /* rather than ESC */ - if (injis == 0) { - buffer[last++] = i; - } else { - /* JIS encoding */ - if(prockanjicode == 2) - i = JIStoSJIS(i << 8 | getc(f)); - else if(prockanjicode == 1) - i = JIStoEUC(i << 8 | getc(f)); - buffer[last++] = (i >> 8) & 0xff; - buffer[last++] = i & 0xff; - } - } - } -#else +#ifdef KANJI + last = input_line2(f, buffer, last, bufsize, &i); +#else /* KANJI */ while (last < bufsize && (i = getc (f)) != EOF && i != '\n' && i != '\r') buffer[last++] = i; #endif /* KANJI */ @@ -1793,9 +1750,9 @@ /* Get the job name to be used, which may have been set from the command line. */ strnumber -getjobname(strnumber name) +getjobname() { - strnumber ret = name; + strnumber ret = curname; if (job_name != NULL) ret = maketexstring(job_name); return ret; @@ -1846,7 +1803,6 @@ boolean isnewsource P2C(strnumber, srcfilename, int, lineno) { - size_t len; char *name = gettexstring(srcfilename); return (compare_paths(name, last_source_name) != 0 || lineno != last_lineno); } @@ -1855,8 +1811,6 @@ remembersourceinfo P2C(strnumber, srcfilename, int, lineno) { - size_t len; - if (last_source_name) free(last_source_name); last_source_name = gettexstring(srcfilename); Index: pdvitomp.ch =================================================================== --- jmpost-0.04b.orig/pdvitomp.ch +++ jmpost-0.04b/pdvitomp.ch @@ -334,6 +334,16 @@ @z @x +@ = +procedure parse_arguments; +const n_options = 2; {Pascal won't count array lengths for us.} +@y +@ = +procedure parse_arguments; +const n_options = 3; {Pascal won't count array lengths for us.} +@z + +@x var @!long_options: array[0..n_options] of getopt_struct; @!getopt_return_val: integer; @!option_index: c_int_type; @@ -438,14 +448,9 @@ next_jfm_char_index:=0; @ @= - if strcmp(optarg, 'jis') = 0 then - proc_kanji_code:=0 - else if strcmp(optarg, 'euc') = 0 then - proc_kanji_code:=1 - else if strcmp(optarg, 'sjis') = 0 then - proc_kanji_code:=2 - else - print_ln('Bad kanjicode encoding', optarg, '.'); + if (not set_enc_string(optarg,optarg)) then begin + write_ln('Bad kanjicode encoding "', stringcast(optarg), '".'); + end; @ JFM character type table is stored in the array |jfm_char_code| and |jfm_char_type|. The character code and the character type of $i$-th @@ -491,7 +496,7 @@ @ Every Kanji characters are supposed to be printable here, so that the state always results in normal at the end of the procedure. Kanji characters need to be converted into output Kanji encoding -from JIS. +from DVI(JIS). @= procedure print_kanji_char(@!c:integer); @@ -509,11 +514,8 @@ print('"'); incr(print_col); state:=normal; end; - if (proc_kanji_code=1) then - c:=JIStoEUC(c) - else if (proc_kanji_code=2) then - c:=JIStoSJIS(c); - print(xchr[c div 256]); print(xchr[c mod 256]); + c:=toBUFF(fromDVI(c)); + print(xchr[Hi(c)]); print(xchr[Lo(c)]); print_col:=print_col+2; end; @z