gdb/fortran: Cleanup code for parsing logical constants
[deliverable/binutils-gdb.git] / gdb / f-exp.y
index d70c66474c0eff698ea83a6c17d563afc2c80b4c..704585e63ae3bd38fffe46860608d0a8e47d9bbd 100644 (file)
@@ -807,19 +807,22 @@ static const struct token dot_ops[] =
   { NULL, 0, BINOP_END }
 };
 
-struct f77_boolean_val 
+/* Holds the Fortran representation of a boolean, and the integer value we
+   substitute in when one of the matching strings is parsed.  */
+struct f77_boolean_val
 {
+  /* The string representing a Fortran boolean.  */
   const char *name;
+
+  /* The integer value to replace it with.  */
   int value;
-}; 
+};
 
-static const struct f77_boolean_val boolean_values[]  = 
+/* The set of Fortran booleans.  These are matched case insensitively.  */
+static const struct f77_boolean_val boolean_values[]  =
 {
   { ".true.", 1 },
-  { ".TRUE.", 1 },
-  { ".false.", 0 },
-  { ".FALSE.", 0 },
-  { NULL, 0 }
+  { ".false.", 0 }
 };
 
 static const struct token f77_keywords[] = 
@@ -931,19 +934,19 @@ yylex (void)
   prev_lexptr = lexptr;
  
   tokstart = lexptr;
-  
-  /* First of all, let us make sure we are not dealing with the 
+
+  /* First of all, let us make sure we are not dealing with the
      special tokens .true. and .false. which evaluate to 1 and 0.  */
-  
+
   if (*lexptr == '.')
-    { 
-      for (int i = 0; boolean_values[i].name != NULL; i++)
+    {
+      for (int i = 0; i < ARRAY_SIZE (boolean_values); i++)
        {
-         if (strncmp (tokstart, boolean_values[i].name,
-                      strlen (boolean_values[i].name)) == 0)
+         if (strncasecmp (tokstart, boolean_values[i].name,
+                          strlen (boolean_values[i].name)) == 0)
            {
-             lexptr += strlen (boolean_values[i].name); 
-             yylval.lval = boolean_values[i].value; 
+             lexptr += strlen (boolean_values[i].name);
+             yylval.lval = boolean_values[i].value;
              return BOOLEAN_LITERAL;
            }
        }
This page took 0.025168 seconds and 4 git commands to generate.