- if (settings.scriptfp == NULL || feof(settings.scriptfp)) {
- if (settings.optind >= settings.argc) {
- free(buf);
- return NULL;
- }
-
- char *next = settings.argv[settings.optind++];
-
- if (settings.scriptfp != NULL && feof(settings.scriptfp))
- fclose(settings.scriptfp);
- if (strcmp(next, "-") == 0)
- settings.scriptfp = stdin; // LCOV_EXCL_LINE
- else
- settings.scriptfp = fopen(next, "r");
- }
-
- if (isatty(fileno(settings.scriptfp))) {
- free(buf); // LCOV_EXCL_LINE
- return readline(prompt); // LCOV_EXCL_LINE
- } else {
- char *ln = fgets(buf, BUFSIZ-1, settings.scriptfp);
- if (ln != NULL) {
- fputs(PROMPT, stdout);
- fputs(ln, stdout);
- return ln;
- }
- }
+ if (settings.scriptfp == NULL || feof(settings.scriptfp)) {
+ if (settings.optind >= settings.argc) {
+ free(buf);
+ return NULL;
+ }
+
+ char *next = settings.argv[settings.optind++];
+
+ if (settings.scriptfp != NULL && feof(settings.scriptfp))
+ fclose(settings.scriptfp);
+ if (strcmp(next, "-") == 0)
+ settings.scriptfp = stdin; // LCOV_EXCL_LINE
+ else
+ settings.scriptfp = fopen(next, "r");
+ }
+
+ if (isatty(fileno(settings.scriptfp))) {
+ free(buf); // LCOV_EXCL_LINE
+ return readline(prompt); // LCOV_EXCL_LINE
+ } else {
+ char *ln = fgets(buf, LINESIZE, settings.scriptfp);
+ if (ln != NULL) {
+ fputs(PROMPT, stdout);
+ fputs(ln, stdout);
+ return ln;
+ }
+ }