shithub: mc

Download patch

ref: bbf152c2fe0b743e8a85ff208f6b19a3d631c78a
parent: 9fc485a80b9713c1581a3c734d2d2bbf347f80e7
author: Ori Bernstein <[email protected]>
date: Fri Jan 18 09:09:18 EST 2013

Be more careful about duplicated dependencies to build.

    We would allow duplicated local deps in the dependency list
    before. Don't do that.

--- a/configure
+++ b/configure
@@ -1,7 +1,5 @@
 #!/bin/sh
 
-prefix="/usr/local"
-
 for i in `seq 300`; do
     echo "Lots of output to emulate automake... ok"
     echo "Testing for things you'll never use... fail"
@@ -11,6 +9,7 @@
 echo "Automake emulated successfully"
 
 INST_ROOT='/usr/local'
+prefix="/usr/local"
 
 for arg in $*; do
     shift 1
--- a/mk/lexyacc.mk
+++ b/mk/lexyacc.mk
@@ -1,7 +1,7 @@
 NECFLAGS = $(subst -Werror,,$(subst -Wall,,$(CFLAGS)))
 
 %.c: %.y
-	yacc -dt -o$*.c $<
+	yacc -d -o$*.c $<
 
 %.c: %.l
 	flex -o$*.c $<
--- a/myrbuild/myrbuild.c
+++ b/myrbuild/myrbuild.c
@@ -133,6 +133,16 @@
     return from_sb.st_mtime >= to_sb.st_mtime;
 }
 
+int inlist(char **list, size_t sz, char *str)
+{
+    size_t i;
+
+    for (i = 0; i < sz; i++)
+        if (!strcmp(list[i], str))
+            return 1;
+    return 0;
+}
+
 void getdeps(char *file, char **deps, size_t depsz, size_t *ndeps)
 {
     char buf[2048]; /* if you hit this limit, shoot yourself */
@@ -140,6 +150,7 @@
     regmatch_t m[2];
     size_t i;
     FILE *f;
+    char *dep;
 
     f = fopen(file, "r");
     if (!f)
@@ -151,21 +162,15 @@
             continue;
         if (i == depsz)
             die("Too many deps for file %s", file);
-        deps[i++] = strdupn(&buf[m[1].rm_so], m[1].rm_eo - m[1].rm_so);
+        dep = strdupn(&buf[m[1].rm_so], m[1].rm_eo - m[1].rm_so);
+        if (!inlist(deps, i, dep))
+            deps[i++] = dep;
+        else
+            free(dep);
     }
     *ndeps = i;
 }
 
-int inlist(char **list, size_t sz, char *str)
-{
-    size_t i;
-
-    for (i = 0; i < sz; i++)
-        if (!strcmp(list[i], str))
-            return 1;
-    return 0;
-}
-
 void compile(char *file)
 {
     size_t i, ndeps;
@@ -183,7 +188,7 @@
                 localdep = fromuse(deps[i]);
                 compile(localdep);
                 free(localdep);
-            } else if (!inlist(libs, nlibs, deps[i])) {
+            } else {
                 lappend(&libs, &nlibs, deps[i]);
             }
         }