Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

bug in cut (1)

2 views
Skip to first unread message

chris

unread,
Aug 6, 1986, 5:45:54 PM8/6/86
to
Two uninitialized variables in cut.c may produce weird results. Do
AT&T's compilers initialize stack variables to zero?
There is also some junk code floating around and, finally, the holly
'cannot open' message...

================
Lint output:
================
cut.c(72): warning: r may be used before set
cut.c(75): warning: num may be used before set
cut.c(20): warning: d unused in function main
fclose returns value which is always ignored
diagl defined( cut.c(177) ), but never used
optarg used( cut.c(53) ), but not defined
optind used( cut.c(63) ), but not defined

================
Repeat by:
================
$ cut -d: -f1 /etc/passwd
cut: no fields

================
Context diff follows:
================

*** /tmp/cut.c Wed Aug 6 17:35:51 1986
--- cut.c Wed Aug 6 17:39:55 1986
***************
*** 17,24
char **argv;
{
int del = '\t';
! char *d;
! int num, j, count, poscnt, r, s, t;
int endflag, supflag, cflag, fflag, backflag, filenr;
int sel[NFIELDS];
char buf[BUFSIZ];

--- 17,23 -----
char **argv;
{
int del = '\t';
! int num = 0, j, count, poscnt, r = 0, s, t;
int endflag, supflag, cflag, fflag, backflag, filenr;
int sel[NFIELDS];
char buf[BUFSIZ];
***************
*** 116,122
inptr = stdin;
else
if ((inptr = fopen(argv[filenr], "r")) == NULL) {
! fprintf(stderr, "cut: cannot open %s\n", argv[filenr]);
exit(2);
}
endflag = 0;

--- 115,122 -----
inptr = stdin;
else
if ((inptr = fopen(argv[filenr], "r")) == NULL) {
! fprintf(stderr, "cut: ");
! perror(argv[filenr]);
exit(2);
}
endflag = 0;
***************
*** 171,181
fprintf(stderr, "cut: %s\n", s);
exit(2);
}
-
-
- diagl()
- {
- diag("bad list for c/f option\n");
- }
-
-

--- 171,173 -----
fprintf(stderr, "cut: %s\n", s);
exit(2);
}

================


Chris
--

Chris Bertin : (603) 881-8791 x218
xePIX Inc. :
51 Lake St : {allegra|ihnp4|cbosgd|ima|genrad|amd|harvard}\
Nashua, NH 03060 : !wjh12!pixel!pixutl!chris

0 new messages