* src/SDCCmain.c (linkEdit): Added runtime path detection to the mcs51 port.
[fw/sdcc] / src / SDCCmacro.c
index 49db2a0e3a83b73dcfca08a1a8fa3e69c71e0326..4bc7ce431941777cbc4bd27cce6f7f539785e625 100644 (file)
@@ -26,7 +26,7 @@
 
 enum 
   {
-    MAX_STRING_LENGTH  = FILENAME_MAX,
+    MAX_STRING_LENGTH  = PATH_MAX,
     MAX_MACRO_NAME_LENGTH = 128
   };
 
@@ -36,7 +36,9 @@ _evalMacros(char *apinto, hTab *pvals, const char *pfrom)
   bool fdidsomething = FALSE;
   char *pinto = apinto;
 
-  assert(pinto && pvals && pfrom);
+  assert(pinto);
+  assert(pvals);
+  assert(pfrom);
 
   while (*pfrom)
     {
@@ -67,8 +69,6 @@ _evalMacros(char *apinto, hTab *pvals, const char *pfrom)
              wassertl (0, "Invalid macro name");
             }
 
-          printf("Mapping %s to \"%s\"\n", name, pval);
-
           /* Replace */
           strcpy(pinto, pval);
           pinto += strlen(pval);
@@ -108,7 +108,7 @@ mvsprintf(hTab *pvals, const char *pformat, va_list ap)
   _evalMacros(ainto, pvals, atmp);
 
   /* Return a copy of the evaluated string. */
-  return gc_strdup(ainto);
+  return Safe_strdup(ainto);
 }
 
 char *msprintf(hTab *pvals, const char *pformat, ...)
@@ -124,3 +124,19 @@ char *msprintf(hTab *pvals, const char *pformat, ...)
 
   return pret;
 }
+
+void
+mfprintf(FILE *fp, hTab *pvals, const char *pformat, ...)
+{
+  va_list ap;
+  char *p;
+
+  va_start(ap, pformat);
+
+  p = mvsprintf(pvals, pformat, ap);
+
+  va_end(ap);
+
+  fputs(p, fp);
+  Safe_free(p);
+}