71 lines
1.7 KiB
Text
71 lines
1.7 KiB
Text
$NetBSD: patch-aj,v 1.3 2006/09/17 01:25:18 christos Exp $
|
|
|
|
--- src/lid.c.orig 2006-07-21 22:43:25.000000000 -0400
|
|
+++ src/lid.c 2006-09-16 21:23:15.000000000 -0400
|
|
@@ -31,7 +31,6 @@
|
|
#include <dirname.h>
|
|
#include <unistd.h>
|
|
#include <termios.h>
|
|
-#include <alloca.h>
|
|
#include <regex.h>
|
|
#include <xalloc.h>
|
|
#include <pathmax.h>
|
|
@@ -538,10 +537,11 @@
|
|
void
|
|
report_grep (char const *name, struct file_link **flinkv)
|
|
{
|
|
- char line[1<<020];
|
|
+ char *line = xmalloc(BUFSIZ);
|
|
+ size_t line_len = BUFSIZ;
|
|
char const *pattern = 0;
|
|
regex_t compiled;
|
|
- char *file_name = alloca (PATH_MAX);
|
|
+ char file_name[PATH_MAX];
|
|
|
|
if (key_style == ks_pattern)
|
|
{
|
|
@@ -573,8 +573,17 @@
|
|
continue;
|
|
}
|
|
|
|
- while (fgets (line + 1, sizeof (line) - 1, source_FILE))
|
|
+ while (fgets (line + 1, line_len - 1, source_FILE))
|
|
{
|
|
+ size_t len;
|
|
+ while ((len = strlen(line)) == line_len - 1 &&
|
|
+ line[line_len - 2] != '\n')
|
|
+ {
|
|
+ line = xrealloc(line, line_len + BUFSIZ);
|
|
+ line_len += BUFSIZ;
|
|
+ if (fgets(line + len, BUFSIZ, source_FILE) == NULL)
|
|
+ break;
|
|
+ }
|
|
line_number++;
|
|
if (pattern)
|
|
{
|
|
@@ -589,6 +598,7 @@
|
|
}
|
|
fclose (source_FILE);
|
|
}
|
|
+ free(line);
|
|
}
|
|
|
|
static char **
|
|
@@ -800,7 +810,7 @@
|
|
{
|
|
char pattern[BUFSIZ];
|
|
unsigned int count;
|
|
- char *file_name = alloca (PATH_MAX);
|
|
+ char file_name[PATH_MAX];
|
|
char *eol;
|
|
|
|
if (fgets (pattern, sizeof (pattern), stdin) == 0)
|
|
@@ -1368,7 +1378,7 @@
|
|
continue;
|
|
}
|
|
/* march down both strings as long as we match */
|
|
- while (*++name == *++line)
|
|
+ while (*name != '\0' && *++name == *++line)
|
|
;
|
|
/* is this the end of `name', is there a word delimiter ?? */
|
|
if (*name == '\0' && !IS_ALNUM (*line))
|