From f5a86a83d3bc325abd27ecbba59beddc15ad0da4 Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Fri, 12 Jun 2009 10:46:25 -0400
Subject: ENH: Use KWSys String strcasecmp to parse Fortran

This replaces the Fortran dependency parser source's custom strcasecmp
implementation with one from KWSys String.  It removes duplicate code
and avoids a Borland warning about inlining functions with 'while'.
---
 Source/cmDependsFortranParser.cxx     | 515 +++++++++++++++++-----------------
 Source/cmDependsFortranParser.y       |  53 +---
 Source/cmDependsFortranParserTokens.h |  29 +-
 3 files changed, 274 insertions(+), 323 deletions(-)

diff --git a/Source/cmDependsFortranParser.cxx b/Source/cmDependsFortranParser.cxx
index 6bc90d6..f294d77 100644
--- a/Source/cmDependsFortranParser.cxx
+++ b/Source/cmDependsFortranParser.cxx
@@ -1,14 +1,14 @@
-/* A Bison parser, made by GNU Bison 2.3.  */
+/* A Bison parser, made by GNU Bison 2.4.1.  */
 
 /* Skeleton implementation for Bison's Yacc-like parsers in C
 
-   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+      Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
 
-   This program is free software; you can redistribute it and/or modify
+   This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,9 +16,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* As a special exception, you may create a larger work that contains
    part or all of the Bison parser skeleton and distribute that work
@@ -47,7 +45,7 @@
 #define YYBISON 1
 
 /* Bison version.  */
-#define YYBISON_VERSION "2.3"
+#define YYBISON_VERSION "2.4.1"
 
 /* Skeleton name.  */
 #define YYSKELETON_NAME "yacc.c"
@@ -55,89 +53,28 @@
 /* Pure parsers.  */
 #define YYPURE 1
 
+/* Push parsers.  */
+#define YYPUSH 0
+
+/* Pull parsers.  */
+#define YYPULL 1
+
 /* Using locations.  */
 #define YYLSP_NEEDED 0
 
 /* Substitute the variable and function names.  */
-#define yyparse cmDependsFortran_yyparse
-#define yylex   cmDependsFortran_yylex
-#define yyerror cmDependsFortran_yyerror
-#define yylval  cmDependsFortran_yylval
-#define yychar  cmDependsFortran_yychar
-#define yydebug cmDependsFortran_yydebug
-#define yynerrs cmDependsFortran_yynerrs
-
-
-/* Tokens.  */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
-   /* Put the tokens into the symbol table, so that GDB and other debuggers
-      know about them.  */
-   enum yytokentype {
-     EOSTMT = 258,
-     ASSIGNMENT_OP = 259,
-     GARBAGE = 260,
-     CPP_INCLUDE = 261,
-     F90PPR_INCLUDE = 262,
-     COCO_INCLUDE = 263,
-     F90PPR_DEFINE = 264,
-     CPP_DEFINE = 265,
-     F90PPR_UNDEF = 266,
-     CPP_UNDEF = 267,
-     CPP_IFDEF = 268,
-     CPP_IFNDEF = 269,
-     CPP_IF = 270,
-     CPP_ELSE = 271,
-     CPP_ELIF = 272,
-     CPP_ENDIF = 273,
-     F90PPR_IFDEF = 274,
-     F90PPR_IFNDEF = 275,
-     F90PPR_IF = 276,
-     F90PPR_ELSE = 277,
-     F90PPR_ELIF = 278,
-     F90PPR_ENDIF = 279,
-     COMMA = 280,
-     DCOLON = 281,
-     CPP_TOENDL = 282,
-     UNTERMINATED_STRING = 283,
-     STRING = 284,
-     WORD = 285
-   };
-#endif
-/* Tokens.  */
-#define EOSTMT 258
-#define ASSIGNMENT_OP 259
-#define GARBAGE 260
-#define CPP_INCLUDE 261
-#define F90PPR_INCLUDE 262
-#define COCO_INCLUDE 263
-#define F90PPR_DEFINE 264
-#define CPP_DEFINE 265
-#define F90PPR_UNDEF 266
-#define CPP_UNDEF 267
-#define CPP_IFDEF 268
-#define CPP_IFNDEF 269
-#define CPP_IF 270
-#define CPP_ELSE 271
-#define CPP_ELIF 272
-#define CPP_ENDIF 273
-#define F90PPR_IFDEF 274
-#define F90PPR_IFNDEF 275
-#define F90PPR_IF 276
-#define F90PPR_ELSE 277
-#define F90PPR_ELIF 278
-#define F90PPR_ENDIF 279
-#define COMMA 280
-#define DCOLON 281
-#define CPP_TOENDL 282
-#define UNTERMINATED_STRING 283
-#define STRING 284
-#define WORD 285
-
-
+#define yyparse         cmDependsFortran_yyparse
+#define yylex           cmDependsFortran_yylex
+#define yyerror         cmDependsFortran_yyerror
+#define yylval          cmDependsFortran_yylval
+#define yychar          cmDependsFortran_yychar
+#define yydebug         cmDependsFortran_yydebug
+#define yynerrs         cmDependsFortran_yynerrs
 
 
 /* Copy the first part of user declarations.  */
