diff --git a/Makefile.in b/Makefile.in index bc164ca..882bb62 100644 --- a/Makefile.in +++ b/Makefile.in @@ -230,11 +230,6 @@ pwyacc.h: pwyacc.c mysql-dbadm$(EXEEXT): $(mysql_dbadm_OBJECTS) $(mysql_dbadm_DEPENDENCIES) @rm -f mysql-dbadm$(EXEEXT) $(LINK) $(mysql_dbadm_LDFLAGS) $(mysql_dbadm_OBJECTS) $(mysql_dbadm_LDADD) $(LIBS) -pwyacc.h: pwyacc.c - @if test ! -f $@; then \ - rm -f pwyacc.c; \ - $(MAKE) pwyacc.c; \ - else :; fi mysql-useradm$(EXEEXT): $(mysql_useradm_OBJECTS) $(mysql_useradm_DEPENDENCIES) @rm -f mysql-useradm$(EXEEXT) $(LINK) $(mysql_useradm_LDFLAGS) $(mysql_useradm_OBJECTS) $(mysql_useradm_LDADD) $(LIBS) diff --git a/common.c b/common.c index 6ad0d56..77febf3 100644 --- a/common.c +++ b/common.c @@ -1,5 +1,5 @@ /* - * @(#) $Header: /tmp/cvs/mysql-admutils/common.c,v 1.8 2006-08-15 11:51:58 geirha Exp $ + * @(#) $Header: /tmp/cvs/mysql-admutils/common.c,v 1.9 2007-02-27 14:10:07 geirha Exp $ * * functions used by mysql-dbadm.c and mysql-useradm.c * @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -22,7 +23,7 @@ char *program_name; -static char *rcsheader = "@(#) " PACKAGE " " VERSION " orakel@ntnu.no $Header: /tmp/cvs/mysql-admutils/common.c,v 1.8 2006-08-15 11:51:58 geirha Exp $"; +static char *rcsheader = "@(#) " PACKAGE " " VERSION " orakel@ntnu.no $Header: /tmp/cvs/mysql-admutils/common.c,v 1.9 2007-02-27 14:10:07 geirha Exp $"; int @@ -56,7 +57,7 @@ wrong_use(char *format, ...) int dberror(MYSQL *pmysql, char *format, ...) { - char *errmsg; + const char *errmsg; va_list ap; fprintf(stderr, "%s: ", program_name); diff --git a/mysql-dbadm.c b/mysql-dbadm.c index 448e092..631f88b 100644 --- a/mysql-dbadm.c +++ b/mysql-dbadm.c @@ -1,5 +1,5 @@ /* - * @(#) $Header: /tmp/cvs/mysql-admutils/mysql-dbadm.c,v 1.18 2007-02-27 11:38:07 geirha Exp $ + * @(#) $Header: /tmp/cvs/mysql-admutils/mysql-dbadm.c,v 1.19 2007-02-27 14:10:08 geirha Exp $ * * mysql-dbadm.c * @@ -513,9 +513,16 @@ main(int argc, char *argv[]) db[32] = '\0'; if (! (owner(db) || member(db))) { - dberror(NULL, "You are not the owner of '%s'. Skipping.", - db); - continue; + if (command == c_create) + dberror(NULL,"Unable to create mysql-database '%s'.\n" + "A mysql-database must start with either '%s_' or " + "'groupname_', where groupname is a unix group you are a " + "member of. Type \"groups\" to see which groups you are a " + "member of.\n", + db, getpwuid(getuid())->pw_name); + else + dberror(NULL, "You are not in charge of mysql-database: '%s'. Skipping.", db); + continue; } switch (command) { diff --git a/mysql-useradm.c b/mysql-useradm.c index c5de2e0..69a9de8 100644 --- a/mysql-useradm.c +++ b/mysql-useradm.c @@ -1,5 +1,5 @@ /* - * @(#) $Header: /tmp/cvs/mysql-admutils/mysql-useradm.c,v 1.10 2005-06-27 10:13:01 knuta Exp $ + * @(#) $Header: /tmp/cvs/mysql-admutils/mysql-useradm.c,v 1.11 2007-02-27 14:10:08 geirha Exp $ * * mysql-useradm.c * @@ -52,7 +52,7 @@ is_password_set(MYSQL *pmysql, const char *user) return -1; if (rows > 1) return dberror(NULL, "Query for password for user '%s' gave %d results!", - user, rows); + user, rows); row = mysql_fetch_row(res); return (row[0] && (strlen(row[0]) > 0)); } @@ -99,25 +99,25 @@ passwd(MYSQL *pmysql, const char *user) sprintf(prompt, "(current) MySQL password for user '%s': ", user); password = getpass(prompt); sprintf(query, "select password = password('%s') from user " - "where user = '%s'", password, user); + "where user = '%s'", password, user); if (mysql_query(pmysql, query)) - return dberror(pmysql, "Failed to check old password for user '%s'.", - user); + return dberror(pmysql, "Failed to check old password for user '%s'.", + user); res = mysql_store_result(pmysql); rows = mysql_num_rows(res); if (rows == 0) - return dberror(NULL, "Check for old password for user '%s' " - "returned empty.", user); + return dberror(NULL, "Check for old password for user '%s' " + "returned empty.", user); if (rows > 1) - return dberror(NULL, "Check for old password for user '%s' " - "returned more than one row!", user); + return dberror(NULL, "Check for old password for user '%s' " + "returned more than one row!", user); row = mysql_fetch_row(res); if (strcmp(row[0], "1") != 0) - { - fprintf(stderr, "%s: Wrong password entered for user '%s'.\n", - program_name, user); - return 1; - } + { + fprintf(stderr, "%s: Wrong password entered for user '%s'.\n", + program_name, user); + return 1; + } } sprintf(prompt, "New MySQL password for user '%s': ", user); @@ -133,12 +133,12 @@ passwd(MYSQL *pmysql, const char *user) free(confirm_password); sprintf(query, "update user set password = password('%s') " - "where user = '%s'", password, user); + "where user = '%s'", password, user); if (mysql_query(pmysql, query)) return dberror(pmysql, "Failed to set new password for user '%s'.", user); if (mysql_affected_rows(pmysql) > 1) dberror(NULL, "%d rows affected by password update for user '%s'!", - mysql_affected_rows(pmysql), user); + mysql_affected_rows(pmysql), user); fprintf(stderr, "Password updated for user '%s'.\n", user); return 0; @@ -180,7 +180,7 @@ list(MYSQL *pmysql) p = getpwuid(getuid()); sprintf(query, "select user from user where user='%s' or user like '%s\\_%%'", - p->pw_name, p->pw_name); + p->pw_name, p->pw_name); // sprintf(query, "select user from user where user='myhr' or user like 'myhr\\_%%'"); numgroups = 0; @@ -212,7 +212,7 @@ list(MYSQL *pmysql) for (i = 0; i < rows; i++) if ((row = mysql_fetch_row(res))) { - userlist[i] = strdup(row[0]); + userlist[i] = strdup(row[0]); } userlist[i] = NULL; @@ -270,7 +270,7 @@ main(int argc, char *argv[]) /* connect to the database server and select the mysql database */ if (!mysql_real_connect(&mysql, db_server, db_user, db_passwd, db_name, 0, NULL, 0)) return dberror(&mysql, "Cannot connect to database server '%s'.", - db_server); + db_server); if (mysql_select_db(&mysql, db_name)) return dberror(&mysql, "Cannot select database '%s'.", db_name); @@ -279,11 +279,11 @@ main(int argc, char *argv[]) dblist = list(&mysql); p = dblist; while (*p) - { - show(&mysql, *p); - free(*p); - p++; - } + { + show(&mysql, *p); + free(*p); + p++; + } free(dblist); } else { @@ -293,31 +293,40 @@ main(int argc, char *argv[]) for (i = 2; i < argc; i++) { strncpy(user, argv[i], 32); user[33] = '\0'; - if (! (owner(user) || member(user))) - { - dberror(NULL, "You are not the owner of '%s'. Skipping.", user); - continue; - } + if (! (owner(user) || member(user))) + { + if (command == c_create) + dberror(NULL,"Unable to create mysql-user '%s'.\n" - switch (command) - { - case c_create: - create(&mysql, user); - break; - case c_delete: - delete(&mysql, user); - break; - case c_passwd: - passwd(&mysql, user); - break; - case c_show: - show(&mysql, user); - break; - default: - fprintf(stderr, "This point should never be reached.\n"); - exit(1); - } - } + "A mysql-user must start with either '%s_' or " + "'groupname_', where groupname is a unix group you are a " + "member of. Type \"groups\" to see which groups you are " + "a member of.\n", + user, getpwuid(getuid())->pw_name); + else + dberror(NULL, "You are not in charge of mysql-user: '%s'. Skipping.", user); + continue; + } + + switch (command) + { + case c_create: + create(&mysql, user); + break; + case c_delete: + delete(&mysql, user); + break; + case c_passwd: + passwd(&mysql, user); + break; + case c_show: + show(&mysql, user); + break; + default: + fprintf(stderr, "This point should never be reached.\n"); + exit(1); + } + } } reload(&mysql); diff --git a/pwfile.c b/pwfile.c index 969e22e..ce2e573 100644 --- a/pwfile.c +++ b/pwfile.c @@ -1,11 +1,13 @@ /* - * @($) $Id: pwfile.c,v 1.2 2002-02-27 08:49:48 knutpett Exp $ + * @($) $Id: pwfile.c,v 1.3 2007-02-27 14:10:08 geirha Exp $ * * functions for parsing the config file. * */ #include +#include +#include #include #include #include diff --git a/pwyacc.c b/pwyacc.c index a38fad2..e90c550 100644 --- a/pwyacc.c +++ b/pwyacc.c @@ -1,7 +1,157 @@ -/* A Bison parser, made by GNU Bison 1.875. */ +/* A Bison parser, made from /home/homeq/ge/geirha/cvs/mysql-admutils/pwyacc.y + by GNU bison 1.35. */ -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc. +#define YYBISON 1 /* Identify Bison output. */ + +# define SET 257 +# define HOST 258 +# define USER 259 +# define PASSWORD 260 +# define STRING 261 + +#line 8 "pwyacc.y" + +int yyerror(const char *msg); +int yylex(void); +int config_set_string_var(int var, const char *value); +#ifndef YYSTYPE +# define YYSTYPE int +# define YYSTYPE_IS_TRIVIAL 1 +#endif +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + + + +#define YYFINAL 12 +#define YYFLAG -32768 +#define YYNTBASE 9 + +/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */ +#define YYTRANSLATE(x) ((unsigned)(x) <= 261 ? yytranslate[x] : 12) + +/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */ +static const char yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 8, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 3, 4, 5, + 6, 7 +}; + +#if YYDEBUG +static const short yyprhs[] = +{ + 0, 0, 1, 4, 9, 11, 13 +}; +static const short yyrhs[] = +{ + -1, 10, 9, 0, 3, 11, 7, 8, 0, 5, + 0, 6, 0, 4, 0 +}; + +#endif + +#if YYDEBUG +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const short yyrline[] = +{ + 0, 18, 19, 21, 28, 28, 28 +}; +#endif + + +#if (YYDEBUG) || defined YYERROR_VERBOSE + +/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */ +static const char *const yytname[] = +{ + "$", "error", "$undefined.", "SET", "HOST", "USER", "PASSWORD", "STRING", + "';'", "input", "statement", "variable", 0 +}; +#endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const short yyr1[] = +{ + 0, 9, 9, 10, 11, 11, 11 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const short yyr2[] = +{ + 0, 0, 2, 4, 1, 1, 1 +}; + +/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE + doesn't specify something else to do. Zero means the default is an + error. */ +static const short yydefact[] = +{ + 1, 0, 1, 6, 4, 5, 0, 2, 0, 3, + 0, 0, 0 +}; + +static const short yydefgoto[] = +{ + 7, 2, 6 +}; + +static const short yypact[] = +{ + 0, -4, 0,-32768,-32768,-32768, -3,-32768, -2,-32768, + 5, 7,-32768 +}; + +static const short yypgoto[] = +{ + 8,-32768,-32768 +}; + + +#define YYLAST 8 + + +static const short yytable[] = +{ + 3, 4, 5, 1, 8, 11, 9, 12, 10 +}; + +static const short yycheck[] = +{ + 4, 5, 6, 3, 7, 0, 8, 0, 0 +}; +/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ +#line 3 "/store/share/bison/bison.simple" + +/* Skeleton output parser for bison, + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 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 @@ -23,8 +173,10 @@ This special exception was added by the Free Software Foundation in version 1.24 of Bison. */ -/* Written by Richard Stallman by simplifying the original so called - ``semantic'' parser. */ +/* This is the parser code that is written into each bison parser when + the %semantic_parser declaration is not specified in the grammar. + It was written by Richard Stallman by simplifying the hairy parser + used when %semantic_parser is specified. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local @@ -33,79 +185,7 @@ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ -/* Identify Bison output. */ -#define YYBISON 1 - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 0 - -/* Using locations. */ -#define YYLSP_NEEDED 0 - - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - SET = 258, - HOST = 259, - USER = 260, - PASSWORD = 261, - STRING = 262 - }; -#endif -#define SET 258 -#define HOST 259 -#define USER 260 -#define PASSWORD 261 -#define STRING 262 - - - - -/* Copy the first part of user declarations. */ -#line 8 "pwyacc.y" - -int yyerror(const char *msg); -int yylex(void); -int config_set_string_var(int var, const char *value); - - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -typedef int YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - - - -/* Copy the second part of user declarations. */ - - -/* Line 214 of yacc.c. */ -#line 106 "y.tab.c" - -#if ! defined (yyoverflow) || YYERROR_VERBOSE +#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE) /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -134,28 +214,37 @@ typedef int YYSTYPE; # define YYSTACK_ALLOC malloc # define YYSTACK_FREE free # endif -#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ +#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */ #if (! defined (yyoverflow) \ && (! defined (__cplusplus) \ - || (YYSTYPE_IS_TRIVIAL))) + || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { short yyss; YYSTYPE yyvs; - }; +# if YYLSP_NEEDED + YYLTYPE yyls; +# endif +}; /* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) +# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ -# define YYSTACK_BYTES(N) \ +# if YYLSP_NEEDED +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + + 2 * YYSTACK_GAP_MAX) +# else +# define YYSTACK_BYTES(N) \ ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAXIMUM) + + YYSTACK_GAP_MAX) +# endif /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ @@ -186,177 +275,13 @@ union yyalloc YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack, Stack, yysize); \ Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (0) #endif -#if defined (__STDC__) || defined (__cplusplus) - typedef signed char yysigned_char; -#else - typedef short yysigned_char; -#endif - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 8 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 7 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 9 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 4 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 7 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 12 - -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 262 - -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) - -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const unsigned char yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 8, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7 -}; - -#if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const unsigned char yyprhs[] = -{ - 0, 0, 3, 4, 7, 12, 14, 16 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yysigned_char yyrhs[] = -{ - 10, 0, -1, -1, 11, 10, -1, 3, 12, 7, - 8, -1, 5, -1, 6, -1, 4, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const unsigned char yyrline[] = -{ - 0, 18, 18, 19, 21, 28, 28, 28 -}; -#endif - -#if YYDEBUG || YYERROR_VERBOSE -/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "SET", "HOST", "USER", "PASSWORD", - "STRING", "';'", "$accept", "input", "statement", "variable", 0 -}; -#endif - -# ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ -static const unsigned short yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 59 -}; -# endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const unsigned char yyr1[] = -{ - 0, 9, 10, 10, 11, 12, 12, 12 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const unsigned char yyr2[] = -{ - 0, 2, 0, 2, 4, 1, 1, 1 -}; - -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const unsigned char yydefact[] = -{ - 2, 0, 0, 2, 7, 5, 6, 0, 1, 3, - 0, 4 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const yysigned_char yydefgoto[] = -{ - -1, 2, 3, 7 -}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -5 -static const yysigned_char yypact[] = -{ - 0, -4, 4, 0, -5, -5, -5, -2, -5, -5, - -1, -5 -}; - -/* YYPGOTO[NTERM-NUM]. */ -static const yysigned_char yypgoto[] = -{ - -5, 3, -5, -5 -}; - -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -1 -static const unsigned char yytable[] = -{ - 4, 5, 6, 1, 8, 10, 9, 11 -}; - -static const unsigned char yycheck[] = -{ - 4, 5, 6, 3, 0, 7, 3, 8 -}; - -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const unsigned char yystos[] = -{ - 0, 3, 10, 11, 4, 5, 6, 12, 0, 10, - 7, 8 -}; #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) # define YYSIZE_T __SIZE_TYPE__ @@ -376,34 +301,29 @@ static const unsigned char yystos[] = #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) +#define YYEMPTY -2 #define YYEOF 0 - #define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab +#define YYABORT goto yyabortlab #define YYERROR goto yyerrlab1 - /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ - #define YYFAIL goto yyerrlab - #define YYRECOVERING() (!!yyerrstatus) - #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ + yychar1 = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ { \ - yyerror ("syntax error: cannot back up");\ + yyerror ("syntax error: cannot back up"); \ YYERROR; \ } \ while (0) @@ -411,24 +331,41 @@ while (0) #define YYTERROR 1 #define YYERRCODE 256 + /* YYLLOC_DEFAULT -- Compute the default location (before the actions - are run). */ + are run). + + When YYLLOC_DEFAULT is run, CURRENT is set the location of the + first token. By default, to implement support for ranges, extend + its range to the last symbol. */ #ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - Current.first_line = Rhs[1].first_line; \ - Current.first_column = Rhs[1].first_column; \ - Current.last_line = Rhs[N].last_line; \ - Current.last_column = Rhs[N].last_column; +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + Current.last_line = Rhs[N].last_line; \ + Current.last_column = Rhs[N].last_column; #endif + /* YYLEX -- calling `yylex' with the right arguments. */ -#ifdef YYLEX_PARAM -# define YYLEX yylex (YYLEX_PARAM) -#else -# define YYLEX yylex () -#endif +#if YYPURE +# if YYLSP_NEEDED +# ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) +# else +# define YYLEX yylex (&yylval, &yylloc) +# endif +# else /* !YYLSP_NEEDED */ +# ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +# else +# define YYLEX yylex (&yylval) +# endif +# endif /* !YYLSP_NEEDED */ +#else /* !YYPURE */ +# define YYLEX yylex () +#endif /* !YYPURE */ + /* Enable debugging if requested. */ #if YYDEBUG @@ -443,93 +380,13 @@ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (0) - -# define YYDSYMPRINT(Args) \ -do { \ - if (yydebug) \ - yysymprint Args; \ -} while (0) - -# define YYDSYMPRINTF(Title, Token, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yysymprint (stderr, \ - Token, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) - -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (cinluded). | -`------------------------------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yy_stack_print (short *bottom, short *top) -#else -static void -yy_stack_print (bottom, top) - short *bottom; - short *top; -#endif -{ - YYFPRINTF (stderr, "Stack now"); - for (/* Nothing. */; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); - YYFPRINTF (stderr, "\n"); -} - -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (0) - - -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yy_reduce_print (int yyrule) -#else -static void -yy_reduce_print (yyrule) - int yyrule; -#endif -{ - int yyi; - unsigned int yylineno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", - yyrule - 1, yylineno); - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) - YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); - YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); -} - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (Rule); \ -} while (0) - /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) -# define YYDSYMPRINT(Args) -# define YYDSYMPRINTF(Title, Token, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ - /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 @@ -549,10 +406,8 @@ int yydebug; #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif - - -#if YYERROR_VERBOSE +#ifdef YYERROR_VERBOSE # ifndef yystrlen # if defined (__GLIBC__) && defined (_STRING_H) @@ -602,134 +457,86 @@ yystpcpy (yydest, yysrc) } # endif # endif - -#endif /* !YYERROR_VERBOSE */ - - - -#if YYDEBUG -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) -#else -static void -yysymprint (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE *yyvaluep; #endif -{ - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; - - if (yytype < YYNTOKENS) - { - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); -# ifdef YYPRINT - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# endif - } - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - - switch (yytype) - { - default: - break; - } - YYFPRINTF (yyoutput, ")"); -} - -#endif /* ! YYDEBUG */ -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yydestruct (int yytype, YYSTYPE *yyvaluep) -#else -static void -yydestruct (yytype, yyvaluep) - int yytype; - YYSTYPE *yyvaluep; -#endif -{ - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; - - switch (yytype) - { - - default: - break; - } -} +#line 315 "/store/share/bison/bison.simple" -/* Prevent warnings from -Wmissing-prototypes. */ + +/* The user can define YYPARSE_PARAM as the name of an argument to be passed + into yyparse. The argument should have type void *. + It should actually point to an object. + Grammar actions can access the variable by casting it + to the proper pointer type. */ #ifdef YYPARSE_PARAM # if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM); +# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM +# define YYPARSE_PARAM_DECL # else -int yyparse (); +# define YYPARSE_PARAM_ARG YYPARSE_PARAM +# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; # endif -#else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) +#else /* !YYPARSE_PARAM */ +# define YYPARSE_PARAM_ARG +# define YYPARSE_PARAM_DECL +#endif /* !YYPARSE_PARAM */ + +/* Prevent warning if -Wstrict-prototypes. */ +#ifdef __GNUC__ +# ifdef YYPARSE_PARAM +int yyparse (void *); +# else int yyparse (void); -#else -int yyparse (); +# endif #endif -#endif /* ! YYPARSE_PARAM */ +/* YY_DECL_VARIABLES -- depending whether we use a pure parser, + variables are global, or local to YYPARSE. */ - -/* The lookahead symbol. */ -int yychar; - -/* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; - -/* Number of syntax errors so far. */ +#define YY_DECL_NON_LSP_VARIABLES \ +/* The lookahead symbol. */ \ +int yychar; \ + \ +/* The semantic value of the lookahead symbol. */ \ +YYSTYPE yylval; \ + \ +/* Number of parse errors so far. */ \ int yynerrs; - - -/*----------. -| yyparse. | -`----------*/ - -#ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM) -# else -int yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -# endif -#else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) -int -yyparse (void) +#if YYLSP_NEEDED +# define YY_DECL_VARIABLES \ +YY_DECL_NON_LSP_VARIABLES \ + \ +/* Location data for the lookahead symbol. */ \ +YYLTYPE yylloc; #else -int -yyparse () +# define YY_DECL_VARIABLES \ +YY_DECL_NON_LSP_VARIABLES +#endif -#endif -#endif + +/* If nonreentrant, generate the variables here. */ + +#if !YYPURE +YY_DECL_VARIABLES +#endif /* !YYPURE */ + +int +yyparse (YYPARSE_PARAM_ARG) + YYPARSE_PARAM_DECL { - + /* If reentrant, generate the variables here. */ +#if YYPURE + YY_DECL_VARIABLES +#endif /* !YYPURE */ + register int yystate; register int yyn; int yyresult; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* Lookahead token as an internal (translated) token number. */ - int yytoken = 0; + int yychar1 = 0; /* Three stacks and their tools: `yyss': related to states, @@ -739,7 +546,7 @@ yyparse () Refer to the stacks thru separate pointers, to allow yyoverflow to reallocate them elsewhere. */ - /* The state stack. */ + /* The state stack. */ short yyssa[YYINITDEPTH]; short *yyss = yyssa; register short *yyssp; @@ -749,19 +556,31 @@ yyparse () YYSTYPE *yyvs = yyvsa; register YYSTYPE *yyvsp; +#if YYLSP_NEEDED + /* The location stack. */ + YYLTYPE yylsa[YYINITDEPTH]; + YYLTYPE *yyls = yylsa; + YYLTYPE *yylsp; +#endif - -#define YYPOPSTACK (yyvsp--, yyssp--) +#if YYLSP_NEEDED +# define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) +#else +# define YYPOPSTACK (yyvsp--, yyssp--) +#endif YYSIZE_T yystacksize = YYINITDEPTH; + /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; - +#if YYLSP_NEEDED + YYLTYPE yyloc; +#endif /* When reducing, the number of symbols on the RHS of the reduced - rule. */ + rule. */ int yylen; YYDPRINTF ((stderr, "Starting parse\n")); @@ -778,7 +597,9 @@ yyparse () yyssp = yyss; yyvsp = yyvs; - +#if YYLSP_NEEDED + yylsp = yyls; +#endif goto yysetstate; /*------------------------------------------------------------. @@ -793,7 +614,7 @@ yyparse () yysetstate: *yyssp = yystate; - if (yyss + yystacksize - 1 <= yyssp) + if (yyssp >= yyss + yystacksize - 1) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; @@ -806,17 +627,24 @@ yyparse () YYSTYPE *yyvs1 = yyvs; short *yyss1 = yyss; - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ + data in use in that stack, in bytes. */ +# if YYLSP_NEEDED + YYLTYPE *yyls1 = yyls; + /* This used to be a conditional around just the two extra args, + but that might be undefined if yyoverflow is a macro. */ yyoverflow ("parser stack overflow", &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), - + &yyls1, yysize * sizeof (*yylsp), &yystacksize); - + yyls = yyls1; +# else + yyoverflow ("parser stack overflow", + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); +# endif yyss = yyss1; yyvs = yyvs1; } @@ -825,10 +653,10 @@ yyparse () goto yyoverflowlab; # else /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) + if (yystacksize >= YYMAXDEPTH) goto yyoverflowlab; yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) + if (yystacksize > YYMAXDEPTH) yystacksize = YYMAXDEPTH; { @@ -839,8 +667,10 @@ yyparse () goto yyoverflowlab; YYSTACK_RELOCATE (yyss); YYSTACK_RELOCATE (yyvs); - -# undef YYSTACK_RELOCATE +# if YYLSP_NEEDED + YYSTACK_RELOCATE (yyls); +# endif +# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } @@ -849,12 +679,14 @@ yyparse () yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - +#if YYLSP_NEEDED + yylsp = yyls + yysize - 1; +#endif YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); - if (yyss + yystacksize - 1 <= yyssp) + if (yyssp >= yyss + yystacksize - 1) YYABORT; } @@ -862,6 +694,7 @@ yyparse () goto yybackup; + /*-----------. | yybackup. | `-----------*/ @@ -874,55 +707,88 @@ yybackup: /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) + if (yyn == YYFLAG) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + /* yychar is either YYEMPTY or YYEOF + or a valid token in external form. */ + if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } - if (yychar <= YYEOF) + /* Convert token to internal form (in yychar1) for indexing tables with */ + + if (yychar <= 0) /* This means end of input. */ { - yychar = yytoken = YYEOF; + yychar1 = 0; + yychar = YYEOF; /* Don't call YYLEX any more */ + YYDPRINTF ((stderr, "Now at end of input.\n")); } else { - yytoken = YYTRANSLATE (yychar); - YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); + yychar1 = YYTRANSLATE (yychar); + +#if YYDEBUG + /* We have to keep this `#if YYDEBUG', since we use variables + which are defined only if `YYDEBUG' is set. */ + if (yydebug) + { + YYFPRINTF (stderr, "Next token is %d (%s", + yychar, yytname[yychar1]); + /* Give the individual parser a way to print the precise + meaning of a token, for further debugging info. */ +# ifdef YYPRINT + YYPRINT (stderr, yychar, yylval); +# endif + YYFPRINTF (stderr, ")\n"); + } +#endif } - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + yyn += yychar1; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) goto yydefault; + yyn = yytable[yyn]; - if (yyn <= 0) + + /* yyn is what to do for this token type in this state. + Negative => reduce, -yyn is rule number. + Positive => shift, yyn is new state. + New state is final state => don't bother to shift, + just return success. + 0, or most negative number => error. */ + + if (yyn < 0) { - if (yyn == 0 || yyn == YYTABLE_NINF) + if (yyn == YYFLAG) goto yyerrlab; yyn = -yyn; goto yyreduce; } + else if (yyn == 0) + goto yyerrlab; if (yyn == YYFINAL) YYACCEPT; /* Shift the lookahead token. */ - YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); + YYDPRINTF ((stderr, "Shifting token %d (%s), ", + yychar, yytname[yychar1])); /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval; - +#if YYLSP_NEEDED + *++yylsp = yylloc; +#endif /* Count tokens shifted since error; after three, turn off error status. */ @@ -953,43 +819,75 @@ yyreduce: /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison + Otherwise, the following line sets YYVAL to the semantic value of + the lookahead token. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; +#if YYLSP_NEEDED + /* Similarly for the default location. Let the user run additional + commands if for instance locations are ranges. */ + yyloc = yylsp[1-yylen]; + YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); +#endif - YY_REDUCE_PRINT (yyn); - switch (yyn) +#if YYDEBUG + /* We have to keep this `#if YYDEBUG', since we use variables which + are defined only if `YYDEBUG' is set. */ + if (yydebug) { - case 4: + int yyi; + + YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", + yyn, yyrline[yyn]); + + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++) + YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); + YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]); + } +#endif + + switch (yyn) { + +case 3: #line 22 "pwyacc.y" - { +{ yyval = config_set_string_var(yyvsp[-2], (const char *)yyvsp[-1]); } break; - - case 7: +case 6: #line 29 "pwyacc.y" - { yyval = yyvsp[0]; } +{ yyval = yyvsp[0]; } break; +} +#line 705 "/store/share/bison/bison.simple" - } - -/* Line 991 of yacc.c. */ -#line 983 "y.tab.c" yyvsp -= yylen; yyssp -= yylen; +#if YYLSP_NEEDED + yylsp -= yylen; +#endif - - YY_STACK_PRINT (yyss, yyssp); +#if YYDEBUG + if (yydebug) + { + short *yyssp1 = yyss - 1; + YYFPRINTF (stderr, "state stack now"); + while (yyssp1 != yyssp) + YYFPRINTF (stderr, " %d", *++yyssp1); + YYFPRINTF (stderr, "\n"); + } +#endif *++yyvsp = yyval; - +#if YYLSP_NEEDED + *++yylsp = yyloc; +#endif /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule @@ -997,11 +895,11 @@ yyreduce: yyn = yyr1[yyn]; - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yypgoto[yyn - YYNTBASE] + *yyssp; + if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else - yystate = yydefgoto[yyn - YYNTOKENS]; + yystate = yydefgoto[yyn - YYNTBASE]; goto yynewstate; @@ -1014,13 +912,13 @@ yyerrlab: if (!yyerrstatus) { ++yynerrs; -#if YYERROR_VERBOSE + +#ifdef YYERROR_VERBOSE yyn = yypact[yystate]; - if (YYPACT_NINF < yyn && yyn < YYLAST) + if (yyn > YYFLAG && yyn < YYLAST) { YYSIZE_T yysize = 0; - int yytype = YYTRANSLATE (yychar); char *yymsg; int yyx, yycount; @@ -1029,15 +927,15 @@ yyerrlab: YYCHECK. */ for (yyx = yyn < 0 ? -yyn : 0; yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + if (yycheck[yyx + yyn] == yyx) yysize += yystrlen (yytname[yyx]) + 15, yycount++; - yysize += yystrlen ("syntax error, unexpected ") + 1; - yysize += yystrlen (yytname[yytype]); + yysize += yystrlen ("parse error, unexpected ") + 1; + yysize += yystrlen (yytname[YYTRANSLATE (yychar)]); yymsg = (char *) YYSTACK_ALLOC (yysize); if (yymsg != 0) { - char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); - yyp = yystpcpy (yyp, yytname[yytype]); + char *yyp = yystpcpy (yymsg, "parse error, unexpected "); + yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]); if (yycount < 5) { @@ -1045,7 +943,7 @@ yyerrlab: for (yyx = yyn < 0 ? -yyn : 0; yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + if (yycheck[yyx + yyn] == yyx) { const char *yyq = ! yycount ? ", expecting " : " or "; yyp = yystpcpy (yyp, yyq); @@ -1057,92 +955,102 @@ yyerrlab: YYSTACK_FREE (yymsg); } else - yyerror ("syntax error; also virtual memory exhausted"); + yyerror ("parse error; also virtual memory exhausted"); } else -#endif /* YYERROR_VERBOSE */ - yyerror ("syntax error"); +#endif /* defined (YYERROR_VERBOSE) */ + yyerror ("parse error"); } + goto yyerrlab1; - +/*--------------------------------------------------. +| yyerrlab1 -- error raised explicitly by an action | +`--------------------------------------------------*/ +yyerrlab1: if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ - /* Return failure if at end of input. */ + /* return failure if at end of input */ if (yychar == YYEOF) - { - /* Pop the error token. */ - YYPOPSTACK; - /* Pop the rest of the stack. */ - while (yyss < yyssp) - { - YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); - yydestruct (yystos[*yyssp], yyvsp); - YYPOPSTACK; - } - YYABORT; - } - - YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); - yydestruct (yytoken, &yylval); + YYABORT; + YYDPRINTF ((stderr, "Discarding token %d (%s).\n", + yychar, yytname[yychar1])); yychar = YYEMPTY; - } /* Else will try to reuse lookahead token after shifting the error token. */ - goto yyerrlab2; + + yyerrstatus = 3; /* Each real token shifted decrements this */ + + goto yyerrhandle; -/*----------------------------------------------------. -| yyerrlab1 -- error raised explicitly by an action. | -`----------------------------------------------------*/ -yyerrlab1: +/*-------------------------------------------------------------------. +| yyerrdefault -- current state does not do anything special for the | +| error token. | +`-------------------------------------------------------------------*/ +yyerrdefault: +#if 0 + /* This is wrong; only states that explicitly want error tokens + should shift them. */ - /* Suppress GCC warning that yyerrlab1 is unused when no action - invokes YYERROR. */ -#if defined (__GNUC_MINOR__) && 2093 <= (__GNUC__ * 1000 + __GNUC_MINOR__) - __attribute__ ((__unused__)) + /* If its default is to accept any token, ok. Otherwise pop it. */ + yyn = yydefact[yystate]; + if (yyn) + goto yydefault; #endif - goto yyerrlab2; - - /*---------------------------------------------------------------. -| yyerrlab2 -- pop states until the error token can be shifted. | +| yyerrpop -- pop the current state because it cannot handle the | +| error token | `---------------------------------------------------------------*/ -yyerrlab2: - yyerrstatus = 3; /* Each real token shifted decrements this. */ +yyerrpop: + if (yyssp == yyss) + YYABORT; + yyvsp--; + yystate = *--yyssp; +#if YYLSP_NEEDED + yylsp--; +#endif - for (;;) +#if YYDEBUG + if (yydebug) { - yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); - yydestruct (yystos[yystate], yyvsp); - yyvsp--; - yystate = *--yyssp; - - YY_STACK_PRINT (yyss, yyssp); + short *yyssp1 = yyss - 1; + YYFPRINTF (stderr, "Error: state stack now"); + while (yyssp1 != yyssp) + YYFPRINTF (stderr, " %d", *++yyssp1); + YYFPRINTF (stderr, "\n"); } +#endif + +/*--------------. +| yyerrhandle. | +`--------------*/ +yyerrhandle: + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yyerrdefault; + + yyn += YYTERROR; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) + goto yyerrdefault; + + yyn = yytable[yyn]; + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrpop; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrpop; if (yyn == YYFINAL) YYACCEPT; @@ -1150,7 +1058,9 @@ yyerrlab2: YYDPRINTF ((stderr, "Shifting error token, ")); *++yyvsp = yylval; - +#if YYLSP_NEEDED + *++yylsp = yylloc; +#endif yystate = yyn; goto yynewstate; @@ -1170,15 +1080,13 @@ yyabortlab: yyresult = 1; goto yyreturn; -#ifndef yyoverflow -/*----------------------------------------------. -| yyoverflowlab -- parser overflow comes here. | -`----------------------------------------------*/ +/*---------------------------------------------. +| yyoverflowab -- parser overflow comes here. | +`---------------------------------------------*/ yyoverflowlab: yyerror ("parser stack overflow"); yyresult = 2; /* Fall through. */ -#endif yyreturn: #ifndef yyoverflow @@ -1187,9 +1095,6 @@ yyreturn: #endif return yyresult; } - - #line 32 "pwyacc.y" - diff --git a/pwyacc.h b/pwyacc.h index b51f0b8..a1e3432 100644 --- a/pwyacc.h +++ b/pwyacc.h @@ -1,58 +1,17 @@ -/* A Bison parser, made by GNU Bison 1.875. */ +#ifndef BISON_Y_TAB_H +# define BISON_Y_TAB_H -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc. +# ifndef YYSTYPE +# define YYSTYPE int +# define YYSTYPE_IS_TRIVIAL 1 +# endif +# define SET 257 +# define HOST 258 +# define USER 259 +# define PASSWORD 260 +# define STRING 261 - 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, 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. - - 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., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - SET = 258, - HOST = 259, - USER = 260, - PASSWORD = 261, - STRING = 262 - }; -#endif -#define SET 258 -#define HOST 259 -#define USER 260 -#define PASSWORD 261 -#define STRING 262 - - - - -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -typedef int YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif extern YYSTYPE yylval; - - +#endif /* not BISON_Y_TAB_H */