Use an integer instead of a char to store the getopt() return value in
order to match the function prototype and to work with compilers that default to unsigned chars. Compare the getopt() return value with -1 instead of EOF.
This commit is contained in:
parent
f8fcb56bce
commit
d786999078
|
@ -14,7 +14,7 @@
|
|||
* I would appreciate (though I do not require) receiving a copy of any
|
||||
* improvements you might make to this program.
|
||||
*
|
||||
* $Id: units.c,v 1.4 1996/03/21 18:06:48 jtc Exp $
|
||||
* $Id: units.c,v 1.5 1996/04/01 21:43:53 mark Exp $
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
@ -631,14 +631,14 @@ main(int argc, char **argv)
|
|||
|
||||
struct unittype have, want;
|
||||
char havestr[81], wantstr[81];
|
||||
char optchar;
|
||||
int optchar;
|
||||
char *userfile = 0;
|
||||
int quiet = 0;
|
||||
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
|
||||
while (EOF != (optchar = getopt(argc, argv, "vqf:"))) {
|
||||
while ((optchar = getopt(argc, argv, "vqf:")) != -1) {
|
||||
switch (optchar) {
|
||||
case 'f':
|
||||
userfile = optarg;
|
||||
|
|
Loading…
Reference in New Issue