See Changelog 1.204
[fw/sdcc] / src / SDCCmain.c
index 8b41cce77ba3cd4279f6950910878a654f610540..005181240a880a8fed9e745a949d784a2cc1d439 100644 (file)
@@ -87,7 +87,7 @@ int ds390_jammed = 0;
 
 // Globally accessible scratch buffer for file names.
 char scratchFileName[PATH_MAX];
-char buffer[PATH_MAX];
+char buffer[PATH_MAX * 2];
 
 // In MSC VC6 default search path for exe's to path for this
 
@@ -115,6 +115,7 @@ char DefaultExePath[128];
 #define OPTION_DATA_LOC                "--data-loc"
 #define OPTION_CODE_LOC                "--code-loc"
 #define OPTION_IDATA_LOC       "--idata-loc"
+#define OPTION_NO_LABEL_OPT     "--nolabelopt"
 #define OPTION_NO_LOOP_INV     "--noinvariant"
 #define OPTION_NO_LOOP_IND     "--noinduction"
 #define OPTION_LESS_PEDANTIC   "--lesspedantic"
@@ -152,6 +153,7 @@ optionsTable[] = {
     { 0,    "--stack-10bit",        &options.stack10bit, "use the 10bit stack for ds390 (default)" },
     { 0,    "--xstack",             &options.useXstack, "Use external stack" },
     { 0,    OPTION_NO_GCSE,         NULL, "Disable the GCSE optimisation" },
+    { 0,    OPTION_NO_LABEL_OPT,    NULL, "Disable label optimisation" },
     { 0,    OPTION_NO_LOOP_INV,     NULL, "Disable optimisation of invariants" },
     { 0,    OPTION_NO_LOOP_IND,     NULL, NULL },
     { 0,    "--nojtbound",          &optimize.noJTabBoundary, "Don't generate boundary check for jump tables" },
@@ -391,16 +393,14 @@ printVersionInfo ()
           " (CYGWIN)\n"
 #elif defined __MINGW32__
           " (MINGW32) \n"
-#else
-#  ifdef __DJGPP__
+#elif defined __DJGPP__
           " (DJGPP) \n"
-#  else
-#    if defined(_MSC_VER)
-          " (WIN32) \n"
-#    else
+#elif defined(_MSC_VER)
+          " (MSVC) \n"
+#elif defined(__BORLANDC__)
+          " (BORLANDC) \n"
+#else
           " (UNIX) \n"
-#    endif
-#  endif
 #endif
 
           ,VersionString
@@ -560,7 +560,7 @@ processFile (char *s)
        }
 
       /* copy the file name into the buffer */
-      strncpyz (buffer, s, PATH_MAX);
+      strncpyz (buffer, s, sizeof(buffer));
 
       /* get rid of the "."-extension */
 
@@ -957,6 +957,12 @@ parseCmdLine (int argc, char **argv)
              continue;
            }
 
+         if (strcmp (argv[i], OPTION_NO_LABEL_OPT) == 0)
+           {
+             optimize.label4 = 0;
+             continue;
+           }
+
          if (strcmp (argv[i], OPTION_NO_LOOP_IND) == 0)
            {
              optimize.loopInduction = 0;
@@ -1032,7 +1038,8 @@ parseCmdLine (int argc, char **argv)
                 char *p;
 
                 /* copy the file name into the buffer */
-                strncpyz(buffer, getStringArg("-o", argv, &i, argc), PATH_MAX);
+                strncpyz(buffer, getStringArg("-o", argv, &i, argc), 
+                        sizeof(buffer));
                 /* point to last character */
                 p = buffer + strlen (buffer) - 1;
                 if (*p == DIR_SEPARATOR_CHAR)
@@ -1213,7 +1220,7 @@ parseCmdLine (int argc, char **argv)
           char *objectName;
          size_t bufSize;
 
-          strncpyz (buffer, relFiles[0], PATH_MAX);
+          strncpyz (buffer, relFiles[0], sizeof(buffer));
           /* remove extension (it must be .rel) */
           *strrchr (buffer, '.') = '\0';
           /* remove path */
@@ -1422,11 +1429,11 @@ linkEdit (char **envp)
     {
       char buffer2[PATH_MAX];
       buildCmdLine (buffer2, port->linker.cmd, dstFileName, scratchFileName, NULL, NULL);
-      buildCmdLine2 (buffer, buffer2, PATH_MAX);
+      buildCmdLine2 (buffer, buffer2, sizeof(buffer));
     }
   else
     {
-      buildCmdLine2 (buffer, port->linker.mcmd, PATH_MAX);
+      buildCmdLine2 (buffer, port->linker.mcmd, sizeof(buffer));
     }
 
   system_ret = my_system (buffer);
@@ -1501,8 +1508,9 @@ assemble (char **envp)
         strncpyz (scratchFileName, fullDstFileName, sizeof(scratchFileName));
     } else {
         /* the assembled file gets the name of the first modul */
-        strncpyz (scratchFileName, dstFileName, PATH_MAX);
-        strncatz (scratchFileName, port->linker.rel_ext, PATH_MAX);
+        strncpyz (scratchFileName, dstFileName, sizeof(scratchFileName));
+        strncatz (scratchFileName, port->linker.rel_ext, 
+                 sizeof(scratchFileName));
     }
 
     if (port->assembler.do_assemble) {
@@ -1615,7 +1623,7 @@ preProcess (char **envp)
       if (options.verbose)
        printf ("sdcc: Calling preprocessor...\n");
 
-      buildCmdLine2 (buffer, _preCmd, PATH_MAX);
+      buildCmdLine2 (buffer, _preCmd, sizeof(buffer));
 
       if (my_system (buffer))
        {
@@ -1713,7 +1721,7 @@ _discoverPaths (const char *argv0)
     {
       getPathDifference (buffer, PREFIX, BINDIR);
       strncpyz (scratchFileName, getenv (SDCCDIR_NAME), sizeof(scratchFileName));
-      strncatz (scratchFileName, buffer, PATH_MAX);
+      strncatz (scratchFileName, buffer, sizeof(scratchFileName));
       setMainValue ("bindir", scratchFileName);
       ExePathList[0] = Safe_strdup (scratchFileName);
     }