From: Ben Pfaff Date: Mon, 7 Jan 2013 06:41:17 +0000 (-0800) Subject: segment: Separate SEG_N_TYPES from enum segment_type. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=37d653f70adc51de57b0460022f6fd371d51279c;p=pspp segment: Separate SEG_N_TYPES from enum segment_type. 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. --- diff --git a/src/language/lexer/scan.c b/src/language/lexer/scan.c index de75eeef3b..5e3d59e19c 100644 --- a/src/language/lexer/scan.c +++ b/src/language/lexer/scan.c @@ -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 (); diff --git a/src/language/lexer/segment.c b/src/language/lexer/segment.c index 0d83257959..7ff5e5eb73 100644 --- a/src/language/lexer/segment.c +++ b/src/language/lexer/segment.c @@ -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; } diff --git a/src/language/lexer/segment.h b/src/language/lexer/segment.h index 686b471e18..1c209c5acb 100644 --- a/src/language/lexer/segment.h +++ b/src/language/lexer/segment.h @@ -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. */