diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-09-12 18:43:19 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-09-12 18:43:19 +0200 |
commit | 14eb9b46326f70d6c14ee82614b8107941b04dbe (patch) | |
tree | abdc993c5979d52c2cdae86fd2e2a93b4745b502 /src | |
parent | 63ef5c4f6ed5997be1135189f6bb5872daafa93a (diff) |
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); } |