-/* $OpenBSD: files.c,v 1.1 1997/01/20 19:39:50 millert Exp $ */
+/* $OpenBSD: files.c,v 1.2 1997/01/22 06:43:51 millert Exp $ */
/*-
* Copyright (c) 1993
#if 0
static char sccsid[] = "@(#)files.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: files.c,v 1.1 1997/01/20 19:39:50 millert Exp $";
+static char rcsid[] = "$OpenBSD: files.c,v 1.2 1997/01/22 06:43:51 millert Exp $";
#endif
#endif /* not lint */
if(flno >= 0) fstack[flno].fp = 0;
} else {
buffer->data[100] = '\000';
- warnx("line too long:ignoring %s...", buffer->data);
+ warnx("line too long: ignoring %s...", buffer->data);
}
}
}
-/* $OpenBSD: fsort.c,v 1.2 1997/01/22 05:49:19 millert Exp $ */
+/* $OpenBSD: fsort.c,v 1.3 1997/01/22 06:43:52 millert Exp $ */
/*-
* Copyright (c) 1993
#if 0
static char sccsid[] = "@(#)fsort.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: fsort.c,v 1.2 1997/01/22 05:49:19 millert Exp $";
+static char rcsid[] = "$OpenBSD: fsort.c,v 1.3 1997/01/22 06:43:52 millert Exp $";
#endif
#endif /* not lint */
tfield[0].icol.num = 1;
weights = ftbl[0].weights;
if (!buffer) {
- buffer = malloc(BUFSIZE);
+ buffer = malloc(BUFSIZE + 1);
keylist = malloc(MAXNUM * sizeof(u_char *));
if (!SINGL_FLD)
linebuf = malloc(MAXLLEN);
}
- bufend = buffer + BUFSIZE - 1;
+ bufend = buffer + BUFSIZE;
if (binno >= 0) {
tfiles.top = infiles.top + nfiles;
get = getnext;
-/* $OpenBSD: msort.c,v 1.1 1997/01/20 19:39:53 millert Exp $ */
+/* $OpenBSD: msort.c,v 1.2 1997/01/22 06:43:53 millert Exp $ */
/*-
* Copyright (c) 1993
#if 0
static char sccsid[] = "@(#)msort.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: msort.c,v 1.1 1997/01/20 19:39:53 millert Exp $";
+static char rcsid[] = "$OpenBSD: msort.c,v 1.2 1997/01/22 06:43:53 millert Exp $";
#endif
#endif /* not lint */
int c, i, j;
union f_handle dummy = {0};
struct mfile *flist[16], *cfile;
+
for (i = j = 0; i < nfiles; i++) {
cfile = (MFILE *) (buffer +
i * LALIGN(MAXLLEN + sizeof(TMFILE)));
}
j++;
}
- cfile = cfilebuf;
- cfile->flno = flist[0]->flno;
- cfile->end = cfile->rec->data + MAXLLEN;
- while (nfiles) {
- for (c = 1; c == 1;) {
- if (EOF == (c = get(cfile->flno, dummy, nfiles,
- cfile->rec, cfile->end, ftbl))) {
- put(flist[0]->rec, outfp);
- memmove(flist, flist + 1,
- sizeof(MFILE *) * (--nfiles));
- cfile->flno = flist[0]->flno;
- break;
+ if (nfiles > 0) {
+ cfile = cfilebuf;
+ cfile->flno = flist[0]->flno;
+ cfile->end = cfile->rec->data + MAXLLEN;
+ while (nfiles) {
+ for (c = 1; c == 1;) {
+ if (EOF == (c = get(cfile->flno, dummy, nfiles,
+ cfile->rec, cfile->end, ftbl))) {
+ put(flist[0]->rec, outfp);
+ memmove(flist, flist + 1,
+ sizeof(MFILE *) * (--nfiles));
+ cfile->flno = flist[0]->flno;
+ break;
+ }
+ if (!(c = insert(flist, &cfile, nfiles, DELETE)))
+ put(cfile->rec, outfp);
}
- if (!(c = insert(flist, &cfile, nfiles, DELETE)))
- put(cfile->rec, outfp);
- }
+ }
}
}