* src/SDCCmain.c (linkEdit): Added runtime path detection to the mcs51 port.
[fw/sdcc] / src / SDCCmacro.c
index c93a11bbe842f2601d8b3e38cfa8644187f4a805..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)
     {
@@ -106,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, ...)
@@ -122,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);
+}