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 7716 by michael, Mon Sep 26 12:08:43 2016 UTC vs.
Revision 8563 by michael, Sun Sep 23 11:39:44 2018 UTC

# Line 1 | Line 1
1   /*
2   *  Copyright (c) 2002 Erik Fears
3 < *  Copyright (c) 2014-2016 ircd-hybrid development team
3 > *  Copyright (c) 2014-2018 ircd-hybrid development team
4   *
5   *  This program is free software; you can redistribute it and/or modify
6   *  it under the terms of the GNU General Public License as published by
# Line 20 | Line 20
20  
21   %option case-insensitive
22   %option noyywrap
23 + %option noinput
24   %option nounput
25   %option never-interactive
26  
27 + %x IN_COMMENT
28 +
29   %{
30   #include <stdio.h>
31   #include <string.h>
# Line 32 | Line 35
35   #include "config-parser.h"  /* autogenerated header file */
36   #include "log.h"
37  
38 + /* libopm includes */
39 + #include "libopm/src/opm_types.h"
40 +
41 + #undef YY_FATAL_ERROR
42 + #define YY_FATAL_ERROR(msg) conf_yy_fatal_error(msg)
43  
44   #undef YY_INPUT
45   #define YY_INPUT(buf,result,max_size) \
# Line 55 | Line 63 | static struct included_file
63   static unsigned int include_stack_ptr;
64  
65  
58 static void ccomment(void);
66   static void conf_include(void);
67   static int conf_eof(void);
68  
69   static int
70   conf_yy_input(char *lbuf, unsigned int max_size)
71   {
72 <  return !fgets(lbuf, max_size, conf_file) ? 0 : strlen(lbuf);
72 >  return fgets(lbuf, max_size, conf_file) == NULL ? 0 : strlen(lbuf);
73   }
74  
75 + static int
76 + conf_yy_fatal_error(const char *msg)
77 + {
78 +  return 0;
79 + }
80   %}
81  
82   WS        [[:blank:]]*
# Line 74 | Line 86 | qstring   \"[^\"\n]*[\"\n]
86   include   \.include{WS}(\<.*\>|\".*\")
87  
88   %%
89 +
90 + "/*"                { BEGIN IN_COMMENT; }
91 + <IN_COMMENT>"*/"    { BEGIN INITIAL;    }
92 + <IN_COMMENT>.       ;  /* Eat everything but a newline */
93 + <IN_COMMENT>\n      { ++lineno; }
94 + <IN_COMMENT><<EOF>> { BEGIN INITIAL; if (conf_eof()) yyterminate(); }
95 +
96   {include}       { conf_include(); }
78 "/*"            { ccomment(); }
97   \n.*            { strlcpy(linebuf, yytext + 1, sizeof(linebuf)); ++lineno; yyless(1); }
98   {WS}            ;
99   {COMMENT}       ;
# Line 121 | Line 139 | include   \.include{WS}(\<.*\>|\".*\")
139                    }
140                  }
141  
142 + ADDRESS_FAMILY          { return ADDRESS_FAMILY; }
143   AWAY                    { return AWAY;         }
144   BAN_UNKNOWN             { return BAN_UNKNOWN;  }
145   BLACKLIST               { return BLACKLIST;    }
# Line 136 | Line 155 | DNSBL_TO                { return DNSBL_T
155   EXEMPT                  { return EXEMPT;       }
156   FD                      { return FD;           }
157   INVITE                  { return INVITE;       }
158 + IPV4                    { return IPV4;         }
159 + IPV6                    { return IPV6;         }
160   IRC                     { return IRC;          }
161   KLINE                   { return KLINE;        }
162   KEY                     { return KEY;          }
# Line 282 | Line 303 | OFF                      {
303  
304   %%
305  
285
286 /* C-comment ignoring routine -kre*/
287 static void
288 ccomment(void)
289 {
290  int c = 0;
291
292  /* log(L_NOTICE, "got comment"); */
293  while (1)
294  {
295    while ((c = input()) != '*' && c != EOF)
296      if (c == '\n')
297        ++lineno;
298
299    if (c == '*')
300    {
301      while ((c = input()) == '*')
302        /* Nothing */ ;
303      if (c == '/')
304        break;
305      else if (c == '\n')
306        ++lineno;
307    }
308
309    if (c == EOF)
310    {
311      YY_FATAL_ERROR("EOF in comment");
312
313      /* XXX hack alert this disables
314       * the stupid unused function warning
315       * gcc generates
316       */
317      if (1 == 0)
318        yy_fatal_error("EOF in comment");
319      break;
320    }
321  }
322 }
323
306   static void
307   conf_include(void)
308   {
# Line 360 | Line 342 | conf_include(void)
342  
343    lineno = 1;
344    conf_file = tmp_fbfile_in;
345 +  strlcpy(conffilebuf, filenamebuf, sizeof(conffilebuf));
346  
347 <  snprintf(conffilebuf, sizeof(conffilebuf), "%s", filenamebuf);
365 <  yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
347 >  yy_switch_to_buffer(yy_create_buffer(NULL, YY_BUF_SIZE));
348   }
349  
350   static int
351   conf_eof(void)
352   {
353    if (include_stack_ptr == 0)
372  {
373    lineno = 1;
354      return 1;
375  }
355  
356    /* switch buffer */
357    struct included_file *file = &include_stack[--include_stack_ptr];

Diff Legend

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