texlive[48890] Build/source/texk/dviout-util: dviout-util: import
commits+hironobu at tug.org
commits+hironobu at tug.org
Fri Oct 12 18:31:45 CEST 2018
Revision: 48890
http://tug.org/svn/texlive?view=revision&revision=48890
Author: hironobu
Date: 2018-10-12 18:31:44 +0200 (Fri, 12 Oct 2018)
Log Message:
-----------
dviout-util: import aminophen/dviout-util at 568ad32
Modified Paths:
--------------
trunk/Build/source/texk/dviout-util/Makefile.am
trunk/Build/source/texk/dviout-util/Makefile.in
trunk/Build/source/texk/dviout-util/dvispc.c
trunk/Build/source/texk/dviout-util/dvispc.test
Modified: trunk/Build/source/texk/dviout-util/Makefile.am
===================================================================
--- trunk/Build/source/texk/dviout-util/Makefile.am 2018-10-12 10:06:04 UTC (rev 48889)
+++ trunk/Build/source/texk/dviout-util/Makefile.am 2018-10-12 16:31:44 UTC (rev 48890)
@@ -36,7 +36,8 @@
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 \
Modified: trunk/Build/source/texk/dviout-util/Makefile.in
===================================================================
--- trunk/Build/source/texk/dviout-util/Makefile.in 2018-10-12 10:06:04 UTC (rev 48889)
+++ trunk/Build/source/texk/dviout-util/Makefile.in 2018-10-12 16:31:44 UTC (rev 48890)
@@ -566,8 +566,9 @@
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
Modified: trunk/Build/source/texk/dviout-util/dvispc.c
===================================================================
--- trunk/Build/source/texk/dviout-util/dvispc.c 2018-10-12 10:06:04 UTC (rev 48889)
+++ trunk/Build/source/texk/dviout-util/dvispc.c 2018-10-12 16:31:44 UTC (rev 48890)
@@ -252,6 +252,14 @@
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_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 @@
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 @@
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 @@
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 @@
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 @@
}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 @@
!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 @@
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 @@
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_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_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_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_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++;
Modified: trunk/Build/source/texk/dviout-util/dvispc.test
===================================================================
--- trunk/Build/source/texk/dviout-util/dvispc.test 2018-10-12 10:06:04 UTC (rev 48889)
+++ trunk/Build/source/texk/dviout-util/dvispc.test 2018-10-12 16:31:44 UTC (rev 48890)
@@ -41,22 +41,28 @@
./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
# the following tests include
@@ -68,10 +74,10 @@
# 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,15 +85,27 @@
## 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
More information about the tex-live-commits
mailing list