aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/main.c b/src/main.c
index c301fdf..d4af50c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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);
}