changeset 1838:47fe4b779813 draft

Patch from Tristan Van Berkom to fix bug preventing ccwrap calling raw++ for g++
author Rob Landley <rob@landley.net>
date Sun, 17 Jan 2016 11:41:47 -0600
parents 60ca4cb1ba55
children c8293b3ab81f
files sources/toys/ccwrap.c
diffstat 1 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/sources/toys/ccwrap.c	Mon Jan 11 17:37:20 2016 -0600
+++ b/sources/toys/ccwrap.c	Sun Jan 17 11:41:47 2016 -0600
@@ -157,7 +157,7 @@
 // Read the command line arguments and work out status
 int main(int argc, char *argv[])
 {
-  char *topdir, *ccprefix, *dynlink, *cc, *temp, **keepv, **hdr, **outv;
+  char *topdir, *ccprefix, *dynlink, *cc = 0, *temp, **keepv, **hdr, **outv;
   int i, keepc, srcfiles, flags, outc;
   struct dlist *libs = 0;
 
@@ -237,7 +237,7 @@
   }
   // We want to strip off the bin/ but the path we followed can end with
   // a symlink, so append .. instead.
-  strcpy(++temp, "..");
+  strcpy(++temp, "/..");
   topdir = realpath(topdir, 0);
 
   // Add our binary's directory and the tools directory to $PATH so gcc's
@@ -252,11 +252,11 @@
   // Override header/library search path with environment variable?
   temp = getenv("CCWRAP_TOPDIR");
   if (!temp) {
-    cc = xmprintf("%sCCWRAP_TOPDIR", ccprefix);
+    char *icc = xmprintf("%sCCWRAP_TOPDIR", ccprefix);
 
-    for (i=0; cc[i]; i++) if (cc[i] == '-') cc[i]='_';
-    temp = getenv(cc);
-    free(cc);
+    for (i=0; icc[i]; i++) if (icc[i] == '-') icc[i]='_';
+    temp = getenv(icc);
+    free(icc);
   }
   if (temp) {
     free(topdir);
@@ -264,7 +264,7 @@
   }
 
   // Name of the C compiler we're wrapping.
-  cc = getenv("CCWRAP_CC");
+  if (!cc) cc = getenv("CCWRAP_CC");
   if (!cc) cc = "rawcc";
 
   // Does toolchain have a shared libcc?