232 |
struct buffer_ctx *ctx; |
struct buffer_ctx *ctx; |
233 |
struct stat st; |
struct stat st; |
234 |
const char *filename; |
const char *filename; |
235 |
|
|
236 |
filename = mh_expand_name (NULL, name, 0); |
filename = mh_expand_name (NULL, name, 0); |
237 |
if (stat (filename, &st)) |
if (stat (filename, &st)) |
238 |
{ |
{ |
310 |
#ifndef FLEX_SCANNER |
#ifndef FLEX_SCANNER |
311 |
lex_delete_buffer (current_buffer); |
lex_delete_buffer (current_buffer); |
312 |
#endif |
#endif |
313 |
|
if (ali_filename) |
314 |
|
free (ali_filename); |
315 |
|
ali_filename = NULL; |
316 |
if (!context_stack) |
if (!context_stack) |
317 |
{ |
{ |
318 |
yyin = NULL; |
yyin = NULL; |
319 |
return 1; |
return 1; |
320 |
} |
} |
|
if (ali_filename) |
|
|
free (ali_filename); |
|
321 |
/* Restore previous context */ |
/* Restore previous context */ |
322 |
ali_filename = context_stack->filename; |
ali_filename = context_stack->filename; |
323 |
ali_line_num = context_stack->line + 1; /* < line did not increment it */ |
ali_line_num = context_stack->line + 1; /* < line did not increment it */ |
334 |
%} |
%} |
335 |
WS [ \t]+ |
WS [ \t]+ |
336 |
WORD [^ \t\n,:;<+=\*]+ |
WORD [^ \t\n,:;<+=\*]+ |
337 |
|
SPEC [,:;+=\*] |
338 |
|
%s VERBATIM |
339 |
%% |
%% |
340 |
\\\n { ali_line_num++; } |
\\\n { ali_line_num++; } |
341 |
\n { ali_line_num++; return '\n';} |
\n { ali_line_num++; return '\n';} |
342 |
^[ \t]*\;.*\n ali_line_num++; |
^[ \t]*\;.*\n ali_line_num++; |
343 |
^[ \t]*{WORD}\* { char *p; |
^[ \t]*{WORD}\* { char *p; |
344 |
for (p = yytext; p < yytext + yyleng; p++) |
for (p = yytext; p < yytext + yyleng; p++) |
345 |
if (!isspace (*p)) |
if (!isspace (*p)) |
346 |
break; |
break; |
347 |
yylval.string = strdup (p); |
yylval.string = strdup (p); |
348 |
return STRING;} |
return STRING;} |
349 |
{WS} ; |
{WS} ; |
350 |
{WORD} { yylval.string = strdup (yytext); return STRING;} |
{WORD} { yylval.string = strdup (yytext); return STRING;} |
351 |
^{WS}?"<"{WS}?{WORD} { char *p; |
^{WS}?"<"{WS}?{WORD} { |
352 |
|
char *p; |
353 |
for (p = yytext; p < yytext + yyleng && isblank(*p); p++) |
for (p = yytext; p < yytext + yyleng && isblank(*p); p++) |
354 |
; |
; |
355 |
for (p++; p < yytext + yyleng; p++) |
for (p++; p < yytext + yyleng; p++) |
356 |
if (!isspace (*p)) |
if (!isspace (*p)) |
357 |
break; |
break; |
358 |
push_source (p, 1); } |
push_source (p, 1); } |
359 |
"<"{WORD} { yylval.string = xmalloc (yyleng + 2); |
{SPEC} return yytext[0]; |
360 |
yylval.string[0] = '<'; |
<VERBATIM>[^ \t\n,:;+=\*][^\n,]* { |
361 |
memcpy(yylval.string, yytext, yyleng); |
yylval.string = xmalloc (yyleng + 1); |
362 |
yylval.string[yyleng+1] = 0; |
memcpy(yylval.string, yytext, yyleng); |
363 |
return STRING;} |
yylval.string[yyleng] = 0; |
364 |
=|\*|\+|,|:|\; return yytext[0]; |
return STRING;} |
365 |
. { char *p; |
. { char *p; |
366 |
asprintf (&p, |
asprintf (&p, |
367 |
_("Stray character %03o in alias file"), yytext[0]); |
_("Stray character %03o in alias file"), yytext[0]); |
375 |
return pop_source(); |
return pop_source(); |
376 |
} |
} |
377 |
|
|
|
|
|
378 |
/* Parses the named alias file */ |
/* Parses the named alias file */ |
379 |
int |
int |
380 |
mh_alias_read (char *name, int fail) |
mh_alias_read (char *name, int fail) |
381 |
{ |
{ |
382 |
extern int yydebug; |
extern int yydebug; |
383 |
|
char *p = getenv("ALI_YYDEBUG"); |
384 |
|
|
385 |
|
if (p && *p > '0' && *p < '9') |
386 |
|
yydebug = 1; |
387 |
|
|
388 |
if (push_source (name, fail)) |
if (push_source (name, fail)) |
389 |
return 1; |
return 1; |
390 |
|
if (yydebug) |
391 |
|
fprintf (stderr, "Starting parse of %s\n", name); |
392 |
return yyparse (); |
return yyparse (); |
393 |
} |
} |
394 |
|
|
395 |
|
void |
396 |
|
ali_verbatim (int enable) |
397 |
|
{ |
398 |
|
if (enable) |
399 |
|
BEGIN(VERBATIM); |
400 |
|
else |
401 |
|
BEGIN(INITIAL); |
402 |
|
} |
403 |
|
|