%{
-#include <afs/param.h>
#include <afsconfig.h>
-
-RCSID("$Header$");
+#include <afs/param.h>
+#include <roken.h>
/*
*
#else
#include <sys/time.h>
#endif
-#include <sys/timeb.h>
#include "error_table.h"
#include "mit-sipb-cr.h"
#include "internal.h"
-char *current_token = (char *)NULL;
+int char_to_num(char c);
+char *gensym(const char *x);
+char *current_token = NULL;
extern char *table_name;
-char *ds(const char *string);
char *quote(const char *string);
void set_table_1num(char *string);
int char_to_1num(char c);
void set_table_num(char *string);
void set_table_fun(char *astring);
+extern int yylex (void);
+
%}
%union {
char *dynstr;
%%
error_table : ERROR_TABLE header error_codes END
- { table_name = ds($2);
+ { table_name = strdup($2);
current_token = table_name;
put_ecs(); }
;
$$ = $2; }
| table_id
{ current_token = $1;
- set_table_fun(ds("1"));
+ set_table_fun(strdup("1"));
$$ = $1;
}
;
;
ec_name : STRING
- { $$ = ds($1);
+ { $$ = strdup($1);
current_token = $$; }
;
description : QUOTED_STRING
- { $$ = ds($1);
+ { $$ = strdup($1);
current_token = $$; }
;
%%
-/* Copyright (C) 1998 Transarc Corporation. All rights reserved.
- *
+/*
+ * Copyright 2000, International Business Machines Corporation and others.
+ * All Rights Reserved.
+ *
+ * This software has been released under the terms of the IBM Public
+ * License. For details, see the LICENSE file in the top-level source
+ * directory or online at http://www.openafs.org/dl/license10.html
*/
extern FILE *hfile, *cfile, *msfile;
gettimeofday(&tv, (void *)0);
gensym_n = (tv.tv_sec%10000)*100 + tv.tv_usec/10000;
}
- symbol = (char *)malloc(32 * sizeof(char));
+ symbol = malloc(32 * sizeof(char));
gensym_n++;
sprintf(symbol, "et%ld", (long int) gensym_n);
return(symbol);
}
char *
-ds(const char *string)
-{
- char *rv;
- rv = (char *)malloc(strlen(string)+1);
- strcpy(rv, string);
- return(rv);
-}
-
-char *
quote(const char *string)
{
char *rv;
- rv = (char *)malloc(strlen(string)+3);
+ rv = malloc(strlen(string)+3);
strcpy(rv, "\"");
strcat(rv, string);
strcat(rv, "\"");
afs_int32 table_number = 0;
int current = 0;
-char **error_codes = (char **)NULL;
+char **error_codes = NULL;
void add_ec(const char *name, const char *description)
{
#else
fprintf(msfile, "%d %s\n", current, description);
#endif /* !sun */
- } else {
+ } else if (cfile){
fprintf(cfile, "\t\"%s\",\n", description);
}
- if (error_codes == (char **)NULL) {
- error_codes = (char **)malloc(sizeof(char *));
- *error_codes = (char *)NULL;
+ if (error_codes == NULL) {
+ error_codes = malloc(sizeof(char *));
+ *error_codes = NULL;
}
error_codes = (char **)realloc((char *)error_codes,
(current + 2)*sizeof(char *));
- error_codes[current++] = ds(name);
- error_codes[current] = (char *)NULL;
+ error_codes[current++] = strdup(name);
+ error_codes[current] = NULL;
}
void add_ec_val(const char *name, const char *val, const char *description)
}
while (ncurrent > current) {
- if (!msfile)
- fputs("\t(char *)NULL,\n", cfile);
+ if (cfile)
+ fputs("\tNULL,\n", cfile);
current++;
}
if (msfile) {
#else
fprintf(msfile, "%d %s\n", current, description);
#endif /* ! sun */
- } else {
+ } else if (cfile) {
fprintf(cfile, "\t\"%s\",\n", description);
}
- if (error_codes == (char **)NULL) {
- error_codes = (char **)malloc(sizeof(char *));
- *error_codes = (char *)NULL;
+ if (error_codes == NULL) {
+ error_codes = malloc(sizeof(char *));
+ *error_codes = NULL;
}
error_codes = (char **)realloc((char *)error_codes,
(current + 2)*sizeof(char *));
- error_codes[current++] = ds(name);
- error_codes[current] = (char *)NULL;
+ error_codes[current++] = strdup(name);
+ error_codes[current] = NULL;
}
void put_ecs(void)
{
int i;
+ if (!hfile)
+ return;
for (i = 0; i < current; i++) {
- if (error_codes[i] != (char *)NULL)
+ if (error_codes[i] != NULL)
fprintf(hfile, "#define %-40s (%ldL)\n",
error_codes[i], (long int) table_number + i);
}
}
void set_table_num(char *string)
-{ char ucname[6]; /* I think 5 is enough but et_name.c used 6... */
- extern char *ucstring();
-
- if (msfile) {
+{
+ if (use_msf) {
set_table_1num(string);
return;
}
string[4] = '\0';
fprintf(stderr, "to %s\n", string);
}
- string = ucstring (ucname, string, sizeof(ucname));
if (char_to_num (string[0]) > char_to_num ('z')) {
fprintf (stderr, "%s%s%s%s",
"First character of error table name must be ",
void set_table_fun(char *astring)
{
- register char *tp;
+ char *tp;
unsigned int tc;
for(tp=astring; (tc = *tp) != 0; tp++) {
exit(1);
}
}
- if (msfile)
+ if (use_msf)
table_number += (atoi(astring)) << 28;
}
exit (1);
}
+#if defined(IGNORE_SOME_GCC_WARNINGS) && defined(__clang__) && defined(HAVE_FUNC_ATTRIBUTE_FALLTHROUGH)
+/* flex generates fallthroughs in case blocks that get flagged by clang */
+# pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
+#endif
+
#ifdef AFS_NT40_ENV
#include "et_lex.lex_nt.c"
#else