* src/pic16/gen.c (genNearPointerSet): fixed handling of literals
[fw/sdcc] / src / cdbFile.c
index 3f7906a9a1c4555f63ec2ed6556adb670d440ed6..ccfa1f3af3e6b9417da042eafe982a9fa3f09009 100644 (file)
@@ -45,6 +45,33 @@ DEBUGFILE cdbDebugFile =
 FILE *cdbFilePtr = NULL;
 char *cdbModuleName = NULL;
 
+/******************************************************************
+ * spacesToUnderscores - replace all non alpha-numerics with
+ * underscores
+ *
+ *
+ *****************************************************************/
+
+static char *
+spacesToUnderscores (char *dest, const char *src, size_t len)
+{
+  unsigned int i;
+  char *p;
+
+  assert(dest != NULL);
+  assert(src != NULL);
+  assert(len > 0);
+
+  --len;
+  for (p = dest, i = 0; *src != '\0' && i < len; ++src, ++i) {
+    *p++ = (isspace((unsigned char)*src) || (*src == '-')) ? '_' : *src;
+  }
+  *p = '\0';
+
+  return dest;
+}
+
+
 /******************************************************************
  *
  *
@@ -127,6 +154,7 @@ int cdbWriteEndFunction(symbol *pSym, iCode *ic, int offset)
       sprintf (debugSym, "C$%s$%d$%d$%d",
               FileBaseName (ic->filename), pSym->lastLine,
               ic->level, ic->block);
+      spacesToUnderscores (debugSym, debugSym, sizeof (debugSym));
       emitDebuggerSymbol (debugSym);
     }
 
@@ -263,6 +291,7 @@ int cdbWriteCLine(iCode *ic)
   sprintf (debugSym, "C$%s$%d$%d$%d", 
           FileBaseName (ic->filename), ic->lineno,
           ic->level, ic->block);
+  spacesToUnderscores (debugSym, debugSym, sizeof (debugSym));
   emitDebuggerSymbol (debugSym);
 
   return 1;