+
+/* Line 189 of yacc.c  */
 #line 1 "cmDependsFortranParser.y"
 
 /*=========================================================================
@@ -187,6 +124,8 @@ Modify cmDependsFortranParser.cxx:
 #include "cmDependsFortranParser.h" /* Interface to parser object.  */
 #include "cmDependsFortranParserTokens.h" /* Need YYSTYPE for YY_DECL.  */
 
+#include <cmsys/String.h>
+
 /* Configure the parser to use a lexer object.  */
 #define YYPARSE_PARAM yyscanner
 #define YYLEX_PARAM yyscanner
@@ -204,59 +143,10 @@ static void cmDependsFortranError(yyscan_t yyscanner, const char* message)
   cmDependsFortranParser_Error(parser, message);
 }
 
-static char charmap[] = {
-    '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
-    '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
-    '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
-    '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
-    '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
-    '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
-    '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
-    '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
-    '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
-    '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
-    '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
-    '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
-    '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
-    '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
-    '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
-    '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
-    '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
-    '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
-    '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
-    '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
-    '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
-    '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
-    '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
-    '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
-    '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
-    '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
-    '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327',
-    '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337',
-    '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
-    '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
-    '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
-    '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377'
-};
-
-inline int strcasecmpCM(const char *s1, const char *s2) 
-{
-  const char *cm = charmap;
-  unsigned char const* us1 = reinterpret_cast<unsigned char const*>(s1);
-  unsigned char const* us2 = reinterpret_cast<unsigned char const*>(s2);
-  
-  while(cm[*us1] == cm[*us2++])
-    if(*us1++ == '\0') 
-      {
-      return(0);
-      }
-  return(cm[*us1] - cm[*--us2]);
-}
-
 static bool cmDependsFortranParserIsKeyword(const char* word,
                                             const char* keyword)
 {
-  return strcasecmpCM(word, keyword) == 0;
+  return cmsysString_strcasecmp(word, keyword) == 0;
 }
 
 /* Disable some warnings in the generated code.  */
