X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=binutils%2Fnlmheader.y;h=20ae82e4eccaed2631398c423f972b6cef755cb1;hb=f32ba72991d2406b21ab17edc234a2f3fa7fb23d;hp=2b78b893e10c07260bd2c39852c2b40cbbda2aaf;hpb=627703f9821aadad3cb4d77949c33966a00e7ab0;p=deliverable%2Fbinutils-gdb.git diff --git a/binutils/nlmheader.y b/binutils/nlmheader.y index 2b78b893e1..20ae82e4ec 100644 --- a/binutils/nlmheader.y +++ b/binutils/nlmheader.y @@ -1,21 +1,22 @@ %{/* nlmheader.y - parse NLM header specification keywords. - Copyright (C) 1993 Free Software Foundation, Inc. + Copyright (C) 1993-2017 Free Software Foundation, Inc. -This file is part of GNU Binutils. + This file is part of GNU Binutils. -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 -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + 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 + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ /* Written by Ian Lance Taylor . @@ -26,14 +27,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ This implementation is based on the description in the NetWare Tool Maker Specification manual, edition 1.0. */ -#include -#include -#include -#include #include "sysdep.h" -#include "bucomm.h" +#include "safe-ctype.h" +#include "bfd.h" #include "nlm/common.h" #include "nlm/internal.h" +#include "bucomm.h" #include "nlmconv.h" /* Information is stored in the structures pointed to by these @@ -50,15 +49,17 @@ char *check_procedure; /* File named by CUSTOM. */ char *custom_file; /* Whether to generate debugging information (DEBUG). */ -boolean debug_info; +bfd_boolean debug_info; /* Procedure named by EXIT. */ char *exit_procedure; /* Exported symbols (EXPORT). */ struct string_list *export_symbols; +/* List of files from INPUT. */ +struct string_list *input_files; /* Map file name (MAP, FULLMAP). */ char *map_file; /* Whether a full map has been requested (FULLMAP). */ -boolean full_map; +bfd_boolean full_map; /* File named by HELP. */ char *help_file; /* Imported symbols (IMPORT). */ @@ -67,12 +68,14 @@ struct string_list *import_symbols; char *message_file; /* Autoload module list (MODULE). */ struct string_list *modules; +/* File named by OUTPUT. */ +char *output_file; /* File named by SHARELIB. */ char *sharelib_file; /* Start procedure name (START). */ char *start_procedure; /* VERBOSE. */ -boolean verbose; +bfd_boolean verbose; /* RPC description file (XDCDATA). */ char *rpc_file; @@ -87,22 +90,21 @@ static char *symbol_prefix; #define yyerror(msg) nlmheader_error (msg); /* Local functions. */ -static int yylex PARAMS ((void)); -static void nlmlex_file_push PARAMS ((const char *)); -static boolean nlmlex_file_open PARAMS ((const char *)); -static int nlmlex_buf_init PARAMS ((void)); -static char nlmlex_buf_add PARAMS ((int)); -static long nlmlex_get_number PARAMS ((const char *)); -static void nlmheader_identify PARAMS ((void)); -static void nlmheader_warn PARAMS ((const char *, int)); -static void nlmheader_error PARAMS ((const char *)); -static struct string_list * string_list_cons PARAMS ((char *, - struct string_list *)); -static struct string_list * string_list_append PARAMS ((struct string_list *, - struct string_list *)); -static struct string_list * string_list_append1 PARAMS ((struct string_list *, - char *)); -static char *xstrdup PARAMS ((const char *)); +static int yylex (void); +static void nlmlex_file_push (const char *); +static bfd_boolean nlmlex_file_open (const char *); +static int nlmlex_buf_init (void); +static char nlmlex_buf_add (int); +static long nlmlex_get_number (const char *); +static void nlmheader_identify (void); +static void nlmheader_warn (const char *, int); +static void nlmheader_error (const char *); +static struct string_list * string_list_cons (char *, struct string_list *); +static struct string_list * string_list_append (struct string_list *, + struct string_list *); +static struct string_list * string_list_append1 (struct string_list *, + char *); +static char *xstrdup (const char *); %} @@ -114,11 +116,11 @@ static char *xstrdup PARAMS ((const char *)); /* The reserved words. */ -%token CHECK CODESTART COPYRIGHT CUSTOM DATE DEBUG DESCRIPTION EXIT +%token CHECK CODESTART COPYRIGHT CUSTOM DATE DEBUG_K DESCRIPTION EXIT %token EXPORT FLAG_ON FLAG_OFF FULLMAP HELP IMPORT INPUT MAP MESSAGES %token MODULE MULTIPLE OS_DOMAIN OUTPUT PSEUDOPREEMPTION REENTRANT -%token SCREENNAME SHARELIB STACK STACKSIZE START SYNCHRONIZE -%token THREADNAME TYPE VERBOSE VERSION XDCDATA +%token SCREENNAME SHARELIB STACK START SYNCHRONIZE +%token THREADNAME TYPE VERBOSE VERSIONK XDCDATA /* Arguments. */ @@ -126,7 +128,7 @@ static char *xstrdup PARAMS ((const char *)); %token QUOTED_STRING /* Typed non-terminals. */ -%type symbol_list_opt symbol_list module_list +%type symbol_list_opt symbol_list string_list %type symbol %% @@ -137,7 +139,7 @@ static char *xstrdup PARAMS ((const char *)); /* The entire file is just a list of commands. */ -file: +file: commands ; @@ -157,7 +159,7 @@ command: } | CODESTART STRING { - nlmheader_warn ("CODESTART is not implemented; sorry", -1); + nlmheader_warn (_("CODESTART is not implemented; sorry"), -1); free ($2); } | COPYRIGHT QUOTED_STRING @@ -168,7 +170,7 @@ command: len = strlen ($2); if (len >= NLM_MAX_COPYRIGHT_MESSAGE_LENGTH) { - nlmheader_warn ("copyright string is too long", + nlmheader_warn (_("copyright string is too long"), NLM_MAX_COPYRIGHT_MESSAGE_LENGTH - 1); len = NLM_MAX_COPYRIGHT_MESSAGE_LENGTH - 1; } @@ -192,10 +194,16 @@ command: free ($2); free ($3); free ($4); + if (version_hdr->month < 1 || version_hdr->month > 12) + nlmheader_warn (_("illegal month"), -1); + if (version_hdr->day < 1 || version_hdr->day > 31) + nlmheader_warn (_("illegal day"), -1); + if (version_hdr->year < 1900 || version_hdr->year > 3000) + nlmheader_warn (_("illegal year"), -1); } - | DEBUG + | DEBUG_K { - debug_info = true; + debug_info = TRUE; } | DESCRIPTION QUOTED_STRING { @@ -204,7 +212,7 @@ command: len = strlen ($2); if (len > NLM_MAX_DESCRIPTION_LENGTH) { - nlmheader_warn ("description string is too long", + nlmheader_warn (_("description string is too long"), NLM_MAX_DESCRIPTION_LENGTH); len = NLM_MAX_DESCRIPTION_LENGTH; } @@ -235,10 +243,15 @@ command: fixed_hdr->flags &=~ nlmlex_get_number ($2); free ($2); } + | FULLMAP + { + map_file = ""; + full_map = TRUE; + } | FULLMAP STRING { map_file = $2; - full_map = true; + full_map = TRUE; } | HELP STRING { @@ -252,10 +265,13 @@ command: { import_symbols = string_list_append (import_symbols, $3); } - | INPUT STRING + | INPUT string_list { - nlmheader_warn ("INPUT not supported", -1); - free ($2); + input_files = string_list_append (input_files, $2); + } + | MAP + { + map_file = ""; } | MAP STRING { @@ -265,7 +281,7 @@ command: { message_file = $2; } - | MODULE module_list + | MODULE string_list { modules = string_list_append (modules, $2); } @@ -279,8 +295,10 @@ command: } | OUTPUT STRING { - nlmheader_warn ("OUTPUT not supported", -1); - free ($2); + if (output_file == NULL) + output_file = $2; + else + nlmheader_warn (_("ignoring duplicate OUTPUT statement"), -1); } | PSEUDOPREEMPTION { @@ -297,7 +315,7 @@ command: len = strlen ($2); if (len >= NLM_MAX_SCREEN_NAME_LENGTH) { - nlmheader_warn ("screen name is too long", + nlmheader_warn (_("screen name is too long"), NLM_MAX_SCREEN_NAME_LENGTH); len = NLM_MAX_SCREEN_NAME_LENGTH; } @@ -315,11 +333,6 @@ command: var_hdr->stackSize = nlmlex_get_number ($2); free ($2); } - | STACKSIZE STRING - { - var_hdr->stackSize = nlmlex_get_number ($2); - free ($2); - } | START STRING { start_procedure = $2; @@ -335,13 +348,13 @@ command: len = strlen ($2); if (len >= NLM_MAX_THREAD_NAME_LENGTH) { - nlmheader_warn ("thread name is too long", + nlmheader_warn (_("thread name is too long"), NLM_MAX_THREAD_NAME_LENGTH); len = NLM_MAX_THREAD_NAME_LENGTH; } var_hdr->threadNameLength = len; strncpy (var_hdr->threadName, $2, len); - var_hdr->screenName[NLM_MAX_THREAD_NAME_LENGTH] = '\0'; + var_hdr->threadName[len] = '\0'; free ($2); } | TYPE STRING @@ -351,9 +364,9 @@ command: } | VERBOSE { - verbose = true; + verbose = TRUE; } - | VERSION STRING STRING STRING + | VERSIONK STRING STRING STRING { long val; @@ -361,21 +374,23 @@ command: version_hdr->majorVersion = nlmlex_get_number ($2); val = nlmlex_get_number ($3); if (val < 0 || val > 99) - nlmheader_warn ("illegal minor version number (must be between 0 and 99)", + nlmheader_warn (_("illegal minor version number (must be between 0 and 99)"), -1); else version_hdr->minorVersion = val; val = nlmlex_get_number ($4); - if (val < 1 || val > 26) - nlmheader_warn ("illegal revision number (must be between 1 and 26)", + if (val < 0) + nlmheader_warn (_("illegal revision number (must be between 0 and 26)"), -1); + else if (val > 26) + version_hdr->revision = 0; else version_hdr->revision = val; free ($2); free ($3); free ($4); } - | VERSION STRING STRING + | VERSIONK STRING STRING { long val; @@ -383,7 +398,7 @@ command: version_hdr->majorVersion = nlmlex_get_number ($2); val = nlmlex_get_number ($3); if (val < 0 || val > 99) - nlmheader_warn ("illegal minor version number (must be between 0 and 99)", + nlmheader_warn (_("illegal minor version number (must be between 0 and 99)"), -1); else version_hdr->minorVersion = val; @@ -460,14 +475,14 @@ symbol: } ; -/* A list of modules. */ +/* A list of strings. */ -module_list: +string_list: /* May be empty. */ { $$ = NULL; } - | STRING module_list + | STRING string_list { $$ = string_list_cons ($1, $2); } @@ -478,7 +493,7 @@ module_list: /* If strerror is just a macro, we want to use the one from libiberty since it will handle undefined values. */ #undef strerror -extern char *strerror (); +extern char *strerror (int); /* The lexer is simple, too simple for flex. Keywords are only recognized at the start of lines. Everything else must be an @@ -519,9 +534,8 @@ static struct input current; /* Start the lexer going on the main input file. */ -boolean -nlmlex_file (name) - const char *name; +bfd_boolean +nlmlex_file (const char *name) { current.next = NULL; return nlmlex_file_open (name); @@ -530,8 +544,7 @@ nlmlex_file (name) /* Start the lexer going on a subsidiary input file. */ static void -nlmlex_file_push (name) - const char *name; +nlmlex_file_push (const char *name) { struct input *push; @@ -548,21 +561,20 @@ nlmlex_file_push (name) /* Start lexing from a file. */ -static boolean -nlmlex_file_open (name) - const char *name; +static bfd_boolean +nlmlex_file_open (const char *name) { current.file = fopen (name, "r"); if (current.file == NULL) { fprintf (stderr, "%s:%s: %s\n", program_name, name, strerror (errno)); ++parse_errors; - return false; + return FALSE; } current.name = xstrdup (name); current.lineno = 1; current.state = BEGINNING_OF_LINE; - return true; + return TRUE; } /* Table used to turn keywords into tokens. */ @@ -573,14 +585,14 @@ struct keyword_tokens_struct int token; }; -struct keyword_tokens_struct keyword_tokens[] = +static struct keyword_tokens_struct keyword_tokens[] = { { "CHECK", CHECK }, { "CODESTART", CODESTART }, { "COPYRIGHT", COPYRIGHT }, { "CUSTOM", CUSTOM }, { "DATE", DATE }, - { "DEBUG", DEBUG }, + { "DEBUG", DEBUG_K }, { "DESCRIPTION", DESCRIPTION }, { "EXIT", EXIT }, { "EXPORT", EXPORT }, @@ -601,13 +613,13 @@ struct keyword_tokens_struct keyword_tokens[] = { "SCREENNAME", SCREENNAME }, { "SHARELIB", SHARELIB }, { "STACK", STACK }, - { "STACKSIZE", STACKSIZE }, + { "STACKSIZE", STACK }, { "START", START }, { "SYNCHRONIZE", SYNCHRONIZE }, { "THREADNAME", THREADNAME }, { "TYPE", TYPE }, { "VERBOSE", VERBOSE }, - { "VERSION", VERSION }, + { "VERSION", VERSIONK }, { "XDCDATA", XDCDATA } }; @@ -623,7 +635,7 @@ static int lex_pos; ((void) (lex_buf != NULL ? lex_pos = 0 : nlmlex_buf_init ())) static int -nlmlex_buf_init () +nlmlex_buf_init (void) { lex_size = 10; lex_buf = xmalloc (lex_size + 1); @@ -641,8 +653,7 @@ nlmlex_buf_init () : nlmlex_buf_add (c))) static char -nlmlex_buf_add (c) - int c; +nlmlex_buf_add (int c) { if (lex_pos >= lex_size) { @@ -657,7 +668,7 @@ nlmlex_buf_add (c) code. */ static int -yylex () +yylex (void) { int c; @@ -666,7 +677,7 @@ tail_recurse: c = getc (current.file); /* Commas are treated as whitespace characters. */ - while (isspace ((unsigned char) c) || c == ',') + while (ISSPACE (c) || c == ',') { current.state = IN_LINE; if (c == '\n') @@ -719,9 +730,9 @@ tail_recurse: if (c == '\n') ++current.lineno; } - while (isspace ((unsigned char) c)); + while (ISSPACE (c)); BUF_INIT (); - while (! isspace ((unsigned char) c) && c != EOF) + while (! ISSPACE (c) && c != EOF) { BUF_ADD (c); c = getc (current.file); @@ -729,7 +740,7 @@ tail_recurse: BUF_FINISH (); ungetc (c, current.file); - + nlmlex_file_push (lex_buf); goto tail_recurse; } @@ -739,25 +750,22 @@ tail_recurse: if (current.state == BEGINNING_OF_LINE) { BUF_INIT (); - while (isalnum ((unsigned char) c) || c == '_') + while (ISALNUM (c) || c == '_') { - if (islower ((unsigned char) c)) - BUF_ADD (toupper ((unsigned char) c)); - else - BUF_ADD (c); + BUF_ADD (TOUPPER (c)); c = getc (current.file); } BUF_FINISH (); - if (c != EOF && ! isspace ((unsigned char) c) && c != ',') + if (c != EOF && ! ISSPACE (c) && c != ',') { nlmheader_identify (); - fprintf (stderr, "%s:%d: illegal character in keyword: %c\n", + fprintf (stderr, _("%s:%d: illegal character in keyword: %c\n"), current.name, current.lineno, c); } else { - int i; + unsigned int i; for (i = 0; i < KEYWORD_COUNT; i++) { @@ -771,9 +779,9 @@ tail_recurse: return keyword_tokens[i].token; } } - + nlmheader_identify (); - fprintf (stderr, "%s:%d: unrecognized keyword: %s\n", + fprintf (stderr, _("%s:%d: unrecognized keyword: %s\n"), current.name, current.lineno, lex_buf); } @@ -810,7 +818,7 @@ tail_recurse: if (c == EOF) { nlmheader_identify (); - fprintf (stderr, "%s:%d: end of file in quoted string\n", + fprintf (stderr, _("%s:%d: end of file in quoted string\n"), current.name, start_lineno); ++parse_errors; } @@ -822,7 +830,7 @@ tail_recurse: /* Gather a generic argument. */ BUF_INIT (); - while (! isspace (c) + while (! ISSPACE (c) && c != ',' && c != COMMENT_CHAR && c != '(' @@ -843,15 +851,14 @@ tail_recurse: /* Get a number from a string. */ static long -nlmlex_get_number (s) - const char *s; +nlmlex_get_number (const char *s) { long ret; char *send; ret = strtol (s, &send, 10); if (*send != '\0') - nlmheader_warn ("bad number", -1); + nlmheader_warn (_("bad number"), -1); return ret; } @@ -861,13 +868,13 @@ nlmlex_get_number (s) number. */ static void -nlmheader_identify () +nlmheader_identify (void) { static int done; if (! done) { - fprintf (stderr, "%s: problems in NLM command language input:\n", + fprintf (stderr, _("%s: problems in NLM command language input:\n"), program_name); done = 1; } @@ -876,9 +883,7 @@ nlmheader_identify () /* Issue a warning. */ static void -nlmheader_warn (s, imax) - const char *s; - int imax; +nlmheader_warn (const char *s, int imax) { nlmheader_identify (); fprintf (stderr, "%s:%d: %s", current.name, current.lineno, s); @@ -890,8 +895,7 @@ nlmheader_warn (s, imax) /* Report an error. */ static void -nlmheader_error (s) - const char *s; +nlmheader_error (const char *s) { nlmheader_warn (s, -1); ++parse_errors; @@ -900,9 +904,7 @@ nlmheader_error (s) /* Add a string to a string list. */ static struct string_list * -string_list_cons (s, l) - char *s; - struct string_list *l; +string_list_cons (char *s, struct string_list *l) { struct string_list *ret; @@ -915,9 +917,7 @@ string_list_cons (s, l) /* Append a string list to another string list. */ static struct string_list * -string_list_append (l1, l2) - struct string_list *l1; - struct string_list *l2; +string_list_append (struct string_list *l1, struct string_list *l2) { register struct string_list **pp; @@ -930,9 +930,7 @@ string_list_append (l1, l2) /* Append a string to a string list. */ static struct string_list * -string_list_append1 (l, s) - struct string_list *l; - char *s; +string_list_append1 (struct string_list *l, char *s) { struct string_list *n; register struct string_list **pp; @@ -949,8 +947,7 @@ string_list_append1 (l, s) /* Duplicate a string in memory. */ static char * -xstrdup (s) - const char *s; +xstrdup (const char *s) { unsigned long len; char *ret;