segment: Separate SEG_N_TYPES from enum segment_type.
authorBen Pfaff <blp@cs.stanford.edu>
Mon, 7 Jan 2013 06:41:17 +0000 (22:41 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 12 Jan 2013 17:50:40 +0000 (09:50 -0800)
With SEG_N_TYPES not actually a member of enum segment_type, GCC doesn't
complain if it's missing from a switch statement on that type.

src/language/lexer/scan.c
src/language/lexer/segment.c
src/language/lexer/segment.h

index de75eeef3bd1f519a5508c55924be76cc6a2bd66..5e3d59e19cb3a24f77d2bb895e4483f9e8acaf60 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2010, 2011, 2013 Free Software Foundation, Inc.
 
    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
@@ -503,9 +503,6 @@ scan_start__ (struct scanner *scanner, enum segment_type type,
 
     case SEG_UNEXPECTED_CHAR:
       return scan_unexpected_char (&s, token);
-
-    case SEG_N_TYPES:
-      NOT_REACHED ();
     }
 
   NOT_REACHED ();
index 0d83257959f6b2d6818c01ff03c759b63eaea02a..7ff5e5eb73086fc673b3223685c10e5112161b90 100644 (file)
@@ -601,9 +601,6 @@ next_id_in_command (const struct segmenter *s, const char *input, size_t n,
         case SEG_UNEXPECTED_CHAR:
           id[0] = '\0';
           return ofs + retval;
-
-        case SEG_N_TYPES:
-          NOT_REACHED ();
         }
       ofs += retval;
     }
index 686b471e18d4bc7e3536c33ed3dcbb6c7bf9a937..1c209c5acb395dfe630035a4e34f4650215491dc 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2010, 2011, 2013 Free Software Foundation, Inc.
 
    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
@@ -97,9 +97,13 @@ enum segment_type
 #define SEG_TYPE(NAME) SEG_##NAME,
     SEG_TYPES
 #undef SEG_TYPE
-    SEG_N_TYPES
   };
 
+/* Number of segment types. */
+#define SEG_TYPE(NAME) + 1
+enum { SEG_N_TYPES = SEG_TYPES };
+#undef SEG_TYPE
+
 const char *segment_type_to_string (enum segment_type);
 
 /* A segmenter.  Opaque. */