@@ -276,6 +166,9 @@ static bool cmDependsFortranParserIsKeyword(const char* word,
 #endif
 
 
+/* Line 189 of yacc.c  */
+#line 172 "cmDependsFortranParser.cxx"
+
 /* Enabling traces.  */
 #ifndef YYDEBUG
 # define YYDEBUG 0
@@ -294,27 +187,101 @@ static bool cmDependsFortranParserIsKeyword(const char* word,
 # define YYTOKEN_TABLE 0
 #endif
 
+
+/* Tokens.  */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+   /* Put the tokens into the symbol table, so that GDB and other debuggers
+      know about them.  */
+   enum yytokentype {
+     EOSTMT = 258,
+     ASSIGNMENT_OP = 259,
+     GARBAGE = 260,
+     CPP_INCLUDE = 261,
+     F90PPR_INCLUDE = 262,
+     COCO_INCLUDE = 263,
+     F90PPR_DEFINE = 264,
+     CPP_DEFINE = 265,
+     F90PPR_UNDEF = 266,
+     CPP_UNDEF = 267,
+     CPP_IFDEF = 268,
+     CPP_IFNDEF = 269,
+     CPP_IF = 270,
+     CPP_ELSE = 271,
+     CPP_ELIF = 272,
+     CPP_ENDIF = 273,
+     F90PPR_IFDEF = 274,
+     F90PPR_IFNDEF = 275,
+     F90PPR_IF = 276,
+     F90PPR_ELSE = 277,
+     F90PPR_ELIF = 278,
+     F90PPR_ENDIF = 279,
+     COMMA = 280,
+     DCOLON = 281,
+     CPP_TOENDL = 282,
+     UNTERMINATED_STRING = 283,
+     STRING = 284,
+     WORD = 285
+   };
+#endif
+/* Tokens.  */
+#define EOSTMT 258
+#define ASSIGNMENT_OP 259
+#define GARBAGE 260
+#define CPP_INCLUDE 261
+#define F90PPR_INCLUDE 262
+#define COCO_INCLUDE 263
+#define F90PPR_DEFINE 264
+#define CPP_DEFINE 265
+#define F90PPR_UNDEF 266
+#define CPP_UNDEF 267
+#define CPP_IFDEF 268
+#define CPP_IFNDEF 269
+#define CPP_IF 270
+#define CPP_ELSE 271
+#define CPP_ELIF 272
+#define CPP_ENDIF 273
+#define F90PPR_IFDEF 274
+#define F90PPR_IFNDEF 275
+#define F90PPR_IF 276
+#define F90PPR_ELSE 277
+#define F90PPR_ELIF 278
+#define F90PPR_ENDIF 279
+#define COMMA 280
+#define DCOLON 281
+#define CPP_TOENDL 282
+#define UNTERMINATED_STRING 283
+#define STRING 284
+#define WORD 285
+
+
+
+
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 typedef union YYSTYPE
-#line 141 "cmDependsFortranParser.y"
 {
+
+/* Line 214 of yacc.c  */
+#line 94 "cmDependsFortranParser.y"
+
   char* string;
-}
-/* Line 187 of yacc.c.  */
-#line 305 "cmDependsFortranParser.cxx"
-        YYSTYPE;
+
+
+
+/* Line 214 of yacc.c  */
+#line 274 "cmDependsFortranParser.cxx"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
 # define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
 #endif
 
 
-
 /* Copy the second part of user declarations.  */
 
 
-/* Line 216 of yacc.c.  */
-#line 318 "cmDependsFortranParser.cxx"
+/* Line 264 of yacc.c  */
+#line 286 "cmDependsFortranParser.cxx"
 
 #ifdef short
 # undef short
@@ -389,14 +356,14 @@ typedef short int yytype_int16;
 #if (defined __STDC__ || defined __C99__FUNC__ \
      || defined __cplusplus || defined _MSC_VER)
 static int
-YYID (int i)
+YYID (int yyi)
 #else
 static int
-YYID (i)
-    int i;
+YYID (yyi)
+    int yyi;
 #endif
 {
-  return i;
+  return yyi;
 }
 #endif
 
@@ -477,9 +444,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
 /* A type that is properly aligned for any stack member.  */
 union yyalloc
 {
-  yytype_int16 yyss;
-  YYSTYPE yyvs;
-  };
+  yytype_int16 yyss_alloc;
+  YYSTYPE yyvs_alloc;
+};
 
 /* The size of the maximum gap between one aligned stack and the next.  */
 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
@@ -513,12 +480,12 @@ union yyalloc
    elements in the stack, and YYPTR gives the new location of the
    stack.  Advance YYPTR to a properly aligned location for the next
    stack.  */
-# define YYSTACK_RELOCATE(Stack)                                        \
+# define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
     do                                                                  \
       {                                                                 \
         YYSIZE_T yynewbytes;                                            \
-        YYCOPY (&yyptr->Stack, Stack, yysize);                          \
-        Stack = &yyptr->Stack;                                          \
+        YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
+        Stack = &yyptr->Stack_alloc;                                    \
         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
         yyptr += yynewbytes / sizeof (*yyptr);                          \
       }                                                                 \
