From 991c3603b7082d4ea2a20d4a15b95d051b96a9db Mon Sep 17 00:00:00 2001 From: Hironobu Yamashita Date: Fri, 12 Oct 2018 16:31:44 +0000 Subject: dviout-util: import aminophen/dviout-util@568ad32 git-svn-id: svn://tug.org/texlive/trunk@48890 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/dviout-util/Makefile.am | 3 +- Build/source/texk/dviout-util/Makefile.in | 5 +- Build/source/texk/dviout-util/dvispc.c | 77 +++++++++++++++++-------------- Build/source/texk/dviout-util/dvispc.test | 38 +++++++++++---- 4 files changed, 76 insertions(+), 47 deletions(-) (limited to 'Build/source/texk/dviout-util') diff --git a/Build/source/texk/dviout-util/Makefile.am b/Build/source/texk/dviout-util/Makefile.am index 760bb4e7276..13e5905ffbf 100644 --- a/Build/source/texk/dviout-util/Makefile.am +++ b/Build/source/texk/dviout-util/Makefile.am @@ -36,7 +36,8 @@ EXTRA_DIST += tests/test.spc \ tests/longspec.tex tests/longspec.dvi tests/longspecout.dvi DISTCLEANFILES = x*test.spc \ x*testa.txt x*testax.dvi \ - x*testout.dvi x*oldindepout.dvi x*longspecout.dvi + x*testout.dvi x*oldindepout.dvi x*longspecout.dvi \ + x*write.dvi x*writeout.dvi ## chkdvifont.test EXTRA_DIST += tests/test.cfn \ diff --git a/Build/source/texk/dviout-util/Makefile.in b/Build/source/texk/dviout-util/Makefile.in index a7068163c3c..196dabc8bf8 100644 --- a/Build/source/texk/dviout-util/Makefile.in +++ b/Build/source/texk/dviout-util/Makefile.in @@ -566,8 +566,9 @@ EXTRA_DIST = $(TESTS) tests/test.spc tests/test.tex tests/test.dvi \ tests/jis.cfn tests/eufm10.tfm tests/eufm10.cfn tests/cmr10.pk \ tests/cmr10.cfn tests/upjisr-h.vf tests/upsjir-h.cfn DISTCLEANFILES = x*test.spc x*testa.txt x*testax.dvi x*testout.dvi \ - x*oldindepout.dvi x*longspecout.dvi test.dvi xtest.cfn \ - xjis.cfn xeufm10.cfn xeufm10.ed.cfn xcmr10.cfn xupjisr-h.cfn + x*oldindepout.dvi x*longspecout.dvi x*write.dvi x*writeout.dvi \ + test.dvi xtest.cfn xjis.cfn xeufm10.cfn xeufm10.ed.cfn \ + xcmr10.cfn xupjisr-h.cfn all: config.h $(MAKE) $(AM_MAKEFLAGS) all-am diff --git a/Build/source/texk/dviout-util/dvispc.c b/Build/source/texk/dviout-util/dvispc.c index 89da842e531..67e08a71517 100644 --- a/Build/source/texk/dviout-util/dvispc.c +++ b/Build/source/texk/dviout-util/dvispc.c @@ -252,6 +252,14 @@ int max_stack; char *out_pages ="T-L"; int total_book_page; +/* non-stack specials */ +int f_background = 0; +char background[MAX_LEN]; +int f_pdf_bgcolor = 0; +char pdf_bgcolor[MAX_LEN]; +int f_pn = 0; +char tpic_pn[MAX_LEN]; + /* stack specials */ int color_depth; int color_depth_max; @@ -266,14 +274,6 @@ int pdf_annot_depth_max; int pdf_annot_under; char *pdf_annot_pt[MAX_ANNOT]; -/* non-stack specials */ -int f_background = 0; -char background[MAX_LEN]; -int f_pdf_bgcolor = 0; -char pdf_bgcolor[MAX_LEN]; -int f_pn = 0; -char tpic_pn[MAX_LEN]; - int f_needs_corr; /* flag to determine if correction is needed */ char color_buf[COLOR_BUF_SIZE]; /* common buffer for color/pdf_color */ char annot_buf[ANNOT_BUF_SIZE]; @@ -667,13 +667,11 @@ skip: ; break; case 2: - /* if(fp_in == NULL){ */ /* prioritize filename arguments; if fp_in != NULL, non-empty stdin will be discarded but don't care! */ strcpy(infile, argv[argc-2]); strcpy(outfile, argv[argc-1]); break; - /* } */ default: usage(1); } @@ -688,7 +686,27 @@ skip: ; setmode( fileno( stdin ), O_BINARY); #endif } - /* -x : text -> DVI */ + + /* append .dvi suffix if input/output is DVI */ + if(f_mode == EXE2DVI || f_mode == EXE2MODIFY){ + len = strlen(outfile); + if(len){ + if(len < 4 || StrCmp(outfile + len - 4, ".dvi")) + strcat(outfile, ".dvi"); + } + } + if(f_mode != EXE2DVI){ + len = strlen(infile); + if(len){ + if(len < 4 || StrCmp(infile + len - 4, ".dvi")){ + strcat(infile, ".dvi"); + len += 4; /* will be reused later while preparing overwrite */ + } + dvi_info.file_name = infile; + } + } + + /* -x : text -> DVI */ if(f_mode == EXE2DVI){ /* use infile if given, otherwise use existing fp_in (= non-empty stdin) note that fp_in and infile are exclusive (already checked above) */ @@ -699,11 +717,8 @@ skip: ; exit(1); } } - /* [TODO] I'd like to use outfile if given */ + /* use outfile if given */ if(fp_out == NULL || *outfile){ - len = strlen(outfile); - if(len < 4 || StrCmp(outfile + len - 4, ".dvi")) - strcat(outfile, ".dvi"); fp_out = fopen(outfile, WRITE_BINARY); if(fp_out == NULL){ fprintf(stderr, "Cannot open %s for output\n", outfile); @@ -713,16 +728,8 @@ skip: ; trans2dvi(); /* files will be closed */ return 0; } - /* dvi->dvi or -d or -s or -a */ - len = strlen(infile); - if(len){ - if(len < 4 || StrCmp(infile + len - 4, ".dvi")){ - strcat(infile, ".dvi"); - len += 4; - } - dvi_info.file_name = infile; - } + /* dvi->dvi or -d or -s or -a */ /* [TODO] comments not added yet */ if(argc - i == 1){ if(f_mode == EXE2MODIFY && !fnum){ @@ -750,9 +757,6 @@ same: strcpy(outfile, infile); }else if(argc - i == 2){ #ifdef UNIX struct stat infstat, outfstat; -#endif - strcpy(outfile, argv[argc-1]); -#ifdef UNIX if(stat(infile, &infstat) == 0 && stat(outfile, &outfstat) == 0 && infstat.st_dev == outfstat.st_dev && infstat.st_ino == outfstat.st_ino) #else @@ -1327,11 +1331,11 @@ skip: while (tmp--) !strsubcmp(special, "ar") || /* ar: draw circle */ !strsubcmp(special, "ia")) ) /* ia: fill */ f_pn = -1; - else if(!strsubcmp(special, "color") && !f_prescan) /* color push/pop */ + else if(!strsubcmp(special, "color")) /* color push/pop */ sp_color(special); - else if(!strsubcmp(special, "pdf:bcolor") && !f_prescan) /* pdf:bcolor */ + else if(!strsubcmp(special, "pdf:bcolor")) /* pdf:bcolor */ sp_pdf_bcolor(special); - else if(!strsubcmp(special, "pdf:ecolor") && !f_prescan) /* pdf:ecolor */ + else if(!strsubcmp(special, "pdf:ecolor")) /* pdf:ecolor */ sp_pdf_ecolor(special); else if(!strsubcmp(special, "background")){ /* background */ strncpy(background, special, MAX_LEN); @@ -1341,13 +1345,13 @@ skip: while (tmp--) strncpy(pdf_bgcolor, special, MAX_LEN); f_pdf_bgcolor = 1; } - else if(!strsubcmp_n(special, "pdf:bann") && !f_prescan) /* pdf:bann */ + else if(!strsubcmp_n(special, "pdf:bann")) /* pdf:bann */ sp_pdf_bann(special); - else if(!strsubcmp(special, "pdf:eann") && !f_prescan) /* pdf:eann */ + else if(!strsubcmp(special, "pdf:eann")) /* pdf:eann */ sp_pdf_eann(special); break; - } - goto skip; + } + goto skip; } } } @@ -1359,6 +1363,7 @@ skip: while (tmp--) void sp_color(char *sp) { char *s; + if(f_prescan) return; if(strstr(sp, "pop")){ if(--color_depth < 0){ @@ -1395,6 +1400,7 @@ void sp_color(char *sp) void sp_pdf_bcolor(char *sp) { char *s; + if(f_prescan) return; /* copied from "color push" routine of sp_color */ if(pdf_color_depth >= MAX_COLOR){ @@ -1421,6 +1427,7 @@ void sp_pdf_bcolor(char *sp) void sp_pdf_ecolor(char *sp) { char *s; + if(f_prescan) return; /* copied from "color pop" routine of sp_color */ if(--pdf_color_depth < 0){ @@ -1436,6 +1443,7 @@ void sp_pdf_ecolor(char *sp) void sp_pdf_bann(char *sp) { char *s; + if(f_prescan) return; if(pdf_annot_depth >= MAX_ANNOT){ fprintf(stderr, "Too many pdf:bann > %d\n", MAX_ANNOT); Exit(1); @@ -1460,6 +1468,7 @@ void sp_pdf_bann(char *sp) void sp_pdf_eann(char *sp) { char *s; + if(f_prescan) return; if(--pdf_annot_depth < 0){ fprintf(stderr, "pdf:bann ... pdf:eann stack underflow\n"); pdf_annot_under++; diff --git a/Build/source/texk/dviout-util/dvispc.test b/Build/source/texk/dviout-util/dvispc.test index a22519496ec..f477921e759 100755 --- a/Build/source/texk/dviout-util/dvispc.test +++ b/Build/source/texk/dviout-util/dvispc.test @@ -41,21 +41,27 @@ diff --strip-trailing-cr $testdir/test.spc $testdir/test.spc \ ./dvispc -x < x1testa.txt > x1testax.dvi && \ cmp $testdir/test.dvi x1testax.dvi && echo || exit 5 -# not working as expected only for test ?? +# not working as expected only for test (redirect??) #./dvispc -a $testdir/test.dvi | ./dvispc -x x2testax.dvi && \ # cmp $testdir/test.dvi x2testax.dvi && echo || exit 6 -./dvispc -a $testdir/test.dvi | ./dvispc -x > x2testax.dvi && \ - cmp $testdir/test.dvi x2testax.dvi && echo || exit 7 +./dvispc -a $testdir/test.dvi | ./dvispc -x > x3testax.dvi && \ + cmp $testdir/test.dvi x3testax.dvi && echo || exit 7 ## EXE2INDEP ./dvispc -c $testdir/oldindep.dvi xoldindepout.dvi && \ - cmp $testdir/oldindepout.dvi xoldindepout.dvi && echo || exit 8 + cmp $testdir/oldindepout.dvi xoldindepout.dvi && echo || exit 1 ./dvispc -c $testdir/oldindep.dvi > x1oldindepout.dvi && \ - cmp $testdir/oldindepout.dvi x1oldindepout.dvi && echo || exit 9 + cmp $testdir/oldindepout.dvi x1oldindepout.dvi && echo || exit 2 + +## check default overwrite +# not working as expected only for test (redirect??) +#cp $testdir/oldindep.dvi x3write.dvi && \ +# ./dvispc x3write.dvi +# cmp $testdir/oldindepout.dvi x3write.dvi && echo || exit 3 ./dvispc && echo || exit 0 @@ -68,10 +74,10 @@ diff --strip-trailing-cr $testdir/test.spc $testdir/test.spc \ # exit code 1 for usage without argument. (the above line did it!) ./dvispc -c $testdir/test.dvi xtestout.dvi && \ - cmp $testdir/testout.dvi xtestout.dvi && echo || exit 10 + cmp $testdir/testout.dvi xtestout.dvi && echo || exit 4 ./dvispc -c $testdir/test.dvi > x1testout.dvi && \ - cmp $testdir/testout.dvi x1testout.dvi && echo || exit 11 + cmp $testdir/testout.dvi x1testout.dvi && echo || exit 5 ## invalid usage #./dvispc -c < $testdir/test.dvi x2testout.dvi && \ @@ -79,14 +85,26 @@ diff --strip-trailing-cr $testdir/test.spc $testdir/test.spc \ ## stdin is a DVI, random access may not be supported, no test #./dvispc -c < $testdir/test.dvi > x3testout.dvi && \ -# cmp $testdir/testout.dvi x3testout.dvi && echo || exit 12 +# cmp $testdir/testout.dvi x3testout.dvi && echo || exit 6 ./dvispc -c $testdir/longspec.dvi xlongspecout.dvi && \ - cmp $testdir/longspecout.dvi xlongspecout.dvi && echo || exit 13 + cmp $testdir/longspecout.dvi xlongspecout.dvi && echo || exit 7 ## check default is -c ./dvispc $testdir/longspec.dvi x1longspecout.dvi && \ - cmp $testdir/longspecout.dvi x1longspecout.dvi && echo || exit 14 + cmp $testdir/longspecout.dvi x1longspecout.dvi && echo || exit 8 + +## check -b backup works (old version did not work) +# not working as expected only for test (redirect??) +#cp $testdir/oldindep.dvi x4write.dvi && \ +# ./dvispc -b x4write.dvi +# cmp $testdir/oldindepout.dvi x4write.dvi && echo || exit 9 +# cmp $testdir/oldindep.dvi x4write.dvi.bak && echo || exit 9 + +## without .dvi extension (old version missed for outfile) +cp $testdir/oldindep.dvi x5write.dvi && \ + ./dvispc x5write x5writeout + cmp $testdir/oldindepout.dvi x5writeout.dvi && echo || exit 10 exit 0 -- cgit v1.2.3