X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=parser.c;h=ade124e1f64afd09349533171b7fd0c144aa0016;hb=8adc516688947b38e6c89f492d19d45f8db09ba6;hp=5157f39819a6771333ebd0bff67b768cef187273;hpb=d4ad0c3c0cda3b4dc9182581aa9aae4b5758649b;p=userv.git diff --git a/parser.c b/parser.c index 5157f39..ade124e 100644 --- a/parser.c +++ b/parser.c @@ -6,11 +6,12 @@ * about m4 quoting &c., but we have to #include it so that the C * objects from the lexer are available. * - * Copyright (C)1996-1999,2001,2006,2012 Ian Jackson + * userv is copyright Ian Jackson and other contributors. + * See README for full authorship information. * * This 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 + * 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 @@ -19,8 +20,7 @@ * General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with userv; if not, write to the Free Software - * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * along with userv; if not, see . */ static int parse_file(const char *string, int *didexist); @@ -205,6 +205,8 @@ const char *printtoken(int token) { return buf; } else if (token & tokt_number) { snyprintf(buf,sizeof(buf),"number %d",lr_min); return buf; + } else if (token & tokt_fdrange && token & tokr_word) { + snyprintf(buf,sizeof(buf),"fd %s",buf); return buf; } else if (token & tokt_fdrange && lr_max==-1) { snyprintf(buf,sizeof(buf),"fdrange %d-",lr_min); return buf; } else if (token & tokt_fdrange) { @@ -589,9 +591,7 @@ int pcf_range(int ctoken, char *const *pv, int *rtrue) { char *ep; unsigned long v; - r= pa_mwsp(); if (r) return r; mintoken= pa_numberdollar(&min); if (mintoken == tokv_error) return mintoken; - r= pa_mwsp(); if (r) return r; maxtoken= pa_numberdollar(&max); if (maxtoken == tokv_error) return maxtoken; r= pa_mnl(); if (r) return r; for (pp= pv; *pp; pp++) { @@ -995,7 +995,7 @@ int df_includedirectory(int dtoken) { return parseerrprint("unable to open directory `%s': %s",cpget,strerror(errno)); cp= xstrsave(cpget); cpl= strlen(cp); - while ((de= readdir(d))) { + while ((errno=0, de= readdir(d))) { tel= strlen(de->d_name); if (!tel) continue; p= de->d_name; @@ -1014,6 +1014,12 @@ int df_includedirectory(int dtoken) { goto x_err; } } + if (errno) { + parseerrprint("error reading directory `%s': %s",cp,strerror(errno)); + closedir(d); + free(cp); + return tokv_error; + } if (closedir(d)) { parseerrprint("error closing directory `%s': %s",cp,strerror(errno)); free(cp); @@ -1028,6 +1034,15 @@ x_err: return r; } +static int oldquote = 0; + +int dfg_lookupquotemode(int dtoken) { + int r; + r= pa_mnl(); if (r) return r; + oldquote = dtoken == tokv_word_includelookupquoteold; + return r; +} + int df_includelookup(int dtoken) { static char *buildbuf=0; int buildbuflen=0; @@ -1079,9 +1094,11 @@ int df_includelookup(int dtoken) { if (c=='/') { *q++= ':'; c= '-'; - } else if (!((c >= '0' && c <= '9') || + } else if (oldquote ? + !((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || - c == '-' || c == '_')) { + c == '-' || c == '_') : + (c==':')) { *q++= ':'; } *q++= c;