@@ -618,12 +585,12 @@ static const yytype_int8 yyrhs[] =
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
 static const yytype_uint16 yyrline[] =
 {
-       0,   162,   162,   162,   164,   164,   166,   172,   182,   212,
-     223,   236,   247,   254,   260,   266,   272,   278,   283,   288,
-     293,   298,   302,   303,   304,   309,   309,   309,   310,   310,
-     311,   311,   312,   312,   313,   313,   314,   314,   315,   315,
-     316,   316,   317,   317,   318,   318,   321,   322,   323,   324,
-     325,   326,   327
+       0,   115,   115,   115,   117,   117,   119,   125,   135,   165,
+     176,   189,   200,   207,   213,   219,   225,   231,   236,   241,
+     246,   251,   255,   256,   257,   262,   262,   262,   263,   263,
+     264,   264,   265,   265,   266,   266,   267,   267,   268,   268,
+     269,   269,   270,   270,   271,   271,   274,   275,   276,   277,
+     278,   279,   280
 };
 #endif
 
@@ -993,17 +960,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep)
 #if (defined __STDC__ || defined __C99__FUNC__ \
      || defined __cplusplus || defined _MSC_VER)
 static void
-yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
+yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
 #else
 static void
-yy_stack_print (bottom, top)
-    yytype_int16 *bottom;
-    yytype_int16 *top;
+yy_stack_print (yybottom, yytop)
+    yytype_int16 *yybottom;
+    yytype_int16 *yytop;
 #endif
 {
   YYFPRINTF (stderr, "Stack now");
-  for (; bottom <= top; ++bottom)
-    YYFPRINTF (stderr, " %d", *bottom);
+  for (; yybottom <= yytop; yybottom++)
+    {
+      int yybot = *yybottom;
+      YYFPRINTF (stderr, " %d", yybot);
+    }
   YYFPRINTF (stderr, "\n");
 }
 
@@ -1037,11 +1007,11 @@ yy_reduce_print (yyvsp, yyrule)
   /* The symbols being reduced.  */
   for (yyi = 0; yyi < yynrhs; yyi++)
     {
-      fprintf (stderr, "   $%d = ", yyi + 1);
+      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
                        &(yyvsp[(yyi + 1) - (yynrhs)])
                                        );
-      fprintf (stderr, "\n");
+      YYFPRINTF (stderr, "\n");
     }
 }
 
@@ -1321,10 +1291,8 @@ yydestruct (yymsg, yytype, yyvaluep)
         break;
     }
 }
-
 
 /* Prevent warnings from -Wmissing-prototypes.  */
-
 #ifdef YYPARSE_PARAM
 #if defined __STDC__ || defined __cplusplus
 int yyparse (void *YYPARSE_PARAM);
@@ -1343,10 +1311,9 @@ int yyparse ();
 
 
 
-
-/*----------.
-| yyparse.  |
-`----------*/
+/*-------------------------.
+| yyparse or yypush_parse.  |
+`-------------------------*/
 
 #ifdef YYPARSE_PARAM
 #if (defined __STDC__ || defined __C99__FUNC__ \
