Put an extra '\0' at the end of the buffer before handing it to
"tryit()"; "ascmagic()" assumes the buffer is a '\0'-terminated
string, as it runs a copy of it through "strtok()".
*/
#ifndef lint
static char *moduleid =
- "@(#)$Id: file.c,v 1.25 1992/09/11 13:15:16 ian Exp $";
+ "@(#)$Id: file.c,v 1.26 1993/02/19 14:22:45 ian Exp $";
#endif /* lint */
#include <stdio.h>
{
int fd = 0;
static const char stdname[] = "standard input";
- unsigned char buf[HOWMANY];
+ unsigned char buf[HOWMANY+1]; /* one extra for terminating '\0' */
struct utimbuf utbuf;
struct stat sb;
int nbytes = 0; /* number of bytes read from a datafile */
if (nbytes == 0)
ckfputs("empty", stdout);
- else
+ else {
+ buf[nbytes] = '\0'; /* null-terminate it */
tryit(buf, nbytes);
+ }
if (inname != stdname) {
/*