X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=blobdiff_plain;f=src%2Fquote_fmt_lex.l;h=04975d63ee4877667fbd64b4fe119f70676e5f9a;hp=09bf366138bc194be3cf7b1920c061a7aed20ef6;hb=e1b446cafbfb4fb536b636fde6da98032f31aec3;hpb=1bb240ae558e620a6601783d0b722165303e9f38 diff --git a/src/quote_fmt_lex.l b/src/quote_fmt_lex.l index 09bf36613..04975d63e 100644 --- a/src/quote_fmt_lex.l +++ b/src/quote_fmt_lex.l @@ -1,33 +1,80 @@ %{ #include "quote_fmt_lex.h" #include "quote_fmt_parse.h" + +#define YY_NO_UNPUT 1 %} %option prefix="quote_fmt" %option outfile="lex.yy.c" +%s S_NORMAL S_DATE + +%{ +/* + * see notes below. + */ +int quote_fmt_firsttime = 1; +%} + %% -"%d" /* date */ return SHOW_DATE; -"%f" /* From */ return SHOW_FROM; -"%N" /* Full name */ return SHOW_FULLNAME; -"%F" /* firt name */ return SHOW_FIRST_NAME; -"%I" /* initial of sender */ return SHOW_SENDER_INITIAL; -"%s" /* subject */ return SHOW_SUBJECT; -"%t" /* to */ return SHOW_TO; -"%c" /* cc */ return SHOW_CC; -"%n" /* newsgroups */ return SHOW_NEWSGROUPS; -"%i" /* message-id */ return SHOW_MESSAGEID; -"%r" /* references */ return SHOW_REFERENCES; -"%M" /* message */ return SHOW_MESSAGE; -"%Q" /* quoted message */ return SHOW_QUOTED_MESSAGE; -"%%" /* % */ return SHOW_PERCENT; +%{ +/* + * NOTES: + * this lex script used to use characters also in use + * by strftime() (which we want to use for custom + * time formats in replies and templates). to circumvent + * this we have to play a little bit with states. + * + * these are the characters we also want to use in the + * %D time customizer: + * + * %a %A %b %B %c %C %d %H %I %j %m %M %p %S %w %x %y %Y %Z + * + * you can use these characters too, but don't forget to + * prepend them with the state. + * + * also there is also work around for resetting the state + * (firsttime variable). this assumes that yylex() will + * always return to S_NORMAL after quote fmt parsing is + * done. + */ +%} + +%{ + if (quote_fmt_firsttime) { + BEGIN S_NORMAL; + quote_fmt_firsttime = 0; + } +%} + +"%X" /* cursor pos */ return SET_CURSOR_POS; +"%c" /* cc */ return SHOW_CC; +"%d" /* date */ return SHOW_DATE; +"%D" /* date */ { BEGIN S_DATE; return SHOW_DATE_EXPR; } +"%f" /* from */ return SHOW_FROM; +"%F" /* first name */ return SHOW_FIRST_NAME; +"%i" /* message-id */ return SHOW_MESSAGEID; +"%I" /* initial of sender */ return SHOW_SENDER_INITIAL; +"%m" /* message with no signature */ return SHOW_MESSAGE_NO_SIGNATURE; +"%M" /* message */ return SHOW_MESSAGE; +"%n" /* newsgroups */ return SHOW_NEWSGROUPS; +"%N" /* full name */ return SHOW_FULLNAME; +"%L" /* last name */ return SHOW_LAST_NAME; +"%r" /* references */ return SHOW_REFERENCES; +"%s" /* subject */ return SHOW_SUBJECT; +"%t" /* to */ return SHOW_TO; +"%Q" /* quoted message */ return SHOW_QUOTED_MESSAGE; +"%q" /* quoted message with no signature */ return SHOW_QUOTED_MESSAGE_NO_SIGNATURE; +"\\\%" /* % */ return SHOW_PERCENT; "\\\\" /* \ */ return SHOW_BACKSLASH; -"\\t" /* tab */ return SHOW_TAB; -"\\n" /* retour à la ligne */ return SHOW_EOL; +"\\t"|"\t" /* tab */ return SHOW_TAB; +"\\n"|"\n" /* return */ return SHOW_EOL; "\\?" /* ? */ return SHOW_QUESTION_MARK; -"\\(" return SHOW_OPARENT; -"\\)" return SHOW_CPARENT; +"\\|" return SHOW_PIPE; +"\\{" return SHOW_OPARENT; +"\\}" return SHOW_CPARENT; "?d" /* query date */ return QUERY_DATE; "?f" /* query from */ return QUERY_FROM; "?N"|"?F"|"?I" /* query from name */ return QUERY_FULLNAME; @@ -37,8 +84,12 @@ "?n" /* query newsgroups */ return QUERY_NEWSGROUPS; "?i" /* query message-id */ return QUERY_MESSAGEID; "?r" /* query references */ return QUERY_REFERENCES; -"(" return OPARENT; -")" return CPARENT; +"|f" /* insert file */ return INSERT_FILE; +"|p" /* insert program output */ return INSERT_PROGRAMOUTPUT; +"{" return OPARENT; +"}" { BEGIN S_NORMAL; return CPARENT; } +"{" return OPARENT; +"}" return CPARENT; . { yylval.chr = yytext[0]; return CHARACTER; } %%