35 |
ino_t sieve_source_inode; |
ino_t sieve_source_inode; |
36 |
|
|
37 |
static list_t string_list; |
static list_t string_list; |
38 |
|
static char *multiline_delimiter; |
39 |
|
static int strip_tabs; |
40 |
|
|
41 |
static int number __P ((void)); |
static int number __P ((void)); |
42 |
static int string __P ((void)); |
static int string __P ((void)); |
43 |
static void multiline_begin __P ((void)); |
static void multiline_begin __P ((void)); |
47 |
static void sieve_include __P((void)); |
static void sieve_include __P((void)); |
48 |
static void sieve_searchpath __P((void)); |
static void sieve_searchpath __P((void)); |
49 |
static char *str_escape __P((void)); |
static char *str_escape __P((void)); |
50 |
|
static int isemptystr __P((char *text)); |
51 |
|
|
52 |
#ifdef FLEX_SCANNER |
#ifdef FLEX_SCANNER |
53 |
#define xinput() (yyin ? getc(yyin) : EOF) |
#define xinput() (yyin ? getc(yyin) : EOF) |
356 |
multiline_add (NULL); |
multiline_add (NULL); |
357 |
multiline_finish (); |
multiline_finish (); |
358 |
return STRING; } |
return STRING; } |
359 |
text:[ \t]*#.*\n { BEGIN(ML); multiline_begin (); } |
text:-?[ \t]*#.*\n { BEGIN(ML); multiline_begin (); } |
360 |
text:[ \t]*\n { BEGIN(ML); multiline_begin (); } |
text:-?[ \t]*\n { BEGIN(ML); multiline_begin (); } |
361 |
<ML>.[ \t]*\n { BEGIN(INITIAL); |
text:-?\\?{IDENT}[ \t]*#.*\n { BEGIN(ML); multiline_begin (); } |
362 |
sieve_line_num++; |
text:-?\\?{IDENT}[ \t]*\n { BEGIN(ML); multiline_begin (); } |
363 |
multiline_finish (); |
<ML>#[ \t]*include.*\n { if (multiline_delimiter[0] == '\\') |
364 |
return MULTILINE; } |
multiline_add (NULL); |
365 |
<ML>#[ \t]*include.*\n { sieve_include (); } |
else |
366 |
<ML>.*\n { sieve_line_num++; multiline_add (NULL); } |
sieve_include (); } |
367 |
|
<ML>.*\n { char *p = multiline_strip_tabs (yytext); |
368 |
|
sieve_line_num++; |
369 |
|
|
370 |
|
if (strncmp (p, multiline_delimiter, strlen (multiline_delimiter)) |
371 |
|
== 0 |
372 |
|
&& isemptystr (p + strlen (multiline_delimiter))) |
373 |
|
{ |
374 |
|
free (multiline_delimiter); |
375 |
|
multiline_delimiter = NULL; |
376 |
|
BEGIN(INITIAL); |
377 |
|
multiline_finish (); |
378 |
|
return MULTILINE; |
379 |
|
} |
380 |
|
multiline_add (NULL); } |
381 |
{WS} ; |
{WS} ; |
382 |
\n { sieve_line_num++; } |
\n { sieve_line_num++; } |
383 |
. return yytext[0]; |
. return yytext[0]; |
548 |
return STRING; |
return STRING; |
549 |
} |
} |
550 |
|
|
551 |
|
int |
552 |
|
isemptystr (char *text) |
553 |
|
{ |
554 |
|
for (; *text && isspace (*text); text++) |
555 |
|
; |
556 |
|
return *text == 0; |
557 |
|
} |
558 |
|
|
559 |
|
char * |
560 |
|
multiline_strip_tabs (char *text) |
561 |
|
{ |
562 |
|
if (strip_tabs) |
563 |
|
for (; *text == '\t'; text++) |
564 |
|
; |
565 |
|
return text; |
566 |
|
} |
567 |
|
|
568 |
void |
void |
569 |
multiline_add (char *s) |
multiline_add (char *s) |
570 |
{ |
{ |
571 |
if (!s) |
if (!s) |
572 |
{ |
{ |
573 |
s = strdup (yytext); |
s = strdup (multiline_strip_tabs (yytext)); |
574 |
if (!s) |
if (!s) |
575 |
{ |
{ |
576 |
yyerror ("not enough memory"); |
yyerror ("not enough memory"); |
584 |
multiline_begin () |
multiline_begin () |
585 |
{ |
{ |
586 |
int status; |
int status; |
587 |
|
char *p = yytext + 5; /* past the text: keyword */ |
588 |
|
|
589 |
|
if (*p == '-') |
590 |
|
{ |
591 |
|
strip_tabs = 1; |
592 |
|
p++; |
593 |
|
} |
594 |
|
else |
595 |
|
strip_tabs = 0; |
596 |
|
|
597 |
|
if (!isspace (*p)) |
598 |
|
{ |
599 |
|
char *endp; |
600 |
|
int len; |
601 |
|
|
602 |
|
for (endp = p; *endp; endp++) |
603 |
|
if (isspace (*endp)) |
604 |
|
break; |
605 |
|
|
606 |
|
len = endp - p; |
607 |
|
multiline_delimiter = sieve_alloc (len + 1); |
608 |
|
memcpy (multiline_delimiter, p, len); |
609 |
|
multiline_delimiter[len] = 0; |
610 |
|
} |
611 |
|
else |
612 |
|
{ |
613 |
|
multiline_delimiter = strdup ("."); |
614 |
|
if (!multiline_delimiter) |
615 |
|
{ |
616 |
|
yyerror ("not enough memory"); |
617 |
|
exit (1); |
618 |
|
} |
619 |
|
} |
620 |
|
|
621 |
if (string_list) |
if (string_list) |
622 |
sieve_slist_destroy (&string_list); |
sieve_slist_destroy (&string_list); |
627 |
"list_create: %s", mu_errstring (status)); |
"list_create: %s", mu_errstring (status)); |
628 |
exit (1); |
exit (1); |
629 |
} |
} |
630 |
|
|
631 |
} |
} |
632 |
|
|
633 |
void |
void |