From 12a85fff011904123f3ad00f3392ddd74eb82b30 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 23 Mar 2006 20:28:23 +0000 Subject: [PATCH] Renamed getline() to ctdl_getline() due to a conflict with a system library function somewhere. --- citadel/client_chat.c | 2 +- citadel/commands.c | 8 +- citadel/messages.c | 12 +-- citadel/parsedate.c | 176 +++++++++++++++++++++++++----------------- 4 files changed, 118 insertions(+), 80 deletions(-) diff --git a/citadel/client_chat.c b/citadel/client_chat.c index a98b4bdfc..c1cc8f44f 100644 --- a/citadel/client_chat.c +++ b/citadel/client_chat.c @@ -49,7 +49,7 @@ #define MIN(a, b) ((a) < (b) ? (a) : (b)) extern char temp[]; -void getline(char *, int); +void ctdl_getline(char *, int); char last_paged[SIZ] = ""; diff --git a/citadel/commands.c b/citadel/commands.c index 0494afb08..78fd4f5c6 100644 --- a/citadel/commands.c +++ b/citadel/commands.c @@ -567,7 +567,7 @@ int yesno_d(int d) /* Gets a line from the terminal */ /* string == Pointer to string buffer */ /* lim == Maximum length - if negative, no-show */ -void getline(char *string, int lim) +void ctdl_getline(char *string, int lim) { int a, b; char flag = 0; @@ -646,7 +646,7 @@ void strprompt(char *prompt, char *str, int len) color(DIM_WHITE); scr_printf(": "); color(BRIGHT_CYAN); - getline(buf, len); + ctdl_getline(buf, len); if (buf[0] != 0) strcpy(str, buf); color(DIM_WHITE); @@ -711,7 +711,7 @@ void newprompt(char *prompt, char *str, int len) color(BRIGHT_MAGENTA); scr_printf("%s", prompt); color(DIM_MAGENTA); - getline(str, len); + ctdl_getline(str, len); color(DIM_WHITE); } @@ -1151,7 +1151,7 @@ int getcmd(CtdlIPC *ipc, char *argbuf) if (cmdmatch(cmdbuf, cptr, 5)) { /* We've found our command. */ if (requires_string(cptr, cmdpos)) { - getline(argbuf, 32); + ctdl_getline(argbuf, 32); } else { scr_printf("\n"); } diff --git a/citadel/messages.c b/citadel/messages.c index 18cebfcdf..fea2a7c06 100644 --- a/citadel/messages.c +++ b/citadel/messages.c @@ -61,7 +61,7 @@ struct cittext { void stty_ctdl(int cmd); int haschar(const char *st, int ch); -void getline(char *string, int lim); +void ctdl_getline(char *string, int lim); int file_checksum(char *filename); void progress(CtdlIPC* ipc, unsigned long curr, unsigned long cmax); @@ -746,12 +746,12 @@ void replace_string(char *filename, long int startpos) long msglen = 0L; scr_printf("Enter text to be replaced:\n: "); - getline(srch_str, (sizeof(srch_str)-1) ); + ctdl_getline(srch_str, (sizeof(srch_str)-1) ); if (strlen(srch_str) == 0) return; scr_printf("Enter text to replace it with:\n: "); - getline(rplc_str, (sizeof(rplc_str)-1) ); + ctdl_getline(rplc_str, (sizeof(rplc_str)-1) ); fp = fopen(filename, "r+"); if (fp == NULL) @@ -1156,7 +1156,7 @@ int entmsg(CtdlIPC *ipc, strcpy(buf, reply_to); } else { scr_printf("Enter recipient: "); - getline(buf, (SIZ-100) ); + ctdl_getline(buf, (SIZ-100) ); if (strlen(buf) == 0) return (1); } @@ -1307,10 +1307,10 @@ void process_quote(void) scr_printf("%2d %s", ++line, buf); } scr_printf("Begin quoting at [ 1] : "); - getline(buf, 3); + ctdl_getline(buf, 3); qstart = (buf[0] == 0) ? (1) : atoi(buf); scr_printf(" End quoting at [%d] : ", line); - getline(buf, 3); + ctdl_getline(buf, 3); qend = (buf[0] == 0) ? (line) : atoi(buf); rewind(qfile); line = 0; diff --git a/citadel/parsedate.c b/citadel/parsedate.c index b7845b2fe..39a3651a8 100644 --- a/citadel/parsedate.c +++ b/citadel/parsedate.c @@ -1,7 +1,7 @@ -/* A Bison parser, made by GNU Bison 1.875. */ +/* A Bison parser, made by GNU Bison 1.875c. */ /* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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 @@ -223,7 +223,7 @@ typedef union YYSTYPE { enum _MERIDIAN Meridian; } YYSTYPE; /* Line 191 of yacc.c. */ -#line 226 "y.tab.c" +#line 227 "y.tab.c" # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 @@ -235,22 +235,29 @@ typedef union YYSTYPE { /* Line 214 of yacc.c. */ -#line 238 "y.tab.c" +#line 239 "y.tab.c" #if ! defined (yyoverflow) || YYERROR_VERBOSE +# ifndef YYFREE +# define YYFREE free +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# endif + /* The parser invokes alloca or malloc; define the necessary symbols. */ -# if YYSTACK_USE_ALLOCA -# define YYSTACK_ALLOC alloca +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# define YYSTACK_ALLOC alloca +# endif # else -# ifndef YYSTACK_USE_ALLOCA -# if defined (alloca) || defined (_ALLOCA_H) -# define YYSTACK_ALLOC alloca -# else -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# endif +# if defined (alloca) || defined (_ALLOCA_H) +# define YYSTACK_ALLOC alloca +# else +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca # endif # endif # endif @@ -263,15 +270,15 @@ typedef union YYSTYPE { # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # endif -# define YYSTACK_ALLOC malloc -# define YYSTACK_FREE free +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE # endif #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ #if (! defined (yyoverflow) \ && (! defined (__cplusplus) \ - || (YYSTYPE_IS_TRIVIAL))) + || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc @@ -292,7 +299,7 @@ union yyalloc /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY -# if 1 < __GNUC__ +# if defined (__GNUC__) && 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else @@ -425,10 +432,10 @@ static const unsigned short yyrline[] = First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - "$end", "error", "$undefined", "tDAY", "tDAYZONE", "tMERIDIAN", "tMONTH", - "tMONTH_UNIT", "tSEC_UNIT", "tSNUMBER", "tUNUMBER", "tZONE", "':'", - "'/'", "','", "$accept", "spec", "item", "time", "zone", "numzone", - "date", "rel", "o_merid", 0 + "$end", "error", "$undefined", "tDAY", "tDAYZONE", "tMERIDIAN", + "tMONTH", "tMONTH_UNIT", "tSEC_UNIT", "tSNUMBER", "tUNUMBER", "tZONE", + "':'", "'/'", "','", "$accept", "spec", "item", "time", "zone", + "numzone", "date", "rel", "o_merid", 0 }; #endif @@ -553,7 +560,7 @@ static const unsigned char yystos[] = #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab -#define YYERROR goto yyerrlab1 +#define YYERROR goto yyerrorlab /* Like YYERROR except do call yyerror. This remains here temporarily @@ -588,11 +595,11 @@ while (0) are run). */ #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).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) #endif /* YYLEX -- calling `yylex' with the right arguments. */ @@ -636,7 +643,7 @@ do { \ /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (cinluded). | +| TOP (included). | `------------------------------------------------------------------*/ #if defined (__STDC__) || defined (__cplusplus) @@ -676,9 +683,9 @@ yy_reduce_print (yyrule) #endif { int yyi; - unsigned int yylineno = yyrline[yyrule]; + unsigned int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", - yyrule - 1, yylineno); + yyrule - 1, yylno); /* Print the symbols being reduced, and their result. */ for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); @@ -715,7 +722,7 @@ int yydebug; SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ -#if YYMAXDEPTH == 0 +#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 # undef YYMAXDEPTH #endif @@ -1402,8 +1409,8 @@ yyreduce: } -/* Line 999 of yacc.c. */ -#line 1406 "y.tab.c" +/* Line 1000 of yacc.c. */ +#line 1414 "y.tab.c" yyvsp -= yylen; yyssp -= yylen; @@ -1444,18 +1451,33 @@ yyerrlab: { YYSIZE_T yysize = 0; int yytype = YYTRANSLATE (yychar); + const char* yyprefix; char *yymsg; - int yyx, yycount; + int yyx; - yycount = 0; /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ - for (yyx = yyn < 0 ? -yyn : 0; - yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 0; + + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - yysize += yystrlen (yytname[yyx]) + 15, yycount++; - yysize += yystrlen ("syntax error, unexpected ") + 1; - yysize += yystrlen (yytname[yytype]); + { + yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); + yycount += 1; + if (yycount == 5) + { + yysize = 0; + break; + } + } + yysize += (sizeof ("syntax error, unexpected ") + + yystrlen (yytname[yytype])); yymsg = (char *) YYSTACK_ALLOC (yysize); if (yymsg != 0) { @@ -1464,16 +1486,13 @@ yyerrlab: if (yycount < 5) { - yycount = 0; - for (yyx = yyn < 0 ? -yyn : 0; - yyx < (int) (sizeof (yytname) / sizeof (char *)); - yyx++) + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { - const char *yyq = ! yycount ? ", expecting " : " or "; - yyp = yystpcpy (yyp, yyq); + yyp = yystpcpy (yyp, yyprefix); yyp = yystpcpy (yyp, yytname[yyx]); - yycount++; + yyprefix = " or "; } } yyerror (yymsg); @@ -1494,25 +1513,27 @@ yyerrlab: /* If just tried and failed to reuse lookahead token after an error, discard it. */ - /* Return failure if at end of input. */ - if (yychar == YYEOF) + 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; + /* If at end of input, pop the error token, + then the rest of the stack, then return failure. */ + if (yychar == YYEOF) + for (;;) + { + YYPOPSTACK; + if (yyssp == yyss) + YYABORT; + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[*yyssp], yyvsp); + } } + else + { + YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); + yydestruct (yytoken, &yylval); + yychar = YYEMPTY; - YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); - yydestruct (yytoken, &yylval); - yychar = YYEMPTY; - + } } /* Else will try to reuse lookahead token after shifting the error @@ -1520,9 +1541,27 @@ yyerrlab: goto yyerrlab1; -/*----------------------------------------------------. -| yyerrlab1 -- error raised explicitly by an action. | -`----------------------------------------------------*/ +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + +#ifdef __GNUC__ + /* Pacify GCC when the user code never invokes YYERROR and the label + yyerrorlab therefore never appears in user code. */ + if (0) + goto yyerrorlab; +#endif + + yyvsp -= yylen; + yyssp -= yylen; + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ @@ -1546,9 +1585,8 @@ yyerrlab1: YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); yydestruct (yystos[yystate], yyvsp); - yyvsp--; - yystate = *--yyssp; - + YYPOPSTACK; + yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } -- 2.30.2