summaryrefslogtreecommitdiff
path: root/devel/id-utils/patches/patch-ar
blob: 868074e41e56807eb69f35528ea0ab93911df56a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
$NetBSD: patch-ar,v 1.1 2002/04/03 16:27:03 joda Exp $

--- src/lid.c~	Wed Apr  3 15:02:41 2002
+++ src/lid.c	Wed Apr  3 16:01:38 2002
@@ -532,7 +532,8 @@
 void
 report_grep (char const *name, struct file_link **flinkv)
 {
-  char line[BUFSIZ];
+  char *line = xmalloc(BUFSIZ);
+  size_t line_len = BUFSIZ;
   char const *pattern = 0;
   regex_t compiled;
   int line_number;
@@ -568,8 +569,14 @@
         }
 
       line_number = 0;
-      while (fgets (&line[1], sizeof (line) - 1, gid_FILE))
+      while (fgets (line + 1, line_len - 1, gid_FILE))
 	{
+	  while(strlen(line) == line_len - 1 && line[line_len - 2] != '\n') {
+	    line = xrealloc(line, line_len + BUFSIZ);
+	    line_len += BUFSIZ;
+	    if(fgets(line + strlen(line), BUFSIZ, gid_FILE) == NULL)
+	      break;
+	  }
 	  line_number++;
 	  if (pattern)
 	    {
@@ -585,6 +592,7 @@
 	}
       fclose (gid_FILE);
     }
+  free(line);
 }
 
 void
@@ -1314,7 +1322,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))