From Peter Valchev: fix editcap to assign the result of "getopt()" to an

"int" and to check "getopt()"s return value with -1 rather than EOF.

Fix other "getopt()" loops to check against -1 as well (EOF is -1 on
most if not all platforms, but the Single UNIX Specification says
"getopt()" returns -1, so we should check against -1, not EOF).

svn path=/trunk/; revision=4793
This commit is contained in:
Guy Harris 2002-02-24 01:26:45 +00:00
parent f4f3208a00
commit 309e86246e
7 changed files with 17 additions and 11 deletions

View File

@ -1060,6 +1060,11 @@ John Mackenzie <John.A.Mackenzie[AT]t-online.de> {
Put missing initializations of table entries in "plugins.c"
}
Peter Valchev <pvalchev[AT]openbsd.org> {
Fix editcap to assign the result of "getopt()" to an "int" and
to check "getopt()"s return value with -1 rather than EOF
}
Alain Magloire <alainm[AT]rcsm.ece.mcgill.ca> was kind enough to
give his permission to use his version of snprintf.c.

View File

@ -1387,6 +1387,7 @@ B<http://www.ethereal.com>.
Adam Sulmicki <adam[AT]cfar.umd.edu>
Kari Tiirikainen <ktiirika[AT]stybba.ntc.nokia.com>
John Mackenzie <John.A.Mackenzie[AT]t-online.de>
Peter Valchev <pvalchev[AT]openbsd.org>
Alain Magloire <alainm[AT]rcsm.ece.mcgill.ca> was kind enough to give his
permission to use his version of snprintf.c.

View File

@ -1,7 +1,7 @@
/* Edit capture files. We can delete records, adjust timestamps, or
* simply convert from one format to another format.
*
* $Id: editcap.c,v 1.19 2002/02/08 10:07:33 guy Exp $
* $Id: editcap.c,v 1.20 2002/02/24 01:26:42 guy Exp $
*
* Originally written by Richard Sharpe.
* Improved by Guy Harris.
@ -314,13 +314,13 @@ int main(int argc, char *argv[])
callback_arg args;
extern char *optarg;
extern int optind;
char opt;
int opt;
char *p;
int snapshot_length;
/* Process the options first */
while ((opt = getopt(argc, argv, "T:F:rvs:t:h")) != EOF) {
while ((opt = getopt(argc, argv, "T:F:rvs:t:h")) !=-1) {
switch (opt) {

View File

@ -1,6 +1,6 @@
/* main.c
*
* $Id: main.c,v 1.233 2002/02/18 01:08:44 guy Exp $
* $Id: main.c,v 1.234 2002/02/24 01:26:45 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -1412,7 +1412,7 @@ main(int argc, char *argv[])
#endif
/* Now get our args */
while ((opt = getopt(argc, argv, "a:b:B:c:f:hi:klm:nN:o:pP:Qr:R:Ss:t:T:w:W:vZ:")) != EOF) {
while ((opt = getopt(argc, argv, "a:b:B:c:f:hi:klm:nN:o:pP:Qr:R:Ss:t:T:w:W:vZ:")) != -1) {
switch (opt) {
case 'a': /* autostop criteria */
#ifdef HAVE_LIBPCAP

View File

@ -1,6 +1,6 @@
/* Combine two dump files, either by appending or by merging by timestamp
*
* $Id: mergecap.c,v 1.6 2002/02/08 10:07:34 guy Exp $
* $Id: mergecap.c,v 1.7 2002/02/24 01:26:42 guy Exp $
*
* Written by Scott Renfro <scott@renfro.org> based on
* editcap by Richard Sharpe and Guy Harris
@ -405,7 +405,7 @@ main(int argc, char *argv[])
out_file.count = 1; /* frames output */
/* Process the options first */
while ((opt = getopt(argc, argv, "hvas:T:F:w:")) != EOF) {
while ((opt = getopt(argc, argv, "hvas:T:F:w:")) != -1) {
switch (opt) {
case 'w':

View File

@ -4,7 +4,7 @@
* Creates random packet traces. Useful for debugging sniffers by testing
* assumptions about the veracity of the data found in the packet.
*
* $Id: randpkt.c,v 1.12 2002/02/14 17:45:07 gram Exp $
* $Id: randpkt.c,v 1.13 2002/02/24 01:26:42 guy Exp $
*
* Copyright (C) 1999 by Gilbert Ramirez <gram@alumni.rice.edu>
*
@ -304,7 +304,7 @@ main(int argc, char **argv)
int produce_max_bytes = 5000;
pkt_example *example;
while ((opt = getopt(argc, argv, "b:c:t:")) != EOF) {
while ((opt = getopt(argc, argv, "b:c:t:")) != -1) {
switch (opt) {
case 'b': /* max bytes */
produce_max_bytes = atoi(optarg);

View File

@ -1,6 +1,6 @@
/* tethereal.c
*
* $Id: tethereal.c,v 1.122 2002/02/18 01:08:38 guy Exp $
* $Id: tethereal.c,v 1.123 2002/02/24 01:26:42 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -415,7 +415,7 @@ main(int argc, char *argv[])
#endif
/* Now get our args */
while ((opt = getopt(argc, argv, "a:b:c:Df:F:hi:lnN:o:pr:R:s:t:vw:Vx")) != EOF) {
while ((opt = getopt(argc, argv, "a:b:c:Df:F:hi:lnN:o:pr:R:s:t:vw:Vx")) != -1) {
switch (opt) {
case 'a': /* autostop criteria */
#ifdef HAVE_LIBPCAP