mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-11 17:04:19 +01:00
Merge from Lite2 (note: needs checking by somebody who understands join)
This commit is contained in:
parent
df3f5d9dd5
commit
6f0a860fc1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=23694
@ -42,7 +42,7 @@ static char copyright[] =
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)join.c 8.3 (Berkeley) 4/16/94";
|
||||
static char sccsid[] = "@(#)join.c 8.6 (Berkeley) 5/4/95";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -53,6 +53,7 @@ static char sccsid[] = "@(#)join.c 8.3 (Berkeley) 4/16/94";
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/*
|
||||
* There's a structure per input file which encapsulates the state of the
|
||||
@ -288,6 +289,10 @@ slurp(F)
|
||||
F->setalloc * sizeof(LINE))) == NULL)
|
||||
err(1, NULL);
|
||||
memset(F->set + cnt, 0, 50 * sizeof(LINE));
|
||||
|
||||
/* re-set lastlp in case it moved */
|
||||
if (lastlp != NULL)
|
||||
lastlp = &F->set[F->setcnt - 1];
|
||||
}
|
||||
|
||||
/*
|
||||
@ -310,7 +315,7 @@ slurp(F)
|
||||
if ((bp = fgetln(F->fp, &len)) == NULL)
|
||||
return;
|
||||
if (lp->linealloc <= len + 1) {
|
||||
lp->linealloc += MAX(100, len + 1);
|
||||
lp->linealloc += MAX(100, len + 1 - lp->linealloc);
|
||||
if ((lp->line =
|
||||
realloc(lp->line, lp->linealloc)) == NULL)
|
||||
err(1, NULL);
|
||||
@ -353,7 +358,7 @@ cmp(lp1, fieldno1, lp2, fieldno2)
|
||||
u_long fieldno1, fieldno2;
|
||||
{
|
||||
if (lp1->fieldcnt <= fieldno1)
|
||||
return (lp2->fieldcnt < fieldno2 ? 0 : 1);
|
||||
return (lp2->fieldcnt <= fieldno2 ? 0 : 1);
|
||||
if (lp2->fieldcnt <= fieldno2)
|
||||
return (-1);
|
||||
return (strcmp(lp1->fields[fieldno1], lp2->fields[fieldno2]));
|
||||
@ -473,7 +478,7 @@ fieldarg(option)
|
||||
u_long fieldno;
|
||||
char *end, *token;
|
||||
|
||||
while ((token = strsep(&option, " \t")) != NULL) {
|
||||
while ((token = strsep(&option, ", \t")) != NULL) {
|
||||
if (*token == '\0')
|
||||
continue;
|
||||
if (token[0] != '1' && token[0] != '2' || token[1] != '.')
|
||||
|
Loading…
Reference in New Issue
Block a user