Thread View: net.bugs.usg
1 messages
1 total messages
Started by chris
Wed, 06 Aug 1986 21:45
bug in cut (1)
Author: chris
Date: Wed, 06 Aug 1986 21:45
Date: Wed, 06 Aug 1986 21:45
95 lines
2609 bytes
2609 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads