Article View: net.bugs.usg
Article #329bug in cut (1)
From: 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
Technical Details
Message-ID:
<28@pixutl.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!topaz!husc6!wjh12!pixel!pixutl!chrisShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!topaz!husc6!wjh12!pixel!pixutl!chris From: chris@pixutl.UUCP (chris) Newsgroups: net.bugs.usg Subject: bug in cut (1) Message-ID: <28@pixutl.UUCP> Date: Wed, 6-Aug-86 17:45:54 EDT Article-I.D.: pixutl.28 Posted: Wed Aug 6 17:45:54 1986 Date-Received: Sat, 9-Aug-86 01:54:04 EDT Organization: xePIX Inc., Nashua, N.H. Lines: 95 Keywords: cut, SYSV