summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/compile_et/compile_et.c35
-rw-r--r--usr.bin/compile_et/compile_et.h13
-rw-r--r--usr.bin/compile_et/error_table.y51
-rw-r--r--usr.bin/compile_et/et_lex.lex.l28
4 files changed, 54 insertions, 73 deletions
diff --git a/usr.bin/compile_et/compile_et.c b/usr.bin/compile_et/compile_et.c
index 7f4c9d7ed31..1529ceb450a 100644
--- a/usr.bin/compile_et/compile_et.c
+++ b/usr.bin/compile_et/compile_et.c
@@ -1,6 +1,6 @@
-/* $OpenBSD: compile_et.c,v 1.12 2005/05/13 05:05:22 jaredy Exp $ */
+/* $OpenBSD: compile_et.c,v 1.13 2005/10/17 07:35:29 biorn Exp $ */
/*
- * Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan
+ * Copyright (c) 1998-2002 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -15,12 +15,7 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Kungliga Tekniska
- * Högskolan and its contributors.
- *
- * 4. Neither the name of the Institute nor the names of its contributors
+ * 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -40,7 +35,7 @@
#undef ROKEN_RENAME
#include "compile_et.h"
-/* RCSID("$KTH: compile_et.c,v 1.12 1999/04/01 09:13:52 joda Exp $"); */
+/* RCSID("$KTH: compile_et.c,v 1.17 2005/05/16 08:42:45 lha Exp $"); */
#include <err.h>
#include "error_table.h"
@@ -88,7 +83,7 @@ generate_c(void)
fprintf(c_file, "#include \"%s\"\n", hfn);
fprintf(c_file, "\n");
- fprintf(c_file, "static const char *text[] = {\n");
+ fprintf(c_file, "static const char *%s_error_strings[] = {\n", name);
for (ec = codes, n = 0; ec; ec = ec->next, n++) {
while (n < ec->number) {
@@ -104,19 +99,21 @@ generate_c(void)
fprintf(c_file, "\tNULL\n");
fprintf(c_file, "};\n");
fprintf(c_file, "\n");
+ fprintf(c_file, "#define num_errors %d\n", number);
+ fprintf(c_file, "\n");
fprintf(c_file,
"void initialize_%s_error_table_r(struct et_list **list)\n", name);
fprintf(c_file, "{\n");
fprintf(c_file,
- " initialize_error_table_r(list, text, "
- "%s_num_errors, ERROR_TABLE_BASE_%s);\n", name, name);
+ " initialize_error_table_r(list, %s_error_strings, "
+ "num_errors, ERROR_TABLE_BASE_%s);\n", name, name);
fprintf(c_file, "}\n");
fprintf(c_file, "\n");
fprintf(c_file, "void initialize_%s_error_table(void)\n", name);
fprintf(c_file, "{\n");
fprintf(c_file,
- " init_error_table(text, ERROR_TABLE_BASE_%s, "
- "%s_num_errors);\n", name, name);
+ " init_error_table(%s_error_strings, ERROR_TABLE_BASE_%s, "
+ "num_errors);\n", name, name);
fprintf(c_file, "}\n");
fclose(c_file);
@@ -147,7 +144,7 @@ generate_h(void)
fprintf(h_file, "#ifndef %s\n", fn);
fprintf(h_file, "#define %s\n", fn);
fprintf(h_file, "\n");
- fprintf(h_file, "#include <kerberosV/com_err.h>\n");
+ fprintf(h_file, "struct et_list;\n");
fprintf(h_file, "\n");
fprintf(h_file,
"void initialize_%s_error_table_r(struct et_list **);\n",
@@ -158,15 +155,15 @@ generate_h(void)
name, name);
fprintf(h_file, "\n");
fprintf(h_file, "typedef enum %s_error_number{\n", name);
- fprintf(h_file, "\tERROR_TABLE_BASE_%s = %ld,\n", name, base);
- fprintf(h_file, "\t%s_err_base = %ld,\n", name, base);
for (ec = codes; ec; ec = ec->next)
- fprintf(h_file, "\t%s = %ld,\n", ec->name, base + ec->number);
+ fprintf(h_file, "\t%s = %ld%s\n", ec->name, base + ec->number,
+ (ec->next != NULL) ? "," : "");
- fprintf(h_file, "\t%s_num_errors = %d\n", name, number);
fprintf(h_file, "} %s_error_number;\n", name);
fprintf(h_file, "\n");
+ fprintf(h_file, "#define ERROR_TABLE_BASE_%s %ld\n", name, base);
+ fprintf(h_file, "\n");
fprintf(h_file, "#endif /* %s */\n", fn);
fclose(h_file);
diff --git a/usr.bin/compile_et/compile_et.h b/usr.bin/compile_et/compile_et.h
index 3ee82db52d2..1ca17bb107d 100644
--- a/usr.bin/compile_et/compile_et.h
+++ b/usr.bin/compile_et/compile_et.h
@@ -1,6 +1,6 @@
-/* $OpenBSD: compile_et.h,v 1.3 2005/05/13 05:05:22 jaredy Exp $ */
+/* $OpenBSD: compile_et.h,v 1.4 2005/10/17 07:35:29 biorn Exp $ */
/*
- * Copyright (c) 1998 Kungliga Tekniska Högskolan
+ * Copyright (c) 1998 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -15,12 +15,7 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Kungliga Tekniska
- * Högskolan and its contributors.
- *
- * 4. Neither the name of the Institute nor the names of its contributors
+ * 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -37,7 +32,7 @@
* SUCH DAMAGE.
*/
-/* $KTH: compile_et.h,v 1.3 1998/11/22 09:39:46 assar Exp $ */
+/* $KTH: compile_et.h,v 1.7 2005/05/16 08:51:47 lha Exp $ */
#ifndef __COMPILE_ET_H__
#define __COMPILE_ET_H__
diff --git a/usr.bin/compile_et/error_table.y b/usr.bin/compile_et/error_table.y
index e362d7d5750..0b1c23bf264 100644
--- a/usr.bin/compile_et/error_table.y
+++ b/usr.bin/compile_et/error_table.y
@@ -1,6 +1,6 @@
%{
/*
- * Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan
+ * Copyright (c) 1998 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -15,12 +15,7 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Kungliga Tekniska
- * Högskolan and its contributors.
- *
- * 4. Neither the name of the Institute nor the names of its contributors
+ * 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -38,10 +33,11 @@
*/
#include "compile_et.h"
-/* RCSID("$KTH: parse.y,v 1.9 1999/07/04 14:54:58 assar Exp $"); */
+
+/* RCSID("$KTH: parse.y,v 1.13 2005/05/16 08:53:34 lha Exp $"); */
void yyerror (char *s);
-long name2number(const char *str);
+static long name2number(const char *str);
void error_message(char *, ...);
extern char *yytext;
@@ -105,39 +101,32 @@ statement : INDEX NUMBER
}
| PREFIX STRING
{
- size_t len = strlen($2) + 2;
-
- if ((prefix = realloc(prefix, len)) == NULL) {
- yyerror(strerror(errno));
- exit(1);
- }
- strlcpy(prefix, $2, len);
- strlcat(prefix, "_", len);
+ free(prefix);
+ asprintf (&prefix, "%s_", $2);
+ if (prefix == NULL)
+ errx(1, "malloc");
free($2);
}
| PREFIX
{
- if ((prefix = realloc(prefix, 1)) == NULL) {
- yyerror(strerror(errno));
- exit(1);
- }
+ prefix = realloc(prefix, 1);
+ if (prefix == NULL)
+ errx(1, "malloc");
*prefix = '\0';
}
| EC STRING ',' STRING
{
struct error_code *ec = malloc(sizeof(*ec));
-
- if (ec == NULL) {
- yyerror(strerror(errno));
- exit(1);
- }
+
+ if (ec == NULL)
+ errx(1, "malloc");
+
ec->next = NULL;
ec->number = number;
if(prefix && *prefix != '\0') {
- if (asprintf (&ec->name, "%s%s", prefix, $2) == -1) {
- yyerror(strerror(errno));
- exit(1);
- }
+ asprintf (&ec->name, "%s%s", prefix, $2);
+ if (ec->name == NULL)
+ errx(1, "malloc");
free($2);
} else
ec->name = $2;
@@ -153,7 +142,7 @@ statement : INDEX NUMBER
%%
-long
+static long
name2number(const char *str)
{
const char *p;
diff --git a/usr.bin/compile_et/et_lex.lex.l b/usr.bin/compile_et/et_lex.lex.l
index ae7fe547172..6f7685fac32 100644
--- a/usr.bin/compile_et/et_lex.lex.l
+++ b/usr.bin/compile_et/et_lex.lex.l
@@ -1,6 +1,6 @@
%{
/*
- * Copyright (c) 1998 Kungliga Tekniska Högskolan
+ * Copyright (c) 1998 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -15,12 +15,7 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Kungliga Tekniska
- * Högskolan and its contributors.
- *
- * 4. Neither the name of the Institute nor the names of its contributors
+ * 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -48,11 +43,15 @@
#include "compile_et.h"
#include "error_table.h"
-/* RCSID("$KTH: lex.l,v 1.4 1998/11/20 05:58:52 assar Exp $"); */
+/* RCSID("$KTH: lex.l,v 1.8 2005/05/16 08:52:54 lha Exp $"); */
static unsigned lineno = 1;
-void error_message(char *, ...);
-int getstring(void);
+void error_message(const char *, ...);
+static int getstring(void);
+
+#define YY_NO_UNPUT
+
+#undef ECHO
%}
@@ -83,7 +82,7 @@ yywrap ()
}
#endif
-int
+static int
getstring(void)
{
char x[128];
@@ -110,13 +109,14 @@ getstring(void)
x[i++] = c;
}
x[i] = '\0';
- if ((yylval.string = strdup(x)) == NULL)
- err(1, NULL);
+ yylval.string = strdup(x);
+ if (yylval.string == NULL)
+ err(1, "malloc");
return STRING;
}
void
-error_message (char *format, ...)
+error_message (const char *format, ...)
{
va_list args;