segment s2 = {"toto", 4 };
segment s3 = {"titi", 4 };
segment s4 = {"\"", 1 };
+ segment s5 = {"index_format", 12 };
mutt_endwin(NULL);
rcparse(parser, RCTK_SPACE, s1, &state);
rcparse(parser, RCTK_ATOM, s3, &state);
rcparse(parser, RCTK_DQUOTE, s4, &state);
+ rcparse(parser, RCTK_SPACE, s1, &state);
+ rcparse(parser, RCTK_DOLLAR, s1, &state);
+ rcparse(parser, RCTK_ATOM, s5, &state);
rcparse(parser, RCTK_NL, s1, &state);
rcparse(parser, 0, s1, &state);
buffer_add(buf, s, len);
return buf;
}
+
+ static void substvar(buffer_t *buf, const segment seg) {
+ const char *res;
+ char tmp[STRING];
+ char var[STRING];
+
+ if (m_strncpy(var, sizeof(var), seg.s, seg.len) <= 0)
+ return;
+
+ if ((res = getenv(var))) {
+ buffer_addstr(buf, res);
+ return;
+ }
+ if (mutt_option_value(var, tmp, sizeof(tmp))) {
+ buffer_addstr(buf, tmp);
+ }
+ }
}
%name rcparse
/* Our macro tokens */
/****************************************************************************/
+%type svar { segment }
+svar(Z) ::= DOLLAR ATOM(B) . { Z = B; }
+svar(Z) ::= DOLLAR LBRACE ATOM(B) RBRACE . { Z = B; }
+
/* '-quoted tokens */
%type sqtok { buffer_t* }
%destructor sqtok { buffer_delete(&$$); }
dqtok(Z) ::= dqtok(A) ATOM|SPACE|SHARP|EQUAL|LBRACE|RBRACE(B) . {
buffer_add(Z = A, B.s, B.len);
}
-dqtok(Z) ::= dqtok(A) DOLLAR ATOM(B) . {
- // FIXME
- B = B;
- Z = A;
-}
-dqtok(Z) ::= dqtok(A) DOLLAR LBRACE ATOM(B) RBRACE . {
- // FIXME
- B = B;
- Z = A;
-}
+dqtok(Z) ::= dqtok(A) svar(B) . { substvar(Z = A, B); }
/* unquoted tokens */
%type uqtok { buffer_t* }
uqtok(Z) ::= BSLASH non_nl(A) . { buffer_add(Z = buffer_new(), A.s, A.len); }
uqtok(Z) ::= QUOTE sqtok(A) QUOTE . { Z = A; }
uqtok(Z) ::= DQUOTE dqtok(A) DQUOTE . { Z = A; }
+uqtok(Z) ::= svar(B) . { substvar(Z = buffer_new(), B); }
/* token accumulator */
%type token { buffer_t* }
rclines ::= rclines rcline .
rcline ::= ALTERNATIVE_ORDER simple_list(L) to_eol . {
+ string_list_t *l;
string_list_append(&AlternativeOrderList, string_list_rev(L));
+ printf("toto\n");
+ for (l = AlternativeOrderList; l; l = l->next) {
+ printf("%s\n", l->data);
+ }
}
rcline ::= AUTO_VIEW simple_list(L) to_eol . {
string_list_append(&AutoViewList, string_list_rev(L));