--- ray/src/cal/rcalc.c 2004/06/09 16:00:13 1.13 +++ ray/src/cal/rcalc.c 2005/02/16 17:20:22 1.17 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rcalc.c,v 1.13 2004/06/09 16:00:13 greg Exp $"; +static const char RCSid[] = "$Id: rcalc.c,v 1.17 2005/02/16 17:20:22 greg Exp $"; #endif /* * rcalc.c - record calculator program. @@ -25,7 +25,7 @@ static const char RCSid[] = "$Id: rcalc.c,v 1.13 2004/ #define isblnk(c) (igneol ? isspace(c) : (c)==' '||(c)=='\t') -#define INBSIZ 4096 /* longest record */ +#define INBSIZ 16384 /* longest record */ #define MAXCOL 32 /* number of columns recorded */ /* field type specifications */ @@ -210,6 +210,11 @@ eputs(" [-b][-l][-n][-p][-w][-u][-tS][-s svar=sval][-e } if (noinput) { /* produce a single output record */ + if (i < argc) { + eputs(argv[0]); + eputs(": file argument(s) incompatible with -n\n"); + quit(1); + } eclock++; putout(); quit(0); @@ -454,7 +459,7 @@ int output eputs(": cannot open\n"); quit(1); } - res = read(fd, inpbuf+1, INBSIZ-1); + res = read(fd, inpbuf+2, INBSIZ-2); if (res <= 0 || res >= INBSIZ-1) { eputs(spec); if (res < 0) @@ -466,7 +471,7 @@ int output quit(1); } close(fd); - (inptr=inpbuf+1)[res] = '\0'; + (inptr=inpbuf+2)[res] = '\0'; } f = &fmt; /* get fields */ while ((res = readfield(&inptr)) != F_NUL) { @@ -632,12 +637,12 @@ getrec(void) /* get next record from file */ { int eatline; register struct field *f; - + while (ipb.chr != EOF) { - eatline = !igneol && ipb.chr != '\n'; if (blnkeq) /* beware of nbsynch() */ while (isblnk(ipb.chr)) resetinp(); + eatline = (!igneol && ipb.chr != '\n'); clearrec(); /* start with fresh record */ for (f = inpfmt; f != NULL; f = f->next) if (getfield(f) == -1)