@@ -1370,74 +1337,75 @@ yyparse ()
 #endif
 #endif
 {
-  /* The look-ahead symbol.  */
+/* The lookahead symbol.  */
 int yychar;
 
-/* The semantic value of the look-ahead symbol.  */
+/* The semantic value of the lookahead symbol.  */
 YYSTYPE yylval;
 
-/* Number of syntax errors so far.  */
-int yynerrs;
+    /* Number of syntax errors so far.  */
+    int yynerrs;
 
-  int yystate;
-  int yyn;
-  int yyresult;
-  /* Number of tokens to shift before error messages enabled.  */
-  int yyerrstatus;
-  /* Look-ahead token as an internal (translated) token number.  */
-  int yytoken = 0;
-#if YYERROR_VERBOSE
-  /* Buffer for error messages, and its allocated size.  */
-  char yymsgbuf[128];
-  char *yymsg = yymsgbuf;
-  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
-#endif
-
-  /* Three stacks and their tools:
-     `yyss': related to states,
-     `yyvs': related to semantic values,
-     `yyls': related to locations.
-
-     Refer to the stacks thru separate pointers, to allow yyoverflow
-     to reallocate them elsewhere.  */
-
-  /* The state stack.  */
-  yytype_int16 yyssa[YYINITDEPTH];
-  yytype_int16 *yyss = yyssa;
-  yytype_int16 *yyssp;
+    int yystate;
+    /* Number of tokens to shift before error messages enabled.  */
+    int yyerrstatus;
 
-  /* The semantic value stack.  */
-  YYSTYPE yyvsa[YYINITDEPTH];
-  YYSTYPE *yyvs = yyvsa;
-  YYSTYPE *yyvsp;
+    /* The stacks and their tools:
+       `yyss': related to states.
+       `yyvs': related to semantic values.
 
+       Refer to the stacks thru separate pointers, to allow yyoverflow
+       to reallocate them elsewhere.  */
 
+    /* The state stack.  */
+    yytype_int16 yyssa[YYINITDEPTH];
+    yytype_int16 *yyss;
+    yytype_int16 *yyssp;
 
-#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
+    /* The semantic value stack.  */
+    YYSTYPE yyvsa[YYINITDEPTH];
+    YYSTYPE *yyvs;
+    YYSTYPE *yyvsp;
 
-  YYSIZE_T yystacksize = YYINITDEPTH;
+    YYSIZE_T yystacksize;
 
+  int yyn;
+  int yyresult;
+  /* Lookahead token as an internal (translated) token number.  */
+  int yytoken;
   /* The variables used to return semantic value and location from the
      action routines.  */
   YYSTYPE yyval;
 
+#if YYERROR_VERBOSE
+  /* Buffer for error messages, and its allocated size.  */
+  char yymsgbuf[128];
+  char *yymsg = yymsgbuf;
+  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
+#endif
+
+#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
 
   /* The number of symbols on the RHS of the reduced rule.
      Keep to zero when no symbol should be popped.  */
   int yylen = 0;
 
+  yytoken = 0;
+  yyss = yyssa;
+  yyvs = yyvsa;
+  yystacksize = YYINITDEPTH;
+
   YYDPRINTF ((stderr, "Starting parse\n"));
 
   yystate = 0;
   yyerrstatus = 0;
   yynerrs = 0;
-  yychar = YYEMPTY;             /* Cause a token to be read.  */
+  yychar = YYEMPTY; /* Cause a token to be read.  */
 
   /* Initialize stack pointers.
      Waste one element of value and location stack
      so that they stay on the same level as the state stack.
      The wasted elements are never initialized.  */
-
   yyssp = yyss;
   yyvsp = yyvs;
 
@@ -1467,7 +1435,6 @@ int yynerrs;
         YYSTYPE *yyvs1 = yyvs;
         yytype_int16 *yyss1 = yyss;
 
-
         /* Each stack pointer address is followed by the size of the
            data in use in that stack, in bytes.  This used to be a
            conditional around just the two extra args, but that might
@@ -1475,7 +1442,6 @@ int yynerrs;
         yyoverflow (YY_("memory exhausted"),
                     &yyss1, yysize * sizeof (*yyssp),
                     &yyvs1, yysize * sizeof (*yyvsp),
-
                     &yystacksize);
 
         yyss = yyss1;
@@ -1498,9 +1464,8 @@ int yynerrs;
           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
         if (! yyptr)
           goto yyexhaustedlab;
-        YYSTACK_RELOCATE (yyss);
-        YYSTACK_RELOCATE (yyvs);
-
+        YYSTACK_RELOCATE (yyss_alloc, yyss);
+        YYSTACK_RELOCATE (yyvs_alloc, yyvs);
 #  undef YYSTACK_RELOCATE
         if (yyss1 != yyssa)
           YYSTACK_FREE (yyss1);
@@ -1511,7 +1476,6 @@ int yynerrs;
       yyssp = yyss + yysize - 1;
       yyvsp = yyvs + yysize - 1;
 
-
       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
                   (unsigned long int) yystacksize));
 
@@ -1521,6 +1485,9 @@ int yynerrs;
 
   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
 
+  if (yystate == YYFINAL)
+    YYACCEPT;
+
   goto yybackup;
 
 /*-----------.
@@ -1529,16 +1496,16 @@ int yynerrs;
 yybackup:
 
   /* Do appropriate processing given the current state.  Read a
-     look-ahead token if we need one and don't already have one.  */
+     lookahead token if we need one and don't already have one.  */
 
-  /* First try to decide what to do without reference to look-ahead token.  */
+  /* First try to decide what to do without reference to lookahead token.  */
   yyn = yypact[yystate];
   if (yyn == YYPACT_NINF)
     goto yydefault;
 
-  /* Not known => get a look-ahead token if don't already have one.  */
+  /* Not known => get a lookahead token if don't already have one.  */
 
-  /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol.  */
+  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
   if (yychar == YYEMPTY)
     {
       YYDPRINTF ((stderr, "Reading a token: "));
@@ -1570,20 +1537,16 @@ yybackup:
       goto yyreduce;
     }
 
-  if (yyn == YYFINAL)
-    YYACCEPT;
-
   /* Count tokens shifted since error; after three, turn off error
      status.  */
   if (yyerrstatus)
     yyerrstatus--;
 
-  /* Shift the look-ahead token.  */
+  /* Shift the lookahead token.  */
   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
 
-  /* Discard the shifted token unless it is eof.  */
-  if (yychar != YYEOF)
-    yychar = YYEMPTY;
+  /* Discard the shifted token.  */
+  yychar = YYEMPTY;
 
   yystate = yyn;
   *++yyvsp = yylval;
@@ -1623,14 +1586,18 @@ yyreduce:
   switch (yyn)
     {
         case 6:
-#line 167 "cmDependsFortranParser.y"
+
+/* Line 1455 of yacc.c  */
+#line 120 "cmDependsFortranParser.y"
     {
     free((yyvsp[(1) - (4)].string));
     }
     break;
 
   case 7:
-#line 173 "cmDependsFortranParser.y"
+
+/* Line 1455 of yacc.c  */
+#line 126 "cmDependsFortranParser.y"
     {
     if (cmDependsFortranParserIsKeyword((yyvsp[(1) - (2)].string), "interface"))
       {
@@ -1643,7 +1610,9 @@ yyreduce:
     break;
 
   case 8:
-#line 183 "cmDependsFortranParser.y"
+
+/* Line 1455 of yacc.c  */
+#line 136 "cmDependsFortranParser.y"
     {
     if (cmDependsFortranParserIsKeyword((yyvsp[(1) - (4)].string), "use"))
       {
@@ -1676,7 +1645,9 @@ yyreduce:
     break;
 
   case 9:
-#line 213 "cmDependsFortranParser.y"
+
+/* Line 1455 of yacc.c  */
+#line 166 "cmDependsFortranParser.y"
     {
     if (cmDependsFortranParserIsKeyword((yyvsp[(1) - (5)].string), "use"))
       {
@@ -1690,7 +1661,9 @@ yyreduce:
     break;
 
   case 10:
-#line 224 "cmDependsFortranParser.y"
+
+/* Line 1455 of yacc.c  */
+#line 177 "cmDependsFortranParser.y"
     {
     if (cmDependsFortranParserIsKeyword((yyvsp[(1) - (7)].string), "use") &&
         cmDependsFortranParserIsKeyword((yyvsp[(3) - (7)].string), "non_intrinsic") )
@@ -1706,7 +1679,9 @@ yyreduce:
     break;
 
   case 11:
-#line 237 "cmDependsFortranParser.y"
+
+/* Line 1455 of yacc.c  */
+#line 190 "cmDependsFortranParser.y"
     {
     if (cmDependsFortranParserIsKeyword((yyvsp[(1) - (4)].string), "include"))
       {
@@ -1720,7 +1695,9 @@ yyreduce:
     break;
 
   case 12:
-#line 248 "cmDependsFortranParser.y"
+
+/* Line 1455 of yacc.c  */
+#line 201 "cmDependsFortranParser.y"
     {
     cmDependsFortranParser* parser =
       cmDependsFortran_yyget_extra(yyscanner);
@@ -1730,7 +1707,9 @@ yyreduce:
     break;
 
   case 13:
-#line 255 "cmDependsFortranParser.y"
+
+/* Line 1455 of yacc.c  */
+#line 208 "cmDependsFortranParser.y"
     {
     cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
     cmDependsFortranParser_RuleDefine(parser, (yyvsp[(2) - (4)].string));
@@ -1739,7 +1718,9 @@ yyreduce:
     break;
 
   case 14:
-#line 261 "cmDependsFortranParser.y"
+
+/* Line 1455 of yacc.c  */
+#line 214 "cmDependsFortranParser.y"
     {
     cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
     cmDependsFortranParser_RuleUndef(parser, (yyvsp[(2) - (4)].string));
@@ -1748,7 +1729,9 @@ yyreduce:
     break;
 
   case 15:
-#line 267 "cmDependsFortranParser.y"
+
+/* Line 1455 of yacc.c  */
+#line 220 "cmDependsFortranParser.y"
     {
     cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
     cmDependsFortranParser_RuleIfdef(parser, (yyvsp[(2) - (4)].string));
@@ -1757,7 +1740,9 @@ yyreduce:
     break;
 
   case 16:
-#line 273 "cmDependsFortranParser.y"
+
+/* Line 1455 of yacc.c  */
+#line 226 "cmDependsFortranParser.y"
     {
     cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
     cmDependsFortranParser_RuleIfndef(parser, (yyvsp[(2) - (4)].string));
@@ -1766,7 +1751,9 @@ yyreduce:
     break;
 
   case 17:
-#line 279 "cmDependsFortranParser.y"
+
+/* Line 1455 of yacc.c  */
+#line 232 "cmDependsFortranParser.y"
     {
     cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
     cmDependsFortranParser_RuleIf(parser);
@@ -1774,7 +1761,9 @@ yyreduce:
     break;
 
   case 18:
-#line 284 "cmDependsFortranParser.y"
+
+/* Line 1455 of yacc.c  */
+#line 237 "cmDependsFortranParser.y"
     {
     cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
     cmDependsFortranParser_RuleElif(parser);
@@ -1782,7 +1771,9 @@ yyreduce:
     break;
 
   case 19:
-#line 289 "cmDependsFortranParser.y"
+
+/* Line 1455 of yacc.c  */
+#line 242 "cmDependsFortranParser.y"
     {
     cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
     cmDependsFortranParser_RuleElse(parser);
@@ -1790,7 +1781,9 @@ yyreduce:
     break;
 
   case 20:
-#line 294 "cmDependsFortranParser.y"
+
+/* Line 1455 of yacc.c  */
+#line 247 "cmDependsFortranParser.y"
     {
     cmDependsFortranParser* parser = cmDependsFortran_yyget_extra(yyscanner);
     cmDependsFortranParser_RuleEndif(parser);
@@ -1798,25 +1791,32 @@ yyreduce:
     break;
 
   case 21:
-#line 299 "cmDependsFortranParser.y"
+
+/* Line 1455 of yacc.c  */
+#line 252 "cmDependsFortranParser.y"
     {
     free((yyvsp[(1) - (4)].string));
     }
     break;
 
   case 46:
-#line 321 "cmDependsFortranParser.y"
+
+/* Line 1455 of yacc.c  */
+#line 274 "cmDependsFortranParser.y"
     { free ((yyvsp[(1) - (1)].string)); }
     break;
 
   case 47:
-#line 322 "cmDependsFortranParser.y"
+
+/* Line 1455 of yacc.c  */
+#line 275 "cmDependsFortranParser.y"
     { free ((yyvsp[(1) - (1)].string)); }
     break;
 
 
-/* Line 1267 of yacc.c.  */
-#line 1820 "cmDependsFortranParser.cxx"
+
+/* Line 1455 of yacc.c  */
+#line 1821 "cmDependsFortranParser.cxx"
       default: break;
     }
   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -1827,7 +1827,6 @@ yyreduce:
 
   *++yyvsp = yyval;
 
-
   /* Now `shift' the result of the reduction.  Determine what state
      that goes to, based on the state we popped back to and the rule
      number reduced by.  */
@@ -1892,7 +1891,7 @@ yyerrlab:
 
   if (yyerrstatus == 3)
     {
-      /* If just tried and failed to reuse look-ahead token after an
+      /* If just tried and failed to reuse lookahead token after an
          error, discard it.  */
 
       if (yychar <= YYEOF)
@@ -1910,7 +1909,7 @@ yyerrlab:
     }
 
 #if 0
-  /* Else will try to reuse look-ahead token after shifting the error
+  /* Else will try to reuse lookahead token after shifting the error
      token.  */
   goto yyerrlab1;
 
@@ -1968,9 +1967,6 @@ yyerrlab1:
       YY_STACK_PRINT (yyss, yyssp);
     }
 
-  if (yyn == YYFINAL)
-    YYACCEPT;
-
   *++yyvsp = yylval;
 
 
@@ -1995,7 +1991,7 @@ yyabortlab:
   yyresult = 1;
   goto yyreturn;
 
-#ifndef yyoverflow
+#if !defined(yyoverflow) || YYERROR_VERBOSE
 /*-------------------------------------------------.
 | yyexhaustedlab -- memory exhaustion comes here.  |
 `-------------------------------------------------*/
@@ -2006,7 +2002,7 @@ yyexhaustedlab:
 #endif
 
 yyreturn:
-  if (yychar != YYEOF && yychar != YYEMPTY)
+  if (yychar != YYEMPTY)
      yydestruct ("Cleanup: discarding lookahead",
                  yytoken, &yylval);
   /* Do not reclaim the symbols of the rule which action triggered
@@ -2032,7 +2028,8 @@ yyreturn:
 }
 
 
-#line 330 "cmDependsFortranParser.y"
 
-/* End of grammar */
+/* Line 1675 of yacc.c  */
+#line 283 "cmDependsFortranParser.y"
 
+/* End of grammar */
diff --git a/Source/cmDependsFortranParser.y b/Source/cmDependsFortranParser.y
index 9aa9445..1e0ff04 100644
--- a/Source/cmDependsFortranParser.y
+++ b/Source/cmDependsFortranParser.y
@@ -46,6 +46,8 @@ Modify cmDependsFortranParser.cxx:
 #include "cmDependsFortranParser.h" /* Interface to parser object.  */
 #include "cmDependsFortranParserTokens.h" /* Need YYSTYPE for YY_DECL.  */
 
+#include <cmsys/String.h>
+
 /* Configure the parser to use a lexer object.  */
 #define YYPARSE_PARAM yyscanner
 #define YYLEX_PARAM yyscanner
@@ -63,59 +65,10 @@ static void cmDependsFortranError(yyscan_t yyscanner, const char* message)
   cmDependsFortranParser_Error(parser, message);
 }
 
-static char charmap[] = {
-    '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
-    '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
-    '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
-    '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
-    '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
-    '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
-    '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
-    '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
-    '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
-    '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
-    '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
-    '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
-    '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
-    '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
-    '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
-    '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
-    '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
-    '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
-    '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
-    '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
-    '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
-    '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
-    '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
-    '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
-    '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
-    '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
-    '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327',
-    '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337',
-    '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
-    '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
-    '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
-    '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377'
-};
-
-inline int strcasecmpCM(const char *s1, const char *s2) 
-{
-  const char *cm = charmap;
-  unsigned char const* us1 = reinterpret_cast<unsigned char const*>(s1);
-  unsigned char const* us2 = reinterpret_cast<unsigned char const*>(s2);
-  
-  while(cm[*us1] == cm[*us2++])
-    if(*us1++ == '\0') 
-      {
-      return(0);
-      }
-  return(cm[*us1] - cm[*--us2]);
-}
-
 static bool cmDependsFortranParserIsKeyword(const char* word,
                                             const char* keyword)
 {
-  return strcasecmpCM(word, keyword) == 0;
+  return cmsysString_strcasecmp(word, keyword) == 0;
 }
 
 /* Disable some warnings in the generated code.  */
diff --git a/Source/cmDependsFortranParserTokens.h b/Source/cmDependsFortranParserTokens.h
index 6079279..0bbcaae 100644
--- a/Source/cmDependsFortranParserTokens.h
+++ b/Source/cmDependsFortranParserTokens.h
@@ -1,14 +1,14 @@
-/* A Bison parser, made by GNU Bison 2.3.  */
+/* A Bison parser, made by GNU Bison 2.4.1.  */
 
 /* Skeleton interface for Bison's Yacc-like parsers in C
 
-   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+      Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
 
-   This program is free software; you can redistribute it and/or modify
+   This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,9 +16,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* As a special exception, you may create a larger work that contains
    part or all of the Bison parser skeleton and distribute that work
@@ -104,14 +102,17 @@
 
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 typedef union YYSTYPE
-#line 141 "cmDependsFortranParser.y"
 {
+
+/* Line 1676 of yacc.c  */
+#line 94 "cmDependsFortranParser.y"
+
   char* string;
-}
-/* Line 1489 of yacc.c.  */
-#line 113 "cmDependsFortranParserTokens.h"
-        YYSTYPE;
+
+/* Line 1676 of yacc.c  */
+#line 118 "cmDependsFortranParserTokens.h"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
 # define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
 #endif
-- 
cgit v0.12