From 4dfae6add147f6fa48356ae581bc960e1b1acd56 Mon Sep 17 00:00:00 2001 From: Hironobu Yamashita Date: Sat, 6 Oct 2018 18:32:44 +0000 Subject: dvispc.c: ignore stdin if infile is given git-svn-id: svn://tug.org/texlive/trunk@48844 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/dviout-util/ChangeLog | 2 +- Build/source/texk/dviout-util/dvispc.c | 37 +++++++++++++++++---------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Build/source/texk/dviout-util/ChangeLog b/Build/source/texk/dviout-util/ChangeLog index 1259d85ccb6..a7a664cc0c6 100644 --- a/Build/source/texk/dviout-util/ChangeLog +++ b/Build/source/texk/dviout-util/ChangeLog @@ -2,7 +2,7 @@ * dvispc.c: Change option handling for future extensions. Make sure binary with trace does not fail tests by - prioritizing outfile as an explicit argument. + prioritizing infile and outfile as explicit arguments. * chkdvifont.man, dvispc.man: New man pages. * Makefile.am: Adjusted. * configure.ac: Version 20181006. diff --git a/Build/source/texk/dviout-util/dvispc.c b/Build/source/texk/dviout-util/dvispc.c index d88387cacb8..dfbb279beb5 100644 --- a/Build/source/texk/dviout-util/dvispc.c +++ b/Build/source/texk/dviout-util/dvispc.c @@ -652,9 +652,8 @@ skip: ; break; case 1: - if(fnum == 2) /* non-empty stdin, redirected stdout */ - /* [TODO] ??? */ - usage(1); + /* if(fnum == 2) + usage(1); */ if(!fnum){ /* empty stdin, free stdout */ /* if EXE2DVI, the only argument might be outfile, but no input available; nothing I can do */ @@ -669,22 +668,24 @@ skip: ; strcpy(outfile, argv[argc-1]); else fp_out = stdout; - }else /* if fp_out == NULL, free stdout; otherwise empty stdin */ - /* [TODO] to be confirmed - if non-empty stdin, the only argument = outfile - (input is taken from stdin) - if redirected stdout, the only argument = infile - (output goes to stdout for EXE2DVI, overwrite for EXE2INDEP) */ + }else + /* if fp_out == NULL, non-empty stdin and free stdout + -> the only argument = outfile (input from stdin) + otherwise, redirected stdout + -> the only argument = infile + if fnum == 2, non-empty stdin will be discarded but don't care! + (output to overwrite for EXE2INDEP, stdout for others) */ strcpy((fp_out == NULL)?outfile:infile, argv[argc-1]); break; case 2: - if(fp_in == NULL){ - /* prioritize filename arguments */ - strcpy(infile, argv[argc-2]); - strcpy(outfile, argv[argc-1]); - break; - } /* else non-empty stdin already given, confused! */ + /* 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); } @@ -692,7 +693,7 @@ skip: ; if(fp_out && (f_mode == EXE2DVI || (f_mode & EXE2INDEP))) setmode( fileno( stdout ), O_BINARY); #endif - if(fp_in && f_mode != EXE2DVI){ + if(fp_in && !infile && f_mode != EXE2DVI){ fprintf(stderr, "*** stdin is a DVI file. ***\n" "*** Random Access may not be supported! ***\n"); #ifndef UNIX @@ -703,7 +704,7 @@ skip: ; 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) */ - if(fp_in == NULL){ + if(fp_in == NULL || infile){ fp_in = fopen(infile, READ_TEXT); if(fp_in == NULL){ fprintf(stderr, "Cannot open %s\n", infile); @@ -771,7 +772,7 @@ same: strcpy(outfile, infile); #endif goto same; } - if(fp_in){ + if(fp_in && !infile){ dvi_info.file_ptr = fp_in; dvi_info.file_name = "stdin"; }else if ((dvi_info.file_ptr = fopen(dvi_info.file_name, READ_BINARY)) == NULL){ -- cgit v1.2.3