#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuninitialized"
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
-#include <ctype.h>
-#include <errno.h>
#include "k5-int.h"
+#include <ctype.h>
struct param {
krb5_int32 delta;
char *p;
};
-#define YYPARSE_PARAM tmv
-
#define MAX_TIME KRB5_INT32_MAX
#define MIN_TIME KRB5_INT32_MIN
res = (a) + (b)
-#define OUT_D ((struct param *)tmv)->delta
+#define OUT_D tmv->delta
#define DO(D,H,M,S) \
{ \
/* Overflow testing - this does not handle negative values well.. */ \
DO_SUM(OUT_D, OUT_D, S); \
}
-static int mylex (int *, char **);
-#define YYLEX_PARAM (&((struct param *)tmv)->p)
+static int mylex(int *intp, struct param *tmv);
#undef yylex
#define yylex(U, P) mylex (&(U)->val, (P))
#undef yyerror
-#define yyerror(MSG)
+#define yyerror(tmv, msg)
-static int yyparse (void *);
+static int yyparse(struct param *);
%}
-%pure_parser
-
-%union { int val; }
+%union {int val;}
+%parse-param {struct param *tmv}
+%lex-param {struct param *tmv}
+%define api.pure
-%token <val> NUM LONGNUM OVERFLOW
+%token <val> tok_NUM tok_LONGNUM tok_OVERFLOW
%token '-' ':' 'd' 'h' 'm' 's' tok_WS
%type <val> num opt_hms opt_ms opt_s wsnum posnum
%%
start: deltat;
-posnum: NUM | LONGNUM ;
+posnum: tok_NUM | tok_LONGNUM ;
num: posnum | '-' posnum { $$ = - $2; } ;
ws: /* nothing */ | tok_WS ;
wsnum: ws num { $$ = $2; }
- | ws OVERFLOW { YYERROR; };
+ | ws tok_OVERFLOW { YYERROR; };
deltat:
- wsnum 'd' opt_hms { DO ($1, 0, 0, $3); }
- | wsnum 'h' opt_ms { DO ( 0, $1, 0, $3); }
- | wsnum 'm' opt_s { DO ( 0, 0, $1, $3); }
- | wsnum 's' { DO ( 0, 0, 0, $1); }
- | wsnum '-' NUM ':' NUM ':' NUM { DO ($1, $3, $5, $7); }
- | wsnum ':' NUM ':' NUM { DO ( 0, $1, $3, $5); }
- | wsnum ':' NUM { DO ( 0, $1, $3, 0); }
- | wsnum { DO ( 0, 0, 0, $1); } /* default to 's' */
+ wsnum 'd' opt_hms { DO ($1, 0, 0, $3); }
+ | wsnum 'h' opt_ms { DO ( 0, $1, 0, $3); }
+ | wsnum 'm' opt_s { DO ( 0, 0, $1, $3); }
+ | wsnum 's' { DO ( 0, 0, 0, $1); }
+ | wsnum '-' tok_NUM ':' tok_NUM ':' tok_NUM { DO ($1, $3, $5, $7); }
+ | wsnum ':' tok_NUM ':' tok_NUM { DO ( 0, $1, $3, $5); }
+ | wsnum ':' tok_NUM { DO ( 0, $1, $3, 0); }
+ | wsnum { DO ( 0, 0, 0, $1); }
+ /* default to 's' */
;
opt_hms:
#endif
static int
-mylex (krb5_int32 *intp, char **pp)
+mylex(int *intp, struct param *tmv)
{
int num, c;
-#define P (*pp)
+#define P (tmv->p)
char *orig_p = P;
#ifdef isascii
num = c - '0';
while (isdigit ((int) *P)) {
if (num > MAX_TIME / 10)
- return OVERFLOW;
+ return tok_OVERFLOW;
num *= 10;
if (num > MAX_TIME - (*P - '0'))
- return OVERFLOW;
+ return tok_OVERFLOW;
num += *P++ - '0';
}
*intp = num;
- return (P - orig_p > 2) ? LONGNUM : NUM;
+ return (P - orig_p > 2) ? tok_LONGNUM : tok_NUM;
case ' ':
case '\t':
case '\n':