--- ray/src/px/pflip.c 2004/03/28 20:33:14 2.8 +++ ray/src/px/pflip.c 2012/05/17 17:36:14 2.10 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: pflip.c,v 2.8 2004/03/28 20:33:14 schorsch Exp $"; +static const char RCSid[] = "$Id: pflip.c,v 2.10 2012/05/17 17:36:14 greg Exp $"; #endif /* * flip picture file horizontally and/or vertically @@ -70,15 +70,19 @@ main( correctorder++; else break; + if (i < argc-2) + goto userr; + if (!fhoriz && !fvert) + fprintf(stderr, "%s: warning - no operation\n", argv[0]); if (i >= argc || argv[i][0] == '-') { - fprintf(stderr, "Usage: %s [-h][-v][-c] infile [outfile]\n", - progname); + if (fvert) + goto userr; + SET_FILE_BINARY(stdin); + fin = stdin; + } else if ((fin = fopen(argv[i], "r")) == NULL) { + fprintf(stderr, "%s: cannot open\n", argv[i]); exit(1); } - if ((fin = fopen(argv[i], "r")) == NULL) { - fprintf(stderr, "%s: cannot open\n", argv[1]); - exit(1); - } if (i < argc-1 && freopen(argv[i+1], "w", stdout) == NULL) { fprintf(stderr, "%s: cannot open\n", argv[i+1]); exit(1); @@ -106,6 +110,10 @@ main( scanfile(); flip(); /* flip the image */ exit(0); +userr: + fprintf(stderr, "Usage: %s [-h][-v][-c] infile [outfile]\n", + progname); + exit(1); }