diff options
author | dfr <dfr@FreeBSD.org> | 2008-05-08 11:01:46 +0000 |
---|---|---|
committer | dfr <dfr@FreeBSD.org> | 2008-05-08 11:01:46 +0000 |
commit | 62929665b739d66740a668830f004f9463f3ced9 (patch) | |
tree | 29031943aed09b2fbdbdc248e2868d86477d1ea3 /contrib/com_err/parse.y | |
parent | e240fee79046f8dbba1a0ff52d7d6d7db5d9ecf4 (diff) | |
download | FreeBSD-src-62929665b739d66740a668830f004f9463f3ced9.zip FreeBSD-src-62929665b739d66740a668830f004f9463f3ced9.tar.gz |
Merge from the vendor branch and resolve conflicts.
Diffstat (limited to 'contrib/com_err/parse.y')
-rw-r--r-- | contrib/com_err/parse.y | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/contrib/com_err/parse.y b/contrib/com_err/parse.y index 960bcfa..7e9cf10 100644 --- a/contrib/com_err/parse.y +++ b/contrib/com_err/parse.y @@ -36,7 +36,7 @@ #include "compile_et.h" #include "lex.h" #if 0 -RCSID("$Id: parse.y,v 1.11 2000/06/22 00:42:52 assar Exp $"); +RCSID("$Id: parse.y 15426 2005-06-16 19:21:42Z lha $"); #endif void yyerror (char *s); @@ -79,16 +79,14 @@ id : ID STRING et : ET STRING { - base = name2number($2); - strncpy(name, $2, sizeof(name)); - name[sizeof(name) - 1] = '\0'; + base_id = name2number($2); + strlcpy(name, $2, sizeof(name)); free($2); } | ET STRING STRING { - base = name2number($2); - strncpy(name, $3, sizeof(name)); - name[sizeof(name) - 1] = '\0'; + base_id = name2number($2); + strlcpy(name, $3, sizeof(name)); free($2); free($3); } @@ -104,24 +102,32 @@ statement : INDEX NUMBER } | PREFIX STRING { - prefix = realloc(prefix, strlen($2) + 2); - strcpy(prefix, $2); - strcat(prefix, "_"); + free(prefix); + asprintf (&prefix, "%s_", $2); + if (prefix == NULL) + errx(1, "malloc"); free($2); } | PREFIX { 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) + errx(1, "malloc"); ec->next = NULL; ec->number = number; if(prefix && *prefix != '\0') { asprintf (&ec->name, "%s%s", prefix, $2); + if (ec->name == NULL) + errx(1, "malloc"); free($2); } else ec->name = $2; @@ -141,7 +147,7 @@ static long name2number(const char *str) { const char *p; - long base = 0; + long num = 0; const char *x = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz0123456789_"; if(strlen(str) > 4) { @@ -154,12 +160,12 @@ name2number(const char *str) yyerror("invalid character in table name"); return 0; } - base = (base << 6) + (q - x) + 1; + num = (num << 6) + (q - x) + 1; } - base <<= 8; - if(base > 0x7fffffff) - base = -(0xffffffff - base + 1); - return base; + num <<= 8; + if(num > 0x7fffffff) + num = -(0xffffffff - num + 1); + return num; } void |