"Fossies" - the Fresh Open Source Software Archive

Member "nmh-1.7.1/sbr/icalendar.c" (6 Mar 2018, 62324 Bytes) of package /linux/misc/nmh-1.7.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "icalendar.c" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes reports: 1.7.1-RC3_vs_1.7.1 or 1.7_vs_1.7.1.

    1 #line 2 "sbr/icalendar.c"
    2 
    3 #line 4 "sbr/icalendar.c"
    4 
    5 #define  YY_INT_ALIGNED short int
    6 
    7 /* A lexical scanner generated by flex */
    8 
    9 #define yy_create_buffer ical_create_buffer
   10 #define yy_delete_buffer ical_delete_buffer
   11 #define yy_flex_debug ical_flex_debug
   12 #define yy_init_buffer ical_init_buffer
   13 #define yy_flush_buffer ical_flush_buffer
   14 #define yy_load_buffer_state ical_load_buffer_state
   15 #define yy_switch_to_buffer ical_switch_to_buffer
   16 #define yyin icalin
   17 #define yyleng icalleng
   18 #define yylex icallex
   19 #define yylineno icallineno
   20 #define yyout icalout
   21 #define yyrestart icalrestart
   22 #define yytext icaltext
   23 #define yywrap icalwrap
   24 #define yyalloc icalalloc
   25 #define yyrealloc icalrealloc
   26 #define yyfree icalfree
   27 
   28 #define FLEX_SCANNER
   29 #define YY_FLEX_MAJOR_VERSION 2
   30 #define YY_FLEX_MINOR_VERSION 5
   31 #define YY_FLEX_SUBMINOR_VERSION 35
   32 #if YY_FLEX_SUBMINOR_VERSION > 0
   33 #define FLEX_BETA
   34 #endif
   35 
   36 /* First, we deal with  platform-specific or compiler-specific issues. */
   37 
   38 /* begin standard C headers. */
   39 #include <stdio.h>
   40 #include <string.h>
   41 #include <errno.h>
   42 #include <stdlib.h>
   43 
   44 /* end standard C headers. */
   45 
   46 /* flex integer type definitions */
   47 
   48 #ifndef FLEXINT_H
   49 #define FLEXINT_H
   50 
   51 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
   52 
   53 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
   54 
   55 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
   56  * if you want the limit (max/min) macros for int types. 
   57  */
   58 #ifndef __STDC_LIMIT_MACROS
   59 #define __STDC_LIMIT_MACROS 1
   60 #endif
   61 
   62 #include <inttypes.h>
   63 typedef int8_t flex_int8_t;
   64 typedef uint8_t flex_uint8_t;
   65 typedef int16_t flex_int16_t;
   66 typedef uint16_t flex_uint16_t;
   67 typedef int32_t flex_int32_t;
   68 typedef uint32_t flex_uint32_t;
   69 typedef uint64_t flex_uint64_t;
   70 #else
   71 typedef signed char flex_int8_t;
   72 typedef short int flex_int16_t;
   73 typedef int flex_int32_t;
   74 typedef unsigned char flex_uint8_t; 
   75 typedef unsigned short int flex_uint16_t;
   76 typedef unsigned int flex_uint32_t;
   77 #endif /* ! C99 */
   78 
   79 /* Limits of integral types. */
   80 #ifndef INT8_MIN
   81 #define INT8_MIN               (-128)
   82 #endif
   83 #ifndef INT16_MIN
   84 #define INT16_MIN              (-32767-1)
   85 #endif
   86 #ifndef INT32_MIN
   87 #define INT32_MIN              (-2147483647-1)
   88 #endif
   89 #ifndef INT8_MAX
   90 #define INT8_MAX               (127)
   91 #endif
   92 #ifndef INT16_MAX
   93 #define INT16_MAX              (32767)
   94 #endif
   95 #ifndef INT32_MAX
   96 #define INT32_MAX              (2147483647)
   97 #endif
   98 #ifndef UINT8_MAX
   99 #define UINT8_MAX              (255U)
  100 #endif
  101 #ifndef UINT16_MAX
  102 #define UINT16_MAX             (65535U)
  103 #endif
  104 #ifndef UINT32_MAX
  105 #define UINT32_MAX             (4294967295U)
  106 #endif
  107 
  108 #endif /* ! FLEXINT_H */
  109 
  110 #ifdef __cplusplus
  111 
  112 /* The "const" storage-class-modifier is valid. */
  113 #define YY_USE_CONST
  114 
  115 #else   /* ! __cplusplus */
  116 
  117 /* C99 requires __STDC__ to be defined as 1. */
  118 #if defined (__STDC__)
  119 
  120 #define YY_USE_CONST
  121 
  122 #endif  /* defined (__STDC__) */
  123 #endif  /* ! __cplusplus */
  124 
  125 #ifdef YY_USE_CONST
  126 #define yyconst const
  127 #else
  128 #define yyconst
  129 #endif
  130 
  131 /* Returned upon end-of-file. */
  132 #define YY_NULL 0
  133 
  134 /* Promotes a possibly negative, possibly signed char to an unsigned
  135  * integer for use as an array index.  If the signed char is negative,
  136  * we want to instead treat it as an 8-bit unsigned char, hence the
  137  * double cast.
  138  */
  139 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
  140 
  141 /* Enter a start condition.  This macro really ought to take a parameter,
  142  * but we do it the disgusting crufty way forced on us by the ()-less
  143  * definition of BEGIN.
  144  */
  145 #define BEGIN (yy_start) = 1 + 2 *
  146 
  147 /* Translate the current start state into a value that can be later handed
  148  * to BEGIN to return to the state.  The YYSTATE alias is for lex
  149  * compatibility.
  150  */
  151 #define YY_START (((yy_start) - 1) / 2)
  152 #define YYSTATE YY_START
  153 
  154 /* Action number for EOF rule of a given start state. */
  155 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
  156 
  157 /* Special action meaning "start processing a new file". */
  158 #define YY_NEW_FILE icalrestart(icalin  )
  159 
  160 #define YY_END_OF_BUFFER_CHAR 0
  161 
  162 /* Size of default input buffer. */
  163 #ifndef YY_BUF_SIZE
  164 #define YY_BUF_SIZE 16384
  165 #endif
  166 
  167 /* The state buf must be large enough to hold one state per character in the main buffer.
  168  */
  169 #define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
  170 
  171 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
  172 #define YY_TYPEDEF_YY_BUFFER_STATE
  173 typedef struct yy_buffer_state *YY_BUFFER_STATE;
  174 #endif
  175 
  176 #ifndef YY_TYPEDEF_YY_SIZE_T
  177 #define YY_TYPEDEF_YY_SIZE_T
  178 typedef size_t yy_size_t;
  179 #endif
  180 
  181 extern yy_size_t icalleng;
  182 
  183 extern FILE *icalin, *icalout;
  184 
  185 #define EOB_ACT_CONTINUE_SCAN 0
  186 #define EOB_ACT_END_OF_FILE 1
  187 #define EOB_ACT_LAST_MATCH 2
  188 
  189     #define YY_LESS_LINENO(n)
  190     
  191 /* Return all but the first "n" matched characters back to the input stream. */
  192 #define yyless(n) \
  193     do \
  194         { \
  195         /* Undo effects of setting up icaltext. */ \
  196         int yyless_macro_arg = (n); \
  197         YY_LESS_LINENO(yyless_macro_arg);\
  198         *yy_cp = (yy_hold_char); \
  199         YY_RESTORE_YY_MORE_OFFSET \
  200         (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
  201         YY_DO_BEFORE_ACTION; /* set up icaltext again */ \
  202         } \
  203     while ( 0 )
  204 
  205 #define unput(c) yyunput( c, (yytext_ptr)  )
  206 
  207 #ifndef YY_STRUCT_YY_BUFFER_STATE
  208 #define YY_STRUCT_YY_BUFFER_STATE
  209 struct yy_buffer_state
  210     {
  211     FILE *yy_input_file;
  212 
  213     char *yy_ch_buf;        /* input buffer */
  214     char *yy_buf_pos;       /* current position in input buffer */
  215 
  216     /* Size of input buffer in bytes, not including room for EOB
  217      * characters.
  218      */
  219     yy_size_t yy_buf_size;
  220 
  221     /* Number of characters read into yy_ch_buf, not including EOB
  222      * characters.
  223      */
  224     yy_size_t yy_n_chars;
  225 
  226     /* Whether we "own" the buffer - i.e., we know we created it,
  227      * and can realloc() it to grow it, and should free() it to
  228      * delete it.
  229      */
  230     int yy_is_our_buffer;
  231 
  232     /* Whether this is an "interactive" input source; if so, and
  233      * if we're using stdio for input, then we want to use getc()
  234      * instead of fread(), to make sure we stop fetching input after
  235      * each newline.
  236      */
  237     int yy_is_interactive;
  238 
  239     /* Whether we're considered to be at the beginning of a line.
  240      * If so, '^' rules will be active on the next match, otherwise
  241      * not.
  242      */
  243     int yy_at_bol;
  244 
  245     int yy_bs_lineno; /**< The line count. */
  246     int yy_bs_column; /**< The column count. */
  247     
  248     /* Whether to try to fill the input buffer when we reach the
  249      * end of it.
  250      */
  251     int yy_fill_buffer;
  252 
  253     int yy_buffer_status;
  254 
  255 #define YY_BUFFER_NEW 0
  256 #define YY_BUFFER_NORMAL 1
  257     /* When an EOF's been seen but there's still some text to process
  258      * then we mark the buffer as YY_EOF_PENDING, to indicate that we
  259      * shouldn't try reading from the input source any more.  We might
  260      * still have a bunch of tokens to match, though, because of
  261      * possible backing-up.
  262      *
  263      * When we actually see the EOF, we change the status to "new"
  264      * (via icalrestart()), so that the user can continue scanning by
  265      * just pointing icalin at a new input file.
  266      */
  267 #define YY_BUFFER_EOF_PENDING 2
  268 
  269     };
  270 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
  271 
  272 /* Stack of input buffers. */
  273 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
  274 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
  275 static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
  276 
  277 /* We provide macros for accessing buffer states in case in the
  278  * future we want to put the buffer states in a more general
  279  * "scanner state".
  280  *
  281  * Returns the top of the stack, or NULL.
  282  */
  283 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
  284                           ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
  285                           : NULL)
  286 
  287 /* Same as previous macro, but useful when we know that the buffer stack is not
  288  * NULL or when we need an lvalue. For internal use only.
  289  */
  290 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
  291 
  292 /* yy_hold_char holds the character lost when icaltext is formed. */
  293 static char yy_hold_char;
  294 static yy_size_t yy_n_chars;        /* number of characters read into yy_ch_buf */
  295 yy_size_t icalleng;
  296 
  297 /* Points to current character in buffer. */
  298 static char *yy_c_buf_p = (char *) 0;
  299 static int yy_init = 0;     /* whether we need to initialize */
  300 static int yy_start = 0;    /* start state number */
  301 
  302 /* Flag which is used to allow icalwrap()'s to do buffer switches
  303  * instead of setting up a fresh icalin.  A bit of a hack ...
  304  */
  305 static int yy_did_buffer_switch_on_eof;
  306 
  307 void icalrestart (FILE *input_file  );
  308 void ical_switch_to_buffer (YY_BUFFER_STATE new_buffer  );
  309 YY_BUFFER_STATE ical_create_buffer (FILE *file,int size  );
  310 void ical_delete_buffer (YY_BUFFER_STATE b  );
  311 void ical_flush_buffer (YY_BUFFER_STATE b  );
  312 void icalpush_buffer_state (YY_BUFFER_STATE new_buffer  );
  313 void icalpop_buffer_state (void );
  314 
  315 static void icalensure_buffer_stack (void );
  316 static void ical_load_buffer_state (void );
  317 static void ical_init_buffer (YY_BUFFER_STATE b,FILE *file  );
  318 
  319 #define YY_FLUSH_BUFFER ical_flush_buffer(YY_CURRENT_BUFFER )
  320 
  321 YY_BUFFER_STATE ical_scan_buffer (char *base,yy_size_t size  );
  322 YY_BUFFER_STATE ical_scan_string (yyconst char *yy_str  );
  323 YY_BUFFER_STATE ical_scan_bytes (yyconst char *bytes,yy_size_t len  );
  324 
  325 void *icalalloc (yy_size_t  );
  326 void *icalrealloc (void *,yy_size_t  );
  327 void icalfree (void *  );
  328 
  329 #define yy_new_buffer ical_create_buffer
  330 
  331 #define yy_set_interactive(is_interactive) \
  332     { \
  333     if ( ! YY_CURRENT_BUFFER ){ \
  334         icalensure_buffer_stack (); \
  335         YY_CURRENT_BUFFER_LVALUE =    \
  336             ical_create_buffer(icalin,YY_BUF_SIZE ); \
  337     } \
  338     YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
  339     }
  340 
  341 #define yy_set_bol(at_bol) \
  342     { \
  343     if ( ! YY_CURRENT_BUFFER ){\
  344         icalensure_buffer_stack (); \
  345         YY_CURRENT_BUFFER_LVALUE =    \
  346             ical_create_buffer(icalin,YY_BUF_SIZE ); \
  347     } \
  348     YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
  349     }
  350 
  351 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
  352 
  353 /* Begin user sect3 */
  354 
  355 #define icalwrap(n) 1
  356 #define YY_SKIP_YYWRAP
  357 
  358 typedef unsigned char YY_CHAR;
  359 
  360 FILE *icalin = (FILE *) 0, *icalout = (FILE *) 0;
  361 
  362 typedef int yy_state_type;
  363 
  364 extern int icallineno;
  365 
  366 int icallineno = 1;
  367 
  368 extern char *icaltext;
  369 #define yytext_ptr icaltext
  370 
  371 static yy_state_type yy_get_previous_state (void );
  372 static yy_state_type yy_try_NUL_trans (yy_state_type current_state  );
  373 static int yy_get_next_buffer (void );
  374 static void yy_fatal_error (yyconst char msg[]  );
  375 
  376 /* Done after the current pattern has been matched and before the
  377  * corresponding action - sets up icaltext.
  378  */
  379 #define YY_DO_BEFORE_ACTION \
  380     (yytext_ptr) = yy_bp; \
  381     icalleng = (yy_size_t) (yy_cp - yy_bp); \
  382     (yy_hold_char) = *yy_cp; \
  383     *yy_cp = '\0'; \
  384     (yy_c_buf_p) = yy_cp;
  385 
  386 #define YY_NUM_RULES 17
  387 #define YY_END_OF_BUFFER 18
  388 /* This struct is not used in this scanner,
  389    but its presence is necessary. */
  390 struct yy_trans_info
  391     {
  392     flex_int32_t yy_verify;
  393     flex_int32_t yy_nxt;
  394     };
  395 static yyconst flex_int16_t yy_accept[125] =
  396     {   0,
  397         0,    0,    0,    0,    6,    6,    0,    0,    0,    0,
  398         0,    0,   12,   12,   12,   12,   18,   16,    1,   16,
  399         3,    3,   17,   13,    4,    7,    6,   15,   16,   16,
  400        14,   16,    9,    9,   10,   12,   17,   16,   16,   16,
  401         1,    0,    0,    0,    3,    3,    6,    0,    0,    0,
  402         5,   15,    0,    6,   14,    0,    0,    0,    9,    9,
  403        12,    0,    0,    0,   11,    0,    0,    0,   12,    0,
  404        12,    0,    3,    3,    5,    0,    6,    0,    9,    9,
  405        11,    0,    0,    0,   12,    2,    3,    5,    6,    8,
  406         9,   11,    0,   11,    0,    0,   12,    3,    5,    6,
  407 
  408         9,   11,    0,    0,   12,    3,    3,    5,    6,    9,
  409         9,   11,    0,    0,   12,    5,   11,    0,    0,    5,
  410        11,    0,    0,    0
  411     } ;
  412 
  413 static yyconst flex_int32_t yy_ec[256] =
  414     {   0,
  415         1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
  416         1,    1,    4,    1,    1,    1,    1,    1,    1,    1,
  417         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  418         1,    5,    6,    7,    6,    6,    6,    6,    6,    6,
  419         6,    6,    6,    8,    9,    6,    6,   10,   10,   10,
  420        10,   10,   10,   10,   10,   10,   10,   11,   12,    6,
  421        13,    6,    6,    6,   14,   14,   14,   14,   14,   14,
  422        14,   14,   14,   14,   14,   14,   14,   14,   14,   14,
  423        14,   14,   14,   14,   14,   14,   14,   15,   14,   14,
  424         6,    6,    6,    6,    6,    6,   14,   14,   14,   14,
  425 
  426        14,   14,   14,   14,   14,   14,   14,   14,   14,   14,
  427        14,   14,   14,   14,   14,   14,   14,   14,   14,   14,
  428        14,   14,    6,    6,    6,    6,    1,   16,   16,   16,
  429        16,   16,   16,   16,   16,   16,   16,   16,   16,   16,
  430        16,   16,   16,   16,   16,   16,   16,   16,   16,   16,
  431        16,   16,   16,   16,   16,   16,   16,   16,   16,   16,
  432        16,   16,   16,   16,   16,   16,   16,   16,   16,   16,
  433        16,   16,   16,   16,   16,   16,   16,   16,   16,   16,
  434        16,   16,   16,   16,   16,   16,   16,   16,   16,   16,
  435        16,   16,   16,   16,   16,   16,   16,   16,   16,   16,
  436 
  437        16,   16,   16,   16,   16,   16,   16,   16,   16,   16,
  438        16,   16,   16,   16,   16,   16,   16,   16,   16,   16,
  439        16,   16,   16,   16,   16,   16,   16,   16,   16,   16,
  440        16,   16,   16,   16,   16,   16,   16,   16,   16,   16,
  441        16,   16,   16,   16,   16,   16,   16,   16,    1,    1,
  442         1,    1,    1,    1,    1
  443     } ;
  444 
  445 static yyconst flex_int32_t yy_meta[17] =
  446     {   0,
  447         1,    2,    2,    2,    2,    2,    2,    2,    2,    2,
  448         2,    2,    2,    2,    2,    2
  449     } ;
  450 
  451 static yyconst flex_int16_t yy_base[131] =
  452     {   0,
  453         0,   13,   26,    0,   38,   54,    2,    4,   68,    0,
  454         8,   17,   83,    0,    0,    0,  136,  406,    9,  132,
  455        97,  125,  406,  406,  406,  406,  110,  125,  130,  109,
  456        15,  121,  128,  114,  406,  142,  157,  119,  160,  105,
  457        21,  117,  175,  116,    0,  178,  191,   28,  115,  101,
  458       205,    0,  113,   99,   32,  107,  220,  106,    0,  223,
  459         0,    0,  105,   89,  237,  251,  266,  101,  406,   87,
  460        86,  269,  275,  281,  294,   65,   64,  308,  314,  320,
  461         0,   63,  333,   60,   59,    0,  340,   58,   57,    0,
  462       346,   56,  359,  406,   53,   52,   51,  373,   50,   49,
  463 
  464       386,   48,   47,   46,   45,    0,    0,   44,   43,    0,
  465         0,   40,   37,   36,   35,   34,   33,   32,   31,   30,
  466        29,   28,   27,  406,  401,  403,   38,   31,   24,    0
  467     } ;
  468 
  469 static yyconst flex_int16_t yy_def[131] =
  470     {   0,
  471       125,  125,  125,    3,  126,  126,  125,  125,  125,    9,
  472       125,  125,  124,   13,   13,   13,  124,  124,  124,  124,
  473       124,   21,  124,  124,  124,  124,  127,  124,  124,  124,
  474       124,  124,  124,   33,  124,  124,  124,  124,  128,  124,
  475       124,  124,  124,  124,   21,  124,  127,   28,  124,  124,
  476       129,   28,  124,   47,  124,  124,  124,  124,   33,  124,
  477        36,   37,  124,  124,  124,  128,  124,  124,  124,  124,
  478        36,  124,   46,   46,  129,  124,   47,  124,   60,   60,
  479        65,  124,  130,   66,   36,   72,   46,   75,   47,   78,
  480        60,   65,  130,  124,  124,   66,   36,  124,   75,   47,
  481 
  482       124,   65,   93,   66,   36,   73,   98,   75,   47,   79,
  483       101,   65,   93,   66,   36,   75,   65,   93,   66,   75,
  484        65,   93,   93,    0,  124,  124,  124,  124,  124,  124
  485     } ;
  486 
  487 static yyconst flex_int16_t yy_nxt[423] =
  488     {   0,
  489       124,   93,   19,   20,   31,   32,   31,   32,   21,   21,
  490        23,   41,   42,   21,   22,   19,   20,   55,   56,   23,
  491        35,   21,   21,   41,   42,   75,   21,   22,   23,   35,
  492        48,   49,   66,   24,   55,   56,   25,   26,   18,   47,
  493        28,   29,  123,  123,  121,  120,  119,  122,  121,  120,
  494       115,  119,  118,   30,   18,  117,   28,   29,  109,  116,
  495       115,  114,  113,  112,  109,  108,  105,  104,  103,   30,
  496        23,  102,  100,   99,   97,   96,   33,   33,   92,   89,
  497        88,   33,   34,   18,   36,   37,   38,   36,   36,   39,
  498        18,   36,   36,   18,   18,   36,   36,   36,   40,   43,
  499 
  500        44,   85,   84,   67,   71,   45,   45,   62,   57,   55,
  501        45,   45,   48,   49,   77,   52,   54,   48,   43,   41,
  502        71,   62,   60,   55,   54,   50,   51,   52,   53,   51,
  503        57,   58,   52,   46,   41,  124,   59,   59,  124,  124,
  504       124,   59,   59,   61,   62,   63,   61,   61,  124,  124,
  505        61,   61,  124,  124,   61,   61,   61,   64,   65,   62,
  506        63,   65,   67,   68,  124,  124,   69,  124,  124,  124,
  507       124,  124,  124,  124,  124,   70,   72,   43,   44,   72,
  508        43,   44,  124,  124,  124,  124,   73,   74,  124,  124,
  509       124,   74,   74,   48,   49,  124,  124,  124,  124,  124,
  510 
  511       124,  124,  124,  124,  124,  124,   50,   48,   49,  124,
  512       124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
  513        76,   78,   57,   58,   78,   57,   58,  124,  124,  124,
  514       124,   79,   80,  124,  124,  124,   80,   80,   81,   62,
  515        63,   81,   81,  124,  124,   81,   81,  124,  124,   81,
  516        81,   81,   82,   67,   68,  124,  124,   69,  124,  124,
  517       124,  124,  124,  124,  124,  124,   70,   83,   67,   68,
  518        83,   43,   44,  124,  124,  124,  124,   86,   86,  124,
  519       124,  124,   86,   86,   73,  124,  124,  124,   73,   73,
  520        87,  124,  124,  124,   87,   87,   48,   49,  124,  124,
  521 
  522       124,  124,  124,  124,  124,  124,  124,  124,  124,   76,
  523        57,   58,  124,  124,  124,  124,   90,   90,  124,  124,
  524       124,   90,   90,   79,  124,  124,  124,   79,   79,   91,
  525       124,  124,  124,   91,   91,   67,   68,  124,  124,   94,
  526       124,  124,  124,  124,  124,  124,  124,  124,   95,   98,
  527       124,  124,  124,   98,   98,  101,  124,  124,  124,  101,
  528       101,  124,  124,  124,  124,   94,  124,  124,  124,  124,
  529       124,  124,  124,  124,   95,   43,   44,  124,  124,  124,
  530       124,  106,  107,  124,  124,  124,  107,  107,   57,   58,
  531       124,  124,  124,  124,  110,  111,  124,  124,  124,  111,
  532 
  533       111,   18,   18,   27,   27,   17,  124,  124,  124,  124,
  534       124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
  535       124,  124
  536     } ;
  537 
  538 static yyconst flex_int16_t yy_chk[423] =
  539     {   0,
  540         0,  130,    1,    1,    7,    7,    8,    8,    1,    1,
  541        11,   19,   19,    1,    1,    2,    2,   31,   31,   12,
  542        11,    2,    2,   41,   41,  129,    2,    2,    3,   12,
  543        48,   48,  128,    3,   55,   55,    3,    3,    5,  127,
  544         5,    5,  123,  122,  121,  120,  119,  118,  117,  116,
  545       115,  114,  113,    5,    6,  112,    6,    6,  109,  108,
  546       105,  104,  103,  102,  100,   99,   97,   96,   95,    6,
  547         9,   92,   89,   88,   85,   84,    9,    9,   82,   77,
  548        76,    9,    9,   13,   13,   13,   13,   13,   13,   13,
  549        13,   13,   13,   13,   13,   13,   13,   13,   13,   21,
  550 
  551        21,   71,   70,   68,   64,   21,   21,   63,   58,   56,
  552        21,   21,   27,   27,   54,   53,   50,   49,   44,   42,
  553        40,   38,   34,   32,   30,   27,   28,   28,   28,   28,
  554        33,   33,   29,   22,   20,   17,   33,   33,    0,    0,
  555         0,   33,   33,   36,   36,   36,   36,   36,    0,    0,
  556        36,   36,    0,    0,   36,   36,   36,   36,   37,   37,
  557        37,   37,   39,   39,    0,    0,   39,    0,    0,    0,
  558         0,    0,    0,    0,    0,   39,   43,   43,   43,   43,
  559        46,   46,    0,    0,    0,    0,   46,   46,    0,    0,
  560         0,   46,   46,   47,   47,    0,    0,    0,    0,    0,
  561 
  562         0,    0,    0,    0,    0,    0,   47,   51,   51,    0,
  563         0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  564        51,   57,   57,   57,   57,   60,   60,    0,    0,    0,
  565         0,   60,   60,    0,    0,    0,   60,   60,   65,   65,
  566        65,   65,   65,    0,    0,   65,   65,    0,    0,   65,
  567        65,   65,   65,   66,   66,    0,    0,   66,    0,    0,
  568         0,    0,    0,    0,    0,    0,   66,   67,   67,   67,
  569        67,   72,   72,    0,    0,    0,    0,   72,   72,    0,
  570         0,    0,   72,   72,   73,    0,    0,    0,   73,   73,
  571        74,    0,    0,    0,   74,   74,   75,   75,    0,    0,
  572 
  573         0,    0,    0,    0,    0,    0,    0,    0,    0,   75,
  574        78,   78,    0,    0,    0,    0,   78,   78,    0,    0,
  575         0,   78,   78,   79,    0,    0,    0,   79,   79,   80,
  576         0,    0,    0,   80,   80,   83,   83,    0,    0,   83,
  577         0,    0,    0,    0,    0,    0,    0,    0,   83,   87,
  578         0,    0,    0,   87,   87,   91,    0,    0,    0,   91,
  579        91,   93,   93,    0,    0,   93,    0,    0,    0,    0,
  580         0,    0,    0,    0,   93,   98,   98,    0,    0,    0,
  581         0,   98,   98,    0,    0,    0,   98,   98,  101,  101,
  582         0,    0,    0,    0,  101,  101,    0,    0,    0,  101,
  583 
  584       101,  125,  125,  126,  126,  124,  124,  124,  124,  124,
  585       124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
  586       124,  124
  587     } ;
  588 
  589 static yy_state_type yy_last_accepting_state;
  590 static char *yy_last_accepting_cpos;
  591 
  592 extern int ical_flex_debug;
  593 int ical_flex_debug = 0;
  594 
  595 /* The intent behind this definition is that it'll catch
  596  * any uses of REJECT which flex missed.
  597  */
  598 #define REJECT reject_used_but_not_detected
  599 #define yymore() yymore_used_but_not_detected
  600 #define YY_MORE_ADJ 0
  601 #define YY_RESTORE_YY_MORE_OFFSET
  602 char *icaltext;
  603 #line 1 "sbr/icalendar.l"
  604 /* icalendar.l -- icalendar (RFC 5545) scanner
  605  *
  606  * This code is Copyright (c) 2014, by the authors of nmh.  See the
  607  * COPYRIGHT file in the root directory of the nmh distribution for
  608  * complete copyright information.
  609  */
  610 /* See porting notes at end of this file. */
  611 #line 11 "sbr/icalendar.l"
  612 #include "h/mh.h"
  613 #include "h/icalendar.h"
  614 #include "sbr/icalparse.h"
  615 
  616 static char *unfold (char *, size_t *);
  617 static void destroy_icallex(void);
  618 /*
  619  * These flex options aren't used:
  620  *   8bit not needed
  621  *   case-insensitive not needed
  622  *   align not used because this isn't performance critical
  623  */
  624 #define YY_NO_INPUT 1
  625 /*
  626 * From RFC 5545 § 3.1.
  627 */
  628 /* The following is a short-cut definition that admits more
  629 that the UNICODE characters permitted by RFC 5545. */
  630 /* The following excludes HTAB, unlike {CTL}. */
  631 /* Solaris lex requires that the , be escaped. */
  632 /*
  633 * From RFC 5545 § 2.1.
  634 */
  635 /*
  636 * From RFC 5545 § 3.3.11.
  637 */
  638 /*
  639 * Core rules (definitions) from RFC 5234 Appendix B.1.
  640 */
  641 /* Variance from RFC 5234:  the {CR} is required in
  642 CRLF, but it is optional below to support Unix
  643 filesystem convention. */
  644 /*
  645  * Our definitions.
  646  */
  647 
  648 #line 649 "sbr/icalendar.c"
  649 
  650 #define INITIAL 0
  651 #define s_name 1
  652 #define s_colon 2
  653 #define s_value 3
  654 #define s_semicolon 4
  655 #define s_param_name 5
  656 #define s_equal 6
  657 #define s_comma 7
  658 
  659 #ifndef YY_NO_UNISTD_H
  660 /* Special case for "unistd.h", since it is non-ANSI. We include it way
  661  * down here because we want the user's section 1 to have been scanned first.
  662  * The user has a chance to override it with an option.
  663  */
  664 #include <unistd.h>
  665 #endif
  666 
  667 #ifndef YY_EXTRA_TYPE
  668 #define YY_EXTRA_TYPE void *
  669 #endif
  670 
  671 static int yy_init_globals (void );
  672 
  673 /* Accessor methods to globals.
  674    These are made visible to non-reentrant scanners for convenience. */
  675 
  676 int icallex_destroy (void );
  677 
  678 int icalget_debug (void );
  679 
  680 void icalset_debug (int debug_flag  );
  681 
  682 YY_EXTRA_TYPE icalget_extra (void );
  683 
  684 void icalset_extra (YY_EXTRA_TYPE user_defined  );
  685 
  686 FILE *icalget_in (void );
  687 
  688 void icalset_in  (FILE * in_str  );
  689 
  690 FILE *icalget_out (void );
  691 
  692 void icalset_out  (FILE * out_str  );
  693 
  694 yy_size_t icalget_leng (void );
  695 
  696 char *icalget_text (void );
  697 
  698 int icalget_lineno (void );
  699 
  700 void icalset_lineno (int line_number  );
  701 
  702 /* Macros after this point can all be overridden by user definitions in
  703  * section 1.
  704  */
  705 
  706 #ifndef YY_SKIP_YYWRAP
  707 #ifdef __cplusplus
  708 extern "C" int icalwrap (void );
  709 #else
  710 extern int icalwrap (void );
  711 #endif
  712 #endif
  713 
  714     static void yyunput (int c,char *buf_ptr  );
  715     
  716 #ifndef yytext_ptr
  717 static void yy_flex_strncpy (char *,yyconst char *,int );
  718 #endif
  719 
  720 #ifdef YY_NEED_STRLEN
  721 static int yy_flex_strlen (yyconst char * );
  722 #endif
  723 
  724 #ifndef YY_NO_INPUT
  725 
  726 #ifdef __cplusplus
  727 static int yyinput (void );
  728 #else
  729 static int input (void );
  730 #endif
  731 
  732 #endif
  733 
  734 /* Amount of stuff to slurp up with each read. */
  735 #ifndef YY_READ_BUF_SIZE
  736 #define YY_READ_BUF_SIZE 8192
  737 #endif
  738 
  739 /* Copy whatever the last rule matched to the standard output. */
  740 #ifndef ECHO
  741 /* This used to be an fputs(), but since the string might contain NUL's,
  742  * we now use fwrite().
  743  */
  744 #define ECHO fwrite( icaltext, icalleng, 1, icalout )
  745 #endif
  746 
  747 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
  748  * is returned in "result".
  749  */
  750 #ifndef YY_INPUT
  751 #define YY_INPUT(buf,result,max_size) \
  752     if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
  753         { \
  754         int c = '*'; \
  755         yy_size_t n; \
  756         for ( n = 0; n < max_size && \
  757                  (c = getc( icalin )) != EOF && c != '\n'; ++n ) \
  758             buf[n] = (char) c; \
  759         if ( c == '\n' ) \
  760             buf[n++] = (char) c; \
  761         if ( c == EOF && ferror( icalin ) ) \
  762             YY_FATAL_ERROR( "input in flex scanner failed" ); \
  763         result = n; \
  764         } \
  765     else \
  766         { \
  767         errno=0; \
  768         while ( (result = fread(buf, 1, max_size, icalin))==0 && ferror(icalin)) \
  769             { \
  770             if( errno != EINTR) \
  771                 { \
  772                 YY_FATAL_ERROR( "input in flex scanner failed" ); \
  773                 break; \
  774                 } \
  775             errno=0; \
  776             clearerr(icalin); \
  777             } \
  778         }\
  779 \
  780 
  781 #endif
  782 
  783 /* No semi-colon after return; correct usage is to write "yyterminate();" -
  784  * we don't want an extra ';' after the "return" because that will cause
  785  * some compilers to complain about unreachable statements.
  786  */
  787 #ifndef yyterminate
  788 #define yyterminate() return YY_NULL
  789 #endif
  790 
  791 /* Number of entries by which start-condition stack grows. */
  792 #ifndef YY_START_STACK_INCR
  793 #define YY_START_STACK_INCR 25
  794 #endif
  795 
  796 /* Report a fatal error. */
  797 #ifndef YY_FATAL_ERROR
  798 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
  799 #endif
  800 
  801 /* end tables serialization structures and prototypes */
  802 
  803 /* Default declaration of generated scanner - a define so the user can
  804  * easily add parameters.
  805  */
  806 #ifndef YY_DECL
  807 #define YY_DECL_IS_OURS 1
  808 
  809 extern int icallex (void);
  810 
  811 #define YY_DECL int icallex (void)
  812 #endif /* !YY_DECL */
  813 
  814 /* Code executed at the beginning of each rule, after icaltext and icalleng
  815  * have been set up.
  816  */
  817 #ifndef YY_USER_ACTION
  818 #define YY_USER_ACTION
  819 #endif
  820 
  821 /* Code executed at the end of each rule. */
  822 #ifndef YY_BREAK
  823 #define YY_BREAK break;
  824 #endif
  825 
  826 #define YY_RULE_SETUP \
  827     YY_USER_ACTION
  828 
  829 /** The main scanner function which does all the work.
  830  */
  831 YY_DECL
  832 {
  833     register yy_state_type yy_current_state;
  834     register char *yy_cp, *yy_bp;
  835     register int yy_act;
  836     
  837 #line 100 "sbr/icalendar.l"
  838 
  839 
  840 #line 841 "sbr/icalendar.c"
  841 
  842     if ( !(yy_init) )
  843         {
  844         (yy_init) = 1;
  845 
  846 #ifdef YY_USER_INIT
  847         YY_USER_INIT;
  848 #endif
  849 
  850         if ( ! (yy_start) )
  851             (yy_start) = 1; /* first start state */
  852 
  853         if ( ! icalin )
  854             icalin = stdin;
  855 
  856         if ( ! icalout )
  857             icalout = stdout;
  858 
  859         if ( ! YY_CURRENT_BUFFER ) {
  860             icalensure_buffer_stack ();
  861             YY_CURRENT_BUFFER_LVALUE =
  862                 ical_create_buffer(icalin,YY_BUF_SIZE );
  863         }
  864 
  865         ical_load_buffer_state( );
  866         }
  867 
  868     while ( 1 )     /* loops until end-of-file is reached */
  869         {
  870         yy_cp = (yy_c_buf_p);
  871 
  872         /* Support of icaltext. */
  873         *yy_cp = (yy_hold_char);
  874 
  875         /* yy_bp points to the position in yy_ch_buf of the start of
  876          * the current run.
  877          */
  878         yy_bp = yy_cp;
  879 
  880         yy_current_state = (yy_start);
  881 yy_match:
  882         do
  883             {
  884             register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
  885             if ( yy_accept[yy_current_state] )
  886                 {
  887                 (yy_last_accepting_state) = yy_current_state;
  888                 (yy_last_accepting_cpos) = yy_cp;
  889                 }
  890             while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  891                 {
  892                 yy_current_state = (int) yy_def[yy_current_state];
  893                 if ( yy_current_state >= 125 )
  894                     yy_c = yy_meta[(unsigned int) yy_c];
  895                 }
  896             yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
  897             ++yy_cp;
  898             }
  899         while ( yy_current_state != 124 );
  900         yy_cp = (yy_last_accepting_cpos);
  901         yy_current_state = (yy_last_accepting_state);
  902 
  903 yy_find_action:
  904         yy_act = yy_accept[yy_current_state];
  905 
  906         YY_DO_BEFORE_ACTION;
  907 
  908 do_action:  /* This label is used only to access EOF actions. */
  909 
  910         switch ( yy_act )
  911     { /* beginning of action switch */
  912             case 0: /* must back up */
  913             /* undo the effects of YY_DO_BEFORE_ACTION */
  914             *yy_cp = (yy_hold_char);
  915             yy_cp = (yy_last_accepting_cpos);
  916             yy_current_state = (yy_last_accepting_state);
  917             goto yy_find_action;
  918 
  919 case 1:
  920 /* rule 1 can match eol */
  921 YY_RULE_SETUP
  922 #line 103 "sbr/icalendar.l"
  923 {
  924     /* Eat any leading newlines. */
  925 }
  926     YY_BREAK
  927 
  928 case 2:
  929 /* rule 2 can match eol */
  930 YY_RULE_SETUP
  931 #line 108 "sbr/icalendar.l"
  932 {
  933     /* flex 2.5.4 defines icalleng as an int instead of a size_t,
  934        so copy it. */
  935     size_t len = icalleng;
  936     unfold (icaltext, &len);
  937     icalleng = len;
  938 
  939     icallval = strdup (icaltext);
  940     /* yy_push_state (s_name);         * s_name */
  941     BEGIN (s_name);                   /* s_name */
  942     return ICAL_NAME;
  943 }
  944     YY_BREAK
  945 
  946 case 3:
  947 YY_RULE_SETUP
  948 #line 122 "sbr/icalendar.l"
  949 {
  950     icallval = strdup (icaltext);
  951     /* yy_push_state (s_name);         * s_name */
  952     BEGIN (s_name);                   /* s_name */
  953     return ICAL_NAME;
  954 }
  955     YY_BREAK
  956 
  957 case 4:
  958 YY_RULE_SETUP
  959 #line 130 "sbr/icalendar.l"
  960 {
  961     /* Don't need to strdup a single character. */
  962     icallval = icaltext;
  963     /* yy_pop_state ();                * INITIAL */
  964     /* yy_push_state (s_colon);        * s_colon */
  965     BEGIN (s_colon);                  /* s_colon */
  966     return ICAL_COLON;
  967 }
  968     YY_BREAK
  969 
  970 case 5:
  971 /* rule 5 can match eol */
  972 YY_RULE_SETUP
  973 #line 140 "sbr/icalendar.l"
  974 {
  975     /* flex 2.5.4 defines icalleng as an int instead of a size_t,
  976        so copy it. */
  977     size_t len = icalleng;
  978     unfold (icaltext, &len);
  979     icalleng = len;
  980 
  981     icallval = strdup (icaltext);
  982     /* yy_pop_state ();                * INITIAL */
  983     /* yy_push_state (s_value);        * s_value */
  984     BEGIN (s_value);                  /* s_value */
  985     return ICAL_VALUE;
  986 }
  987     YY_BREAK
  988 
  989 case 6:
  990 YY_RULE_SETUP
  991 #line 155 "sbr/icalendar.l"
  992 {
  993     icallval = strdup (icaltext);
  994     /* yy_pop_state ();                * INITIAL */
  995     /* yy_push_state (s_value);        * s_value */
  996     BEGIN (s_value);                  /* s_value */
  997     return ICAL_VALUE;
  998 }
  999     YY_BREAK
 1000 
 1001 case 7:
 1002 YY_RULE_SETUP
 1003 #line 164 "sbr/icalendar.l"
 1004 {
 1005     /* Don't need to strdup a single character. */
 1006     icallval = icaltext;
 1007     /* yy_push_state (s_semicolon);    * s_name, s_semicolon */
 1008     BEGIN (s_semicolon);              /* s_name, s_semicolon */
 1009     return ICAL_SEMICOLON;
 1010 }
 1011     YY_BREAK
 1012 
 1013 case 8:
 1014 /* rule 8 can match eol */
 1015 YY_RULE_SETUP
 1016 #line 173 "sbr/icalendar.l"
 1017 {
 1018     /* flex 2.5.4 defines icalleng as an int instead of a size_t,
 1019        so copy it. */
 1020     size_t len = icalleng;
 1021     unfold (icaltext, &len);
 1022     icalleng = len;
 1023 
 1024     icallval = strdup (icaltext);
 1025     /* yy_pop_state ();                * s_name */
 1026     /* yy_push_state (s_param_name);   * s_name, s_param_name */
 1027     BEGIN (s_param_name);             /* s_name, s_param_name */
 1028     return ICAL_PARAM_NAME;
 1029 }
 1030     YY_BREAK
 1031 
 1032 case 9:
 1033 YY_RULE_SETUP
 1034 #line 188 "sbr/icalendar.l"
 1035 {
 1036     icallval = strdup (icaltext);
 1037     /* yy_pop_state ();                * s_name */
 1038     /* yy_push_state (s_param_name);   * s_name, s_param_name */
 1039     BEGIN (s_param_name);             /* s_name, s_param_name */
 1040     return ICAL_PARAM_NAME;
 1041 }
 1042     YY_BREAK
 1043 
 1044 case 10:
 1045 YY_RULE_SETUP
 1046 #line 197 "sbr/icalendar.l"
 1047 {
 1048     /* Don't need to strdup a single character. */
 1049     icallval = icaltext;
 1050     /* yy_pop_state ();                * s_name */
 1051     /* yy_push_state (s_equal);        * s_name, s_equal */
 1052     BEGIN (s_equal);                  /* s_name, s_equal */
 1053     return ICAL_EQUAL;
 1054 }
 1055     YY_BREAK
 1056 
 1057 case 11:
 1058 /* rule 11 can match eol */
 1059 YY_RULE_SETUP
 1060 #line 207 "sbr/icalendar.l"
 1061 {
 1062     /* flex 2.5.4 defines icalleng as an int instead of a size_t,
 1063        so copy it. */
 1064     size_t len = icalleng;
 1065     unfold (icaltext, &len);
 1066     icalleng = len;
 1067 
 1068     icallval = strdup (icaltext);
 1069     /* yy_pop_state ();                * s_name */
 1070     BEGIN (s_name);                   /* s_name */
 1071     return ICAL_PARAM_VALUE;
 1072 }
 1073     YY_BREAK
 1074 
 1075 case 12:
 1076 YY_RULE_SETUP
 1077 #line 221 "sbr/icalendar.l"
 1078 {
 1079     icallval = strdup (icaltext);
 1080     /* yy_pop_state ();                * s_name */
 1081     BEGIN (s_name);                   /* s_name */
 1082     return ICAL_PARAM_VALUE;
 1083 }
 1084     YY_BREAK
 1085 
 1086 case 13:
 1087 YY_RULE_SETUP
 1088 #line 229 "sbr/icalendar.l"
 1089 {
 1090     /* Don't need to strdup a single character. */
 1091     icallval = icaltext;
 1092     /* yy_push_state (s_comma);        * s_name, s_comma */
 1093     BEGIN (s_comma);                  /* s_name, s_comma */
 1094     return ICAL_COMMA;
 1095 }
 1096     YY_BREAK
 1097 
 1098 case 14:
 1099 /* rule 14 can match eol */
 1100 YY_RULE_SETUP
 1101 #line 238 "sbr/icalendar.l"
 1102 {
 1103     /* Use start condition to ensure that all newlines are where expected. */
 1104     icallval = icaltext;
 1105     /* yy_pop_state ();                * INITIAL */
 1106     BEGIN (INITIAL);                  /* INITIAL */
 1107     return ICAL_CRLF;
 1108 }
 1109     YY_BREAK
 1110 
 1111 case 15:
 1112 /* rule 15 can match eol */
 1113 YY_RULE_SETUP
 1114 #line 247 "sbr/icalendar.l"
 1115 {
 1116     /* Null value. */
 1117     icallval = strdup ("");
 1118     /* yy_pop_state ();                * INITIAL */
 1119     /* yy_push_state (s_value);        * s_value */
 1120     BEGIN (s_value);                  /* s_value */
 1121     /* Push the newline back so it can be handled in the proper state. */
 1122     unput ('\n');
 1123     return ICAL_VALUE;
 1124 }
 1125     YY_BREAK
 1126 case 16:
 1127 YY_RULE_SETUP
 1128 #line 258 "sbr/icalendar.l"
 1129 {
 1130     /* By default, flex will just pass unmatched text.  Catch it instead. */
 1131     contentline *clines = vevents.last->contentlines;
 1132     contentline *cline;
 1133 
 1134     if (clines  &&  (cline = clines->last)) {
 1135         if (cline->unexpected == NULL) {
 1136             cline->unexpected = charstring_create (0);
 1137         }
 1138         charstring_append_cstring (cline->unexpected, icaltext);
 1139     }
 1140 }
 1141     YY_BREAK
 1142 
 1143 case YY_STATE_EOF(INITIAL):
 1144 #line 272 "sbr/icalendar.l"
 1145 {
 1146     /* See next rule for when start state is not INITIAL. */
 1147     destroy_icallex ();
 1148     yyterminate ();
 1149 }
 1150     YY_BREAK
 1151 case YY_STATE_EOF(s_name):
 1152 case YY_STATE_EOF(s_colon):
 1153 case YY_STATE_EOF(s_value):
 1154 case YY_STATE_EOF(s_semicolon):
 1155 case YY_STATE_EOF(s_param_name):
 1156 case YY_STATE_EOF(s_equal):
 1157 case YY_STATE_EOF(s_comma):
 1158 #line 278 "sbr/icalendar.l"
 1159 {
 1160     /* Missing a final newline after a token.  The input does not conform
 1161        to RFC 5545 § 3.1, which requires that each contentline end with a
 1162        CRLF.  (Assume that the token is at the end of a contentline.)  Be
 1163        liberal in what we accept by faking a newline here, and setting the
 1164        start state to terminate on the next call. */
 1165     BEGIN (INITIAL);
 1166     return ICAL_CRLF;
 1167 }
 1168     YY_BREAK
 1169 case 17:
 1170 YY_RULE_SETUP
 1171 #line 288 "sbr/icalendar.l"
 1172 ECHO;
 1173     YY_BREAK
 1174 #line 1175 "sbr/icalendar.c"
 1175 
 1176     case YY_END_OF_BUFFER:
 1177         {
 1178         /* Amount of text matched not including the EOB char. */
 1179         int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
 1180 
 1181         /* Undo the effects of YY_DO_BEFORE_ACTION. */
 1182         *yy_cp = (yy_hold_char);
 1183         YY_RESTORE_YY_MORE_OFFSET
 1184 
 1185         if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
 1186             {
 1187             /* We're scanning a new file or input source.  It's
 1188              * possible that this happened because the user
 1189              * just pointed icalin at a new source and called
 1190              * icallex().  If so, then we have to assure
 1191              * consistency between YY_CURRENT_BUFFER and our
 1192              * globals.  Here is the right place to do so, because
 1193              * this is the first action (other than possibly a
 1194              * back-up) that will match for the new input source.
 1195              */
 1196             (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
 1197             YY_CURRENT_BUFFER_LVALUE->yy_input_file = icalin;
 1198             YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
 1199             }
 1200 
 1201         /* Note that here we test for yy_c_buf_p "<=" to the position
 1202          * of the first EOB in the buffer, since yy_c_buf_p will
 1203          * already have been incremented past the NUL character
 1204          * (since all states make transitions on EOB to the
 1205          * end-of-buffer state).  Contrast this with the test
 1206          * in input().
 1207          */
 1208         if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
 1209             { /* This was really a NUL. */
 1210             yy_state_type yy_next_state;
 1211 
 1212             (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
 1213 
 1214             yy_current_state = yy_get_previous_state(  );
 1215 
 1216             /* Okay, we're now positioned to make the NUL
 1217              * transition.  We couldn't have
 1218              * yy_get_previous_state() go ahead and do it
 1219              * for us because it doesn't know how to deal
 1220              * with the possibility of jamming (and we don't
 1221              * want to build jamming into it because then it
 1222              * will run more slowly).
 1223              */
 1224 
 1225             yy_next_state = yy_try_NUL_trans( yy_current_state );
 1226 
 1227             yy_bp = (yytext_ptr) + YY_MORE_ADJ;
 1228 
 1229             if ( yy_next_state )
 1230                 {
 1231                 /* Consume the NUL. */
 1232                 yy_cp = ++(yy_c_buf_p);
 1233                 yy_current_state = yy_next_state;
 1234                 goto yy_match;
 1235                 }
 1236 
 1237             else
 1238                 {
 1239                 yy_cp = (yy_last_accepting_cpos);
 1240                 yy_current_state = (yy_last_accepting_state);
 1241                 goto yy_find_action;
 1242                 }
 1243             }
 1244 
 1245         else switch ( yy_get_next_buffer(  ) )
 1246             {
 1247             case EOB_ACT_END_OF_FILE:
 1248                 {
 1249                 (yy_did_buffer_switch_on_eof) = 0;
 1250 
 1251                 if ( icalwrap( ) )
 1252                     {
 1253                     /* Note: because we've taken care in
 1254                      * yy_get_next_buffer() to have set up
 1255                      * icaltext, we can now set up
 1256                      * yy_c_buf_p so that if some total
 1257                      * hoser (like flex itself) wants to
 1258                      * call the scanner after we return the
 1259                      * YY_NULL, it'll still work - another
 1260                      * YY_NULL will get returned.
 1261                      */
 1262                     (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
 1263 
 1264                     yy_act = YY_STATE_EOF(YY_START);
 1265                     goto do_action;
 1266                     }
 1267 
 1268                 else
 1269                     {
 1270                     if ( ! (yy_did_buffer_switch_on_eof) )
 1271                         YY_NEW_FILE;
 1272                     }
 1273                 break;
 1274                 }
 1275 
 1276             case EOB_ACT_CONTINUE_SCAN:
 1277                 (yy_c_buf_p) =
 1278                     (yytext_ptr) + yy_amount_of_matched_text;
 1279 
 1280                 yy_current_state = yy_get_previous_state(  );
 1281 
 1282                 yy_cp = (yy_c_buf_p);
 1283                 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
 1284                 goto yy_match;
 1285 
 1286             case EOB_ACT_LAST_MATCH:
 1287                 (yy_c_buf_p) =
 1288                 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
 1289 
 1290                 yy_current_state = yy_get_previous_state(  );
 1291 
 1292                 yy_cp = (yy_c_buf_p);
 1293                 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
 1294                 goto yy_find_action;
 1295             }
 1296         break;
 1297         }
 1298 
 1299     default:
 1300         YY_FATAL_ERROR(
 1301             "fatal flex scanner internal error--no action found" );
 1302     } /* end of action switch */
 1303         } /* end of scanning one token */
 1304 } /* end of icallex */
 1305 
 1306 /* yy_get_next_buffer - try to read in a new buffer
 1307  *
 1308  * Returns a code representing an action:
 1309  *  EOB_ACT_LAST_MATCH -
 1310  *  EOB_ACT_CONTINUE_SCAN - continue scanning from current position
 1311  *  EOB_ACT_END_OF_FILE - end of file
 1312  */
 1313 static int yy_get_next_buffer (void)
 1314 {
 1315         register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
 1316     register char *source = (yytext_ptr);
 1317     register int number_to_move, i;
 1318     int ret_val;
 1319 
 1320     if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
 1321         YY_FATAL_ERROR(
 1322         "fatal flex scanner internal error--end of buffer missed" );
 1323 
 1324     if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
 1325         { /* Don't try to fill the buffer, so this is an EOF. */
 1326         if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
 1327             {
 1328             /* We matched a single character, the EOB, so
 1329              * treat this as a final EOF.
 1330              */
 1331             return EOB_ACT_END_OF_FILE;
 1332             }
 1333 
 1334         else
 1335             {
 1336             /* We matched some text prior to the EOB, first
 1337              * process it.
 1338              */
 1339             return EOB_ACT_LAST_MATCH;
 1340             }
 1341         }
 1342 
 1343     /* Try to read more data. */
 1344 
 1345     /* First move last chars to start of buffer. */
 1346     number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
 1347 
 1348     for ( i = 0; i < number_to_move; ++i )
 1349         *(dest++) = *(source++);
 1350 
 1351     if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
 1352         /* don't do the read, it's not guaranteed to return an EOF,
 1353          * just force an EOF
 1354          */
 1355         YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
 1356 
 1357     else
 1358         {
 1359             yy_size_t num_to_read =
 1360             YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
 1361 
 1362         while ( num_to_read <= 0 )
 1363             { /* Not enough room in the buffer - grow it. */
 1364 
 1365             /* just a shorter name for the current buffer */
 1366             YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
 1367 
 1368             int yy_c_buf_p_offset =
 1369                 (int) ((yy_c_buf_p) - b->yy_ch_buf);
 1370 
 1371             if ( b->yy_is_our_buffer )
 1372                 {
 1373                 yy_size_t new_size = b->yy_buf_size * 2;
 1374 
 1375                 if ( new_size <= 0 )
 1376                     b->yy_buf_size += b->yy_buf_size / 8;
 1377                 else
 1378                     b->yy_buf_size *= 2;
 1379 
 1380                 b->yy_ch_buf = (char *)
 1381                     /* Include room in for 2 EOB chars. */
 1382                     icalrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2  );
 1383                 }
 1384             else
 1385                 /* Can't grow it, we don't own it. */
 1386                 b->yy_ch_buf = 0;
 1387 
 1388             if ( ! b->yy_ch_buf )
 1389                 YY_FATAL_ERROR(
 1390                 "fatal error - scanner input buffer overflow" );
 1391 
 1392             (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
 1393 
 1394             num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
 1395                         number_to_move - 1;
 1396 
 1397             }
 1398 
 1399         if ( num_to_read > YY_READ_BUF_SIZE )
 1400             num_to_read = YY_READ_BUF_SIZE;
 1401 
 1402         /* Read in more data. */
 1403         YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
 1404             (yy_n_chars), num_to_read );
 1405 
 1406         YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
 1407         }
 1408 
 1409     if ( (yy_n_chars) == 0 )
 1410         {
 1411         if ( number_to_move == YY_MORE_ADJ )
 1412             {
 1413             ret_val = EOB_ACT_END_OF_FILE;
 1414             icalrestart(icalin  );
 1415             }
 1416 
 1417         else
 1418             {
 1419             ret_val = EOB_ACT_LAST_MATCH;
 1420             YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
 1421                 YY_BUFFER_EOF_PENDING;
 1422             }
 1423         }
 1424 
 1425     else
 1426         ret_val = EOB_ACT_CONTINUE_SCAN;
 1427 
 1428     if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
 1429         /* Extend the array by 50%, plus the number we really need. */
 1430         yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
 1431         YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) icalrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size  );
 1432         if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
 1433             YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
 1434     }
 1435 
 1436     (yy_n_chars) += number_to_move;
 1437     YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
 1438     YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
 1439 
 1440     (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
 1441 
 1442     return ret_val;
 1443 }
 1444 
 1445 /* yy_get_previous_state - get the state just before the EOB char was reached */
 1446 
 1447     static yy_state_type yy_get_previous_state (void)
 1448 {
 1449     register yy_state_type yy_current_state;
 1450     register char *yy_cp;
 1451     
 1452     yy_current_state = (yy_start);
 1453 
 1454     for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
 1455         {
 1456         register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
 1457         if ( yy_accept[yy_current_state] )
 1458             {
 1459             (yy_last_accepting_state) = yy_current_state;
 1460             (yy_last_accepting_cpos) = yy_cp;
 1461             }
 1462         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 1463             {
 1464             yy_current_state = (int) yy_def[yy_current_state];
 1465             if ( yy_current_state >= 125 )
 1466                 yy_c = yy_meta[(unsigned int) yy_c];
 1467             }
 1468         yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
 1469         }
 1470 
 1471     return yy_current_state;
 1472 }
 1473 
 1474 /* yy_try_NUL_trans - try to make a transition on the NUL character
 1475  *
 1476  * synopsis
 1477  *  next_state = yy_try_NUL_trans( current_state );
 1478  */
 1479     static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state )
 1480 {
 1481     register int yy_is_jam;
 1482         register char *yy_cp = (yy_c_buf_p);
 1483 
 1484     register YY_CHAR yy_c = 1;
 1485     if ( yy_accept[yy_current_state] )
 1486         {
 1487         (yy_last_accepting_state) = yy_current_state;
 1488         (yy_last_accepting_cpos) = yy_cp;
 1489         }
 1490     while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 1491         {
 1492         yy_current_state = (int) yy_def[yy_current_state];
 1493         if ( yy_current_state >= 125 )
 1494             yy_c = yy_meta[(unsigned int) yy_c];
 1495         }
 1496     yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
 1497     yy_is_jam = (yy_current_state == 124);
 1498 
 1499     return yy_is_jam ? 0 : yy_current_state;
 1500 }
 1501 
 1502     static void yyunput (int c, register char * yy_bp )
 1503 {
 1504     register char *yy_cp;
 1505     
 1506     yy_cp = (yy_c_buf_p);
 1507 
 1508     /* undo effects of setting up icaltext */
 1509     *yy_cp = (yy_hold_char);
 1510 
 1511     if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
 1512         { /* need to shift things up to make room */
 1513         /* +2 for EOB chars. */
 1514         register yy_size_t number_to_move = (yy_n_chars) + 2;
 1515         register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
 1516                     YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
 1517         register char *source =
 1518                 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
 1519 
 1520         while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
 1521             *--dest = *--source;
 1522 
 1523         yy_cp += (int) (dest - source);
 1524         yy_bp += (int) (dest - source);
 1525         YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
 1526             (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
 1527 
 1528         if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
 1529             YY_FATAL_ERROR( "flex scanner push-back overflow" );
 1530         }
 1531 
 1532     *--yy_cp = (char) c;
 1533 
 1534     (yytext_ptr) = yy_bp;
 1535     (yy_hold_char) = *yy_cp;
 1536     (yy_c_buf_p) = yy_cp;
 1537 }
 1538 
 1539 #ifndef YY_NO_INPUT
 1540 #ifdef __cplusplus
 1541     static int yyinput (void)
 1542 #else
 1543     static int input  (void)
 1544 #endif
 1545 
 1546 {
 1547     int c;
 1548     
 1549     *(yy_c_buf_p) = (yy_hold_char);
 1550 
 1551     if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
 1552         {
 1553         /* yy_c_buf_p now points to the character we want to return.
 1554          * If this occurs *before* the EOB characters, then it's a
 1555          * valid NUL; if not, then we've hit the end of the buffer.
 1556          */
 1557         if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
 1558             /* This was really a NUL. */
 1559             *(yy_c_buf_p) = '\0';
 1560 
 1561         else
 1562             { /* need more input */
 1563             yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
 1564             ++(yy_c_buf_p);
 1565 
 1566             switch ( yy_get_next_buffer(  ) )
 1567                 {
 1568                 case EOB_ACT_LAST_MATCH:
 1569                     /* This happens because yy_g_n_b()
 1570                      * sees that we've accumulated a
 1571                      * token and flags that we need to
 1572                      * try matching the token before
 1573                      * proceeding.  But for input(),
 1574                      * there's no matching to consider.
 1575                      * So convert the EOB_ACT_LAST_MATCH
 1576                      * to EOB_ACT_END_OF_FILE.
 1577                      */
 1578 
 1579                     /* Reset buffer status. */
 1580                     icalrestart(icalin );
 1581 
 1582                     /*FALLTHROUGH*/
 1583 
 1584                 case EOB_ACT_END_OF_FILE:
 1585                     {
 1586                     if ( icalwrap( ) )
 1587                         return 0;
 1588 
 1589                     if ( ! (yy_did_buffer_switch_on_eof) )
 1590                         YY_NEW_FILE;
 1591 #ifdef __cplusplus
 1592                     return yyinput();
 1593 #else
 1594                     return input();
 1595 #endif
 1596                     }
 1597 
 1598                 case EOB_ACT_CONTINUE_SCAN:
 1599                     (yy_c_buf_p) = (yytext_ptr) + offset;
 1600                     break;
 1601                 }
 1602             }
 1603         }
 1604 
 1605     c = *(unsigned char *) (yy_c_buf_p);    /* cast for 8-bit char's */
 1606     *(yy_c_buf_p) = '\0';   /* preserve icaltext */
 1607     (yy_hold_char) = *++(yy_c_buf_p);
 1608 
 1609     return c;
 1610 }
 1611 #endif  /* ifndef YY_NO_INPUT */
 1612 
 1613 /** Immediately switch to a different input stream.
 1614  * @param input_file A readable stream.
 1615  * 
 1616  * @note This function does not reset the start condition to @c INITIAL .
 1617  */
 1618     void icalrestart  (FILE * input_file )
 1619 {
 1620     
 1621     if ( ! YY_CURRENT_BUFFER ){
 1622         icalensure_buffer_stack ();
 1623         YY_CURRENT_BUFFER_LVALUE =
 1624             ical_create_buffer(icalin,YY_BUF_SIZE );
 1625     }
 1626 
 1627     ical_init_buffer(YY_CURRENT_BUFFER,input_file );
 1628     ical_load_buffer_state( );
 1629 }
 1630 
 1631 /** Switch to a different input buffer.
 1632  * @param new_buffer The new input buffer.
 1633  * 
 1634  */
 1635     void ical_switch_to_buffer  (YY_BUFFER_STATE  new_buffer )
 1636 {
 1637     
 1638     /* TODO. We should be able to replace this entire function body
 1639      * with
 1640      *      icalpop_buffer_state();
 1641      *      icalpush_buffer_state(new_buffer);
 1642      */
 1643     icalensure_buffer_stack ();
 1644     if ( YY_CURRENT_BUFFER == new_buffer )
 1645         return;
 1646 
 1647     if ( YY_CURRENT_BUFFER )
 1648         {
 1649         /* Flush out information for old buffer. */
 1650         *(yy_c_buf_p) = (yy_hold_char);
 1651         YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
 1652         YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
 1653         }
 1654 
 1655     YY_CURRENT_BUFFER_LVALUE = new_buffer;
 1656     ical_load_buffer_state( );
 1657 
 1658     /* We don't actually know whether we did this switch during
 1659      * EOF (icalwrap()) processing, but the only time this flag
 1660      * is looked at is after icalwrap() is called, so it's safe
 1661      * to go ahead and always set it.
 1662      */
 1663     (yy_did_buffer_switch_on_eof) = 1;
 1664 }
 1665 
 1666 static void ical_load_buffer_state  (void)
 1667 {
 1668         (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
 1669     (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
 1670     icalin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
 1671     (yy_hold_char) = *(yy_c_buf_p);
 1672 }
 1673 
 1674 /** Allocate and initialize an input buffer state.
 1675  * @param file A readable stream.
 1676  * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
 1677  * 
 1678  * @return the allocated buffer state.
 1679  */
 1680     YY_BUFFER_STATE ical_create_buffer  (FILE * file, int  size )
 1681 {
 1682     YY_BUFFER_STATE b;
 1683     
 1684     b = (YY_BUFFER_STATE) icalalloc(sizeof( struct yy_buffer_state )  );
 1685     if ( ! b )
 1686         YY_FATAL_ERROR( "out of dynamic memory in ical_create_buffer()" );
 1687 
 1688     b->yy_buf_size = size;
 1689 
 1690     /* yy_ch_buf has to be 2 characters longer than the size given because
 1691      * we need to put in 2 end-of-buffer characters.
 1692      */
 1693     b->yy_ch_buf = (char *) icalalloc(b->yy_buf_size + 2  );
 1694     if ( ! b->yy_ch_buf )
 1695         YY_FATAL_ERROR( "out of dynamic memory in ical_create_buffer()" );
 1696 
 1697     b->yy_is_our_buffer = 1;
 1698 
 1699     ical_init_buffer(b,file );
 1700 
 1701     return b;
 1702 }
 1703 
 1704 /** Destroy the buffer.
 1705  * @param b a buffer created with ical_create_buffer()
 1706  * 
 1707  */
 1708     void ical_delete_buffer (YY_BUFFER_STATE  b )
 1709 {
 1710     
 1711     if ( ! b )
 1712         return;
 1713 
 1714     if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
 1715         YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
 1716 
 1717     if ( b->yy_is_our_buffer )
 1718         icalfree((void *) b->yy_ch_buf  );
 1719 
 1720     icalfree((void *) b  );
 1721 }
 1722 
 1723 /* Initializes or reinitializes a buffer.
 1724  * This function is sometimes called more than once on the same buffer,
 1725  * such as during a icalrestart() or at EOF.
 1726  */
 1727     static void ical_init_buffer  (YY_BUFFER_STATE  b, FILE * file )
 1728 
 1729 {
 1730     int oerrno = errno;
 1731     
 1732     ical_flush_buffer(b );
 1733 
 1734     b->yy_input_file = file;
 1735     b->yy_fill_buffer = 1;
 1736 
 1737     /* If b is the current buffer, then ical_init_buffer was _probably_
 1738      * called from icalrestart() or through yy_get_next_buffer.
 1739      * In that case, we don't want to reset the lineno or column.
 1740      */
 1741     if (b != YY_CURRENT_BUFFER){
 1742         b->yy_bs_lineno = 1;
 1743         b->yy_bs_column = 0;
 1744     }
 1745 
 1746         b->yy_is_interactive = 0;
 1747     
 1748     errno = oerrno;
 1749 }
 1750 
 1751 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
 1752  * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
 1753  * 
 1754  */
 1755     void ical_flush_buffer (YY_BUFFER_STATE  b )
 1756 {
 1757         if ( ! b )
 1758         return;
 1759 
 1760     b->yy_n_chars = 0;
 1761 
 1762     /* We always need two end-of-buffer characters.  The first causes
 1763      * a transition to the end-of-buffer state.  The second causes
 1764      * a jam in that state.
 1765      */
 1766     b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
 1767     b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
 1768 
 1769     b->yy_buf_pos = &b->yy_ch_buf[0];
 1770 
 1771     b->yy_at_bol = 1;
 1772     b->yy_buffer_status = YY_BUFFER_NEW;
 1773 
 1774     if ( b == YY_CURRENT_BUFFER )
 1775         ical_load_buffer_state( );
 1776 }
 1777 
 1778 /** Pushes the new state onto the stack. The new state becomes
 1779  *  the current state. This function will allocate the stack
 1780  *  if necessary.
 1781  *  @param new_buffer The new state.
 1782  *  
 1783  */
 1784 void icalpush_buffer_state (YY_BUFFER_STATE new_buffer )
 1785 {
 1786         if (new_buffer == NULL)
 1787         return;
 1788 
 1789     icalensure_buffer_stack();
 1790 
 1791     /* This block is copied from ical_switch_to_buffer. */
 1792     if ( YY_CURRENT_BUFFER )
 1793         {
 1794         /* Flush out information for old buffer. */
 1795         *(yy_c_buf_p) = (yy_hold_char);
 1796         YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
 1797         YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
 1798         }
 1799 
 1800     /* Only push if top exists. Otherwise, replace top. */
 1801     if (YY_CURRENT_BUFFER)
 1802         (yy_buffer_stack_top)++;
 1803     YY_CURRENT_BUFFER_LVALUE = new_buffer;
 1804 
 1805     /* copied from ical_switch_to_buffer. */
 1806     ical_load_buffer_state( );
 1807     (yy_did_buffer_switch_on_eof) = 1;
 1808 }
 1809 
 1810 /** Removes and deletes the top of the stack, if present.
 1811  *  The next element becomes the new top.
 1812  *  
 1813  */
 1814 void icalpop_buffer_state (void)
 1815 {
 1816         if (!YY_CURRENT_BUFFER)
 1817         return;
 1818 
 1819     ical_delete_buffer(YY_CURRENT_BUFFER );
 1820     YY_CURRENT_BUFFER_LVALUE = NULL;
 1821     if ((yy_buffer_stack_top) > 0)
 1822         --(yy_buffer_stack_top);
 1823 
 1824     if (YY_CURRENT_BUFFER) {
 1825         ical_load_buffer_state( );
 1826         (yy_did_buffer_switch_on_eof) = 1;
 1827     }
 1828 }
 1829 
 1830 /* Allocates the stack if it does not exist.
 1831  *  Guarantees space for at least one push.
 1832  */
 1833 static void icalensure_buffer_stack (void)
 1834 {
 1835     yy_size_t num_to_alloc;
 1836     
 1837     if (!(yy_buffer_stack)) {
 1838 
 1839         /* First allocation is just for 2 elements, since we don't know if this
 1840          * scanner will even need a stack. We use 2 instead of 1 to avoid an
 1841          * immediate realloc on the next call.
 1842          */
 1843         num_to_alloc = 1;
 1844         (yy_buffer_stack) = (struct yy_buffer_state**)icalalloc
 1845                                 (num_to_alloc * sizeof(struct yy_buffer_state*)
 1846                                 );
 1847         if ( ! (yy_buffer_stack) )
 1848             YY_FATAL_ERROR( "out of dynamic memory in icalensure_buffer_stack()" );
 1849                                   
 1850         memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
 1851                 
 1852         (yy_buffer_stack_max) = num_to_alloc;
 1853         (yy_buffer_stack_top) = 0;
 1854         return;
 1855     }
 1856 
 1857     if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
 1858 
 1859         /* Increase the buffer to prepare for a possible push. */
 1860         int grow_size = 8 /* arbitrary grow size */;
 1861 
 1862         num_to_alloc = (yy_buffer_stack_max) + grow_size;
 1863         (yy_buffer_stack) = (struct yy_buffer_state**)icalrealloc
 1864                                 ((yy_buffer_stack),
 1865                                 num_to_alloc * sizeof(struct yy_buffer_state*)
 1866                                 );
 1867         if ( ! (yy_buffer_stack) )
 1868             YY_FATAL_ERROR( "out of dynamic memory in icalensure_buffer_stack()" );
 1869 
 1870         /* zero only the new slots.*/
 1871         memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
 1872         (yy_buffer_stack_max) = num_to_alloc;
 1873     }
 1874 }
 1875 
 1876 /** Setup the input buffer state to scan directly from a user-specified character buffer.
 1877  * @param base the character buffer
 1878  * @param size the size in bytes of the character buffer
 1879  * 
 1880  * @return the newly allocated buffer state object. 
 1881  */
 1882 YY_BUFFER_STATE ical_scan_buffer  (char * base, yy_size_t  size )
 1883 {
 1884     YY_BUFFER_STATE b;
 1885     
 1886     if ( size < 2 ||
 1887          base[size-2] != YY_END_OF_BUFFER_CHAR ||
 1888          base[size-1] != YY_END_OF_BUFFER_CHAR )
 1889         /* They forgot to leave room for the EOB's. */
 1890         return 0;
 1891 
 1892     b = (YY_BUFFER_STATE) icalalloc(sizeof( struct yy_buffer_state )  );
 1893     if ( ! b )
 1894         YY_FATAL_ERROR( "out of dynamic memory in ical_scan_buffer()" );
 1895 
 1896     b->yy_buf_size = size - 2;  /* "- 2" to take care of EOB's */
 1897     b->yy_buf_pos = b->yy_ch_buf = base;
 1898     b->yy_is_our_buffer = 0;
 1899     b->yy_input_file = 0;
 1900     b->yy_n_chars = b->yy_buf_size;
 1901     b->yy_is_interactive = 0;
 1902     b->yy_at_bol = 1;
 1903     b->yy_fill_buffer = 0;
 1904     b->yy_buffer_status = YY_BUFFER_NEW;
 1905 
 1906     ical_switch_to_buffer(b  );
 1907 
 1908     return b;
 1909 }
 1910 
 1911 /** Setup the input buffer state to scan a string. The next call to icallex() will
 1912  * scan from a @e copy of @a str.
 1913  * @param yystr a NUL-terminated string to scan
 1914  * 
 1915  * @return the newly allocated buffer state object.
 1916  * @note If you want to scan bytes that may contain NUL values, then use
 1917  *       ical_scan_bytes() instead.
 1918  */
 1919 YY_BUFFER_STATE ical_scan_string (yyconst char * yystr )
 1920 {
 1921     
 1922     return ical_scan_bytes(yystr,strlen(yystr) );
 1923 }
 1924 
 1925 /** Setup the input buffer state to scan the given bytes. The next call to icallex() will
 1926  * scan from a @e copy of @a bytes.
 1927  * @param bytes the byte buffer to scan
 1928  * @param len the number of bytes in the buffer pointed to by @a bytes.
 1929  * 
 1930  * @return the newly allocated buffer state object.
 1931  */
 1932 YY_BUFFER_STATE ical_scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_len )
 1933 {
 1934     YY_BUFFER_STATE b;
 1935     char *buf;
 1936     yy_size_t n, i;
 1937     
 1938     /* Get memory for full buffer, including space for trailing EOB's. */
 1939     n = _yybytes_len + 2;
 1940     buf = (char *) icalalloc(n  );
 1941     if ( ! buf )
 1942         YY_FATAL_ERROR( "out of dynamic memory in ical_scan_bytes()" );
 1943 
 1944     for ( i = 0; i < _yybytes_len; ++i )
 1945         buf[i] = yybytes[i];
 1946 
 1947     buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
 1948 
 1949     b = ical_scan_buffer(buf,n );
 1950     if ( ! b )
 1951         YY_FATAL_ERROR( "bad buffer in ical_scan_bytes()" );
 1952 
 1953     /* It's okay to grow etc. this buffer, and we should throw it
 1954      * away when we're done.
 1955      */
 1956     b->yy_is_our_buffer = 1;
 1957 
 1958     return b;
 1959 }
 1960 
 1961 #ifndef YY_EXIT_FAILURE
 1962 #define YY_EXIT_FAILURE 2
 1963 #endif
 1964 
 1965 static void yy_fatal_error (yyconst char* msg )
 1966 {
 1967         (void) fprintf( stderr, "%s\n", msg );
 1968     exit( YY_EXIT_FAILURE );
 1969 }
 1970 
 1971 /* Redefine yyless() so it works in section 3 code. */
 1972 
 1973 #undef yyless
 1974 #define yyless(n) \
 1975     do \
 1976         { \
 1977         /* Undo effects of setting up icaltext. */ \
 1978         int yyless_macro_arg = (n); \
 1979         YY_LESS_LINENO(yyless_macro_arg);\
 1980         icaltext[icalleng] = (yy_hold_char); \
 1981         (yy_c_buf_p) = icaltext + yyless_macro_arg; \
 1982         (yy_hold_char) = *(yy_c_buf_p); \
 1983         *(yy_c_buf_p) = '\0'; \
 1984         icalleng = yyless_macro_arg; \
 1985         } \
 1986     while ( 0 )
 1987 
 1988 /* Accessor  methods (get/set functions) to struct members. */
 1989 
 1990 /** Get the current line number.
 1991  * 
 1992  */
 1993 int icalget_lineno  (void)
 1994 {
 1995         
 1996     return icallineno;
 1997 }
 1998 
 1999 /** Get the input stream.
 2000  * 
 2001  */
 2002 FILE *icalget_in  (void)
 2003 {
 2004         return icalin;
 2005 }
 2006 
 2007 /** Get the output stream.
 2008  * 
 2009  */
 2010 FILE *icalget_out  (void)
 2011 {
 2012         return icalout;
 2013 }
 2014 
 2015 /** Get the length of the current token.
 2016  * 
 2017  */
 2018 yy_size_t icalget_leng  (void)
 2019 {
 2020         return icalleng;
 2021 }
 2022 
 2023 /** Get the current token.
 2024  * 
 2025  */
 2026 
 2027 char *icalget_text  (void)
 2028 {
 2029         return icaltext;
 2030 }
 2031 
 2032 /** Set the current line number.
 2033  * @param line_number
 2034  * 
 2035  */
 2036 void icalset_lineno (int  line_number )
 2037 {
 2038     
 2039     icallineno = line_number;
 2040 }
 2041 
 2042 /** Set the input stream. This does not discard the current
 2043  * input buffer.
 2044  * @param in_str A readable stream.
 2045  * 
 2046  * @see ical_switch_to_buffer
 2047  */
 2048 void icalset_in (FILE *  in_str )
 2049 {
 2050         icalin = in_str ;
 2051 }
 2052 
 2053 void icalset_out (FILE *  out_str )
 2054 {
 2055         icalout = out_str ;
 2056 }
 2057 
 2058 int icalget_debug  (void)
 2059 {
 2060         return ical_flex_debug;
 2061 }
 2062 
 2063 void icalset_debug (int  bdebug )
 2064 {
 2065         ical_flex_debug = bdebug ;
 2066 }
 2067 
 2068 static int yy_init_globals (void)
 2069 {
 2070         /* Initialization is the same as for the non-reentrant scanner.
 2071      * This function is called from icallex_destroy(), so don't allocate here.
 2072      */
 2073 
 2074     (yy_buffer_stack) = 0;
 2075     (yy_buffer_stack_top) = 0;
 2076     (yy_buffer_stack_max) = 0;
 2077     (yy_c_buf_p) = (char *) 0;
 2078     (yy_init) = 0;
 2079     (yy_start) = 0;
 2080 
 2081 /* Defined in main.c */
 2082 #ifdef YY_STDINIT
 2083     icalin = stdin;
 2084     icalout = stdout;
 2085 #else
 2086     icalin = (FILE *) 0;
 2087     icalout = (FILE *) 0;
 2088 #endif
 2089 
 2090     /* For future reference: Set errno on error, since we are called by
 2091      * icallex_init()
 2092      */
 2093     return 0;
 2094 }
 2095 
 2096 /* icallex_destroy is for both reentrant and non-reentrant scanners. */
 2097 int icallex_destroy  (void)
 2098 {
 2099     
 2100     /* Pop the buffer stack, destroying each element. */
 2101     while(YY_CURRENT_BUFFER){
 2102         ical_delete_buffer(YY_CURRENT_BUFFER  );
 2103         YY_CURRENT_BUFFER_LVALUE = NULL;
 2104         icalpop_buffer_state();
 2105     }
 2106 
 2107     /* Destroy the stack itself. */
 2108     icalfree((yy_buffer_stack) );
 2109     (yy_buffer_stack) = NULL;
 2110 
 2111     /* Reset the globals. This is important in a non-reentrant scanner so the next time
 2112      * icallex() is called, initialization will occur. */
 2113     yy_init_globals( );
 2114 
 2115     return 0;
 2116 }
 2117 
 2118 /*
 2119  * Internal utility routines.
 2120  */
 2121 
 2122 #ifndef yytext_ptr
 2123 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
 2124 {
 2125     register int i;
 2126     for ( i = 0; i < n; ++i )
 2127         s1[i] = s2[i];
 2128 }
 2129 #endif
 2130 
 2131 #ifdef YY_NEED_STRLEN
 2132 static int yy_flex_strlen (yyconst char * s )
 2133 {
 2134     register int n;
 2135     for ( n = 0; s[n]; ++n )
 2136         ;
 2137 
 2138     return n;
 2139 }
 2140 #endif
 2141 
 2142 void *icalalloc (yy_size_t  size )
 2143 {
 2144     return (void *) malloc( size );
 2145 }
 2146 
 2147 void *icalrealloc  (void * ptr, yy_size_t  size )
 2148 {
 2149     /* The cast to (char *) in the following accommodates both
 2150      * implementations that use char* generic pointers, and those
 2151      * that use void* generic pointers.  It works with the latter
 2152      * because both ANSI C and C++ allow castless assignment from
 2153      * any pointer type to void*, and deal with argument conversions
 2154      * as though doing an assignment.
 2155      */
 2156     return (void *) realloc( (char *) ptr, size );
 2157 }
 2158 
 2159 void icalfree (void * ptr )
 2160 {
 2161     free( (char *) ptr );   /* see icalrealloc() for (char *) cast */
 2162 }
 2163 
 2164 #define YYTABLES_NAME "yytables"
 2165 
 2166 #line 288 "sbr/icalendar.l"
 2167 
 2168 
 2169 
 2170 static char *
 2171 unfold (char *text, size_t *leng) {
 2172     /* It's legal to shorten text and modify leng (because we don't
 2173        use yymore()). */
 2174     char *cp;
 2175 
 2176     /* First squash any CR-LF-WSP sequences. */
 2177     while ((cp = strstr (text, "\r\n "))  ||  (cp = strstr (text, "\r\n\t"))) {
 2178         /* Subtract any characters prior to fold sequence and 3 for
 2179            the fold sequence, and add 1 for the terminating null. */
 2180         (void) memmove (cp, cp + 3, *leng - (cp - text) - 3 + 1);
 2181         *leng -= 3;
 2182     }
 2183 
 2184     /* Then squash any LF-WSP sequences. */
 2185     while ((cp = strstr (text, "\n "))  ||  (cp = strstr (text, "\n\t"))) {
 2186         /* Subtract any characters prior to fold sequence and 2 for
 2187            the fold sequence, and add 1 for the terminating null. */
 2188         (void) memmove (cp, cp + 2, *leng - (cp - text) - 2 + 1);
 2189         *leng -= 2;
 2190     }
 2191 
 2192     return text;
 2193 }
 2194 
 2195 
 2196 /*
 2197  * To clean up memory, call the function provided by modern
 2198  * versions of flex.  Older versions don't have it, and of
 2199  * course this won't do anything if the scanner was built
 2200  * with something other than flex.
 2201  */
 2202 static void
 2203 destroy_icallex(void) {
 2204 #if defined FLEX_SCANNER  &&  defined YY_FLEX_SUBMINOR_VERSION
 2205     /* Hack:  rely on fact that the the YY_FLEX_SUBMINOR_VERSION
 2206        #define was added to flex (flex.skl v. 2.163) after
 2207        #icallex_destroy() was added. */
 2208     icallex_destroy ();
 2209 #endif /* FLEX_SCANNER  &&  YY_CURRENT_BUFFER_LVALUE */
 2210 }
 2211 
 2212 /*
 2213  * See comment in h/icalendar.h about having to provide these
 2214  * because flex 2.5.4 doesn't.
 2215  */
 2216 void
 2217 icalset_inputfile (FILE *file) {
 2218     icalin = file;
 2219 }
 2220 
 2221 void
 2222 icalset_outputfile (FILE *file) {
 2223     icalout = file;
 2224 }
 2225 
 2226 /*
 2227  * Porting notes
 2228  * -------------
 2229  * POSIX lex only supports an entry point name of icallex().  nmh
 2230  * programs can contain multiple scanners (see sbr/dtimep.l), so
 2231  * nmh requires the use of flex to build them.
 2232  * In addition, if there is a need to port this to Solaris lex:
 2233  *  - Use the lex -e or -w option.
 2234  *  - Comment out all of the %options.
 2235  *  - Comment out the <<EOF>> rule.
 2236  *  - The start condition and pattern must be on the same line.
 2237  *  - Comments must be inside rules, not just before them.
 2238  *  - Don't use start condition stack.  In the code, above BEGIN's are
 2239  *    used instead, and the contents of an imaginary start condition
 2240  *    stack are shown after each.  The stack operations are also shown
 2241  *    in comments.
 2242  */
 2243