From 16f84dac4d414312e41433f7ae74aecc45166806 Mon Sep 17 00:00:00 2001 From: Ralph Corderoy Date: Sat, 22 Oct 2016 16:17:42 +0100 Subject: [PATCH] Have ruserpass() return TOK_EOF and put "" in the token table. Gives 0 a name and removes a little logic. --- sbr/ruserpass.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sbr/ruserpass.c b/sbr/ruserpass.c index 610f32a5..f7f01792 100644 --- a/sbr/ruserpass.c +++ b/sbr/ruserpass.c @@ -26,6 +26,7 @@ static FILE *cfile; +#define TOK_EOF 0 #define DEFAULT 1 #define LOGIN 2 #define PASSWD 3 @@ -42,6 +43,7 @@ struct toktab { }; static struct toktab toktabs[] = { + { "", TOK_EOF }, { "default", DEFAULT }, { "login", LOGIN }, { "password", PASSWD }, @@ -180,12 +182,12 @@ token(char *tokval) struct toktab *t; if (feof(cfile)) - return (0); + return TOK_EOF; while ((c = getc(cfile)) != EOF && (c == '\n' || c == '\t' || c == ' ' || c == ',')) continue; if (c == EOF) - return (0); + return TOK_EOF; cp = tokval; if (c == '"') { while ((c = getc(cfile)) != EOF && c != '"') { @@ -211,8 +213,6 @@ token(char *tokval) } } *cp = 0; - if (tokval[0] == 0) - return (0); for (t = toktabs; t->tokstr; t++) if (!strcmp(t->tokstr, tokval)) return (t->tval); -- 2.56.0