diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 25 |
1 files changed, 13 insertions, 12 deletions
@@ -138,17 +138,18 @@ usage: interactive = sflag == NULL && argc == 0 && isatty(STDIN_FILENO); if (argc == 0) { - if (sflag != NULL && - (yyin = fmemopen((char *)sflag, strlen(sflag), "r")) == NULL) - { - err(1, "fmemopen"); - } - - current_file = "-"; - for (;;) { - if (yyparse() == 0) - break; - rv = EXIT_FAILURE; + if (sflag == NULL) { + current_file = "-"; + for (;;) { + if (yyparse() == 0) + break; + rv = EXIT_FAILURE; + } + } else { + current_file = "-s"; + YY_BUFFER_STATE buf = yy_scan_string(sflag); + (void)yyparse(); + yy_delete_buffer(buf); } } else for (int i = 0; i < argc; i++) { if (streq(argv[i], "-")) @@ -160,7 +161,7 @@ usage: } current_file = argv[i]; - yyparse(); + (void)yyparse(); fclose(yyin); } |