ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/hopm/trunk/src/config-lexer.l
(Generate patch)

Comparing hopm/trunk/src/config-lexer.l (file contents):
Revision 7711 by michael, Mon Sep 26 11:45:41 2016 UTC vs.
Revision 7716 by michael, Mon Sep 26 12:08:43 2016 UTC

# Line 65 | Line 65 | conf_yy_input(char *lbuf, unsigned int m
65    return !fgets(lbuf, max_size, conf_file) ? 0 : strlen(lbuf);
66   }
67  
68
68   %}
69  
70 < string                 \"[^\"\n]*[\"\n]
71 < include                \.include{WS}(\<.*\>|\".*\")
72 < comment                ("//"|"#").*
73 < whitespace             [ \t\r]*
70 > WS        [[:blank:]]*
71 > DIGIT     [[:digit:]]+
72 > COMMENT   ("//"|"#").*
73 > qstring   \"[^\"\n]*[\"\n]
74 > include   \.include{WS}(\<.*\>|\".*\")
75  
76   %%
77 <
78 < "/*"                    { ccomment(); }
79 <
80 < {comment}               ;
81 <
82 < {string}                {
83 <                           /* QSTRING from Hybrid7. Why re-invent the wheel? */
84 <
85 <                           if(yytext[yyleng-2] == '\\')
86 <                           {
87 <                              yyless(yyleng-1); /* return last quote */
88 <                              yymore();         /* append next string */
89 <                           }
90 <                           else
91 <                           {
92 <                              yylval.string = yytext+1;
93 <                              if(yylval.string[yyleng-2] != '"') ; /* log error */
94 <                              else
95 <                              {
96 <                                 int i,j;
97 <
98 <                                 yylval.string[yyleng-2] = '\0'; /* remove close
99 <                                                                  *  quote
100 <                                                                  */
101 <
102 <                                 for (j=i=0 ;yylval.string[i] != '\0'; i++,j++)
103 <                                 {
104 <                                    if (yylval.string[i] != '\\')
105 <                                    {
106 <                                       yylval.string[j] = yylval.string[i];
107 <                                    }
108 <                                    else
109 <                                    {
110 <                                        i++;
111 <                                        yylval.string[j] = yylval.string[i];
112 <                                    }
113 <                                 }
114 <                                 yylval.string[j] = '\0';
115 <                                 return STRING;
116 <                              }
117 <                           }
118 <                        }
77 > {include}       { conf_include(); }
78 > "/*"            { ccomment(); }
79 > \n.*            { strlcpy(linebuf, yytext + 1, sizeof(linebuf)); ++lineno; yyless(1); }
80 > {WS}            ;
81 > {COMMENT}       ;
82 > {DIGIT}         { yylval.number = atoi(yytext); return NUMBER; }
83 > {qstring}       { if (yytext[yyleng - 2] == '\\')
84 >                  {
85 >                    yyless(yyleng - 1);  /* Return last quote */
86 >                    yymore();  /* Append next string */
87 >                  }
88 >                  else
89 >                  {
90 >                    yylval.string = yytext + 1;
91 >
92 >                    if (yylval.string[yyleng - 2] != '"')
93 >                      log_printf("CONFIG ->Unterminated character string");
94 >                    else
95 >                    {
96 >                      unsigned int i = 0, j = 0;
97 >
98 >                      yylval.string[yyleng - 2] = '\0';  /* Remove close quote */
99 >
100 >                      for (; yylval.string[i] != '\0'; ++i, ++j)
101 >                      {
102 >                        if (yylval.string[i] != '\\')
103 >                          yylval.string[j] = yylval.string[i];
104 >                        else
105 >                        {
106 >                          ++i;
107 >
108 >                          if (yylval.string[i] == '\0')  /* XXX: should not happen */
109 >                          {
110 >                            log_printf("CONFIG -> Unterminated character string");
111 >                            break;
112 >                          }
113 >
114 >                          yylval.string[j] = yylval.string[i];
115 >                        }
116 >                      }
117 >
118 >                      yylval.string[j] = '\0';
119 >                      return STRING;
120 >                    }
121 >                  }
122 >                }
123  
124   AWAY                    { return AWAY;         }
125   BAN_UNKNOWN             { return BAN_UNKNOWN;  }
# Line 243 | Line 247 | DREAMBOX                {
247                          }
248  
249  
246
247 [0-9]+                  {
248                           yylval.number=atoi(yytext);
249                           return NUMBER;
250                        }
251
252
253
254
255
250   TRUE                     {
251                             yylval.number=1;
252                             return NUMBER;
# Line 283 | Line 277 | OFF                      {
277                             return NUMBER;
278                           }
279  
280 <
287 < \n.*                     {
288 <                           strlcpy(linebuf, yytext + 1, sizeof(linebuf));
289 <                           ++lineno;
290 <                           yyless(1);
291 <                         }
292 <
293 < {whitespace}            /* ignore whitespace */;
294 <
295 < .                       return yytext[0];
280 > .                       { return yytext[0]; }
281   <<EOF>>                 { if (conf_eof()) yyterminate(); }
282  
283   %%

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)