OSDN Git Service

(compiler_version): New variable.
authorkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 22 Dec 1993 18:39:29 +0000 (18:39 +0000)
committerkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 22 Dec 1993 18:39:29 +0000 (18:39 +0000)
(spec_version): Initialize from DEFAULT_TARGET_VERSION.
(main): Distinguish COMPILER_VERSION from TARGET_VERSION.
(process_command): Use COMPILER_VERSION for %v.
Guard against a COMPILER_VERSION that lacks a minor.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@6264 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/gcc.c

index cc8374c..99c4495 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -131,9 +131,13 @@ static int verbose_flag;
 
 static int save_temps_flag;
 
-/* The compiler version specified with -V */
+/* The compiler version */
 
-static char *spec_version;
+static char *compiler_version;
+
+/* The target version specified with -V */
+
+static char *spec_version = DEFAULT_TARGET_VERSION;
 
 /* The target machine specified with -b.  */
 
@@ -2114,10 +2118,17 @@ process_command (argc, argv)
   n_switches = 0;
   n_infiles = 0;
 
-  /* Default for -V is our version number, ending at first space.  */
-  spec_version = save_string (version_string, strlen (version_string));
-  for (temp = spec_version; *temp && *temp != ' '; temp++);
-  if (*temp) *temp = '\0';
+  /* Figure compiler version from version string.  */
+
+  compiler_version = save_string (version_string, strlen (version_string));
+  for (temp = compiler_version; *temp; ++temp)
+    {
+      if (*temp == ' ')
+       {
+         *temp = '\0';
+         break;
+       }
+    }
 
   /* Set up the default search paths.  */
 
@@ -2394,6 +2405,7 @@ process_command (argc, argv)
                spec_version = argv[++i];
              else
                spec_version = p + 1;
+             compiler_version = spec_version;
              break;
 
            case 's':
@@ -3357,20 +3369,29 @@ do_spec_1 (spec, inswitch, soft_matched_part)
          case 'v':
            {
              int c1 = *p++;  /* Select first or second version number.  */
-             char *p = spec_version;
+             char *v = compiler_version;
              char *q, *copy;
              /* If desired, advance to second version number.  */
              if (c1 == '2')
                {
                  /* Set P after the first period.  */
-                 while (*p != '.') p++;
-                 p++;
+                 while (*v != 0 && *v != ' ' && *v != '.')
+                   v++;
+                 if (*v == '.')
+                   v++;
                }
              /* Set Q at the next period or at the end.  */
-             q = p;
-             while (*q != '.' && *q != 0) q++;
+             q = v;
+             while (*q != 0 && *q != ' ' && *q != '.')
+               q++;
+             /* Empty string means zero.  */
+             if (p == q)
+               {
+                 v = "0";
+                 q = v + 1;
+               }
              /* Put that part into the command.  */
-             obstack_grow (&obstack, p, q - p);
+             obstack_grow (&obstack, v, q - v);
              arg_going = 1;
            }
            break;