-/* Reads a single line into getl_buf from the list of files. Will not
- read from the eof of one file to the beginning of another unless
- the options field on the new file's getl_script is nonzero. Return
- zero on eof. */
-int
-getl_read_line (void)
-{
- getl_mode = GETL_MODE_BATCH;
-
- while (getl_head)
- {
- struct getl_script *s = getl_head;
-
- ds_clear (&getl_buf);
- if (s->separate)
- return 0;
-
- if (s->first_line)
- {
- if (!handle_line_buffer ())
- {
- getl_close_file ();
- continue;
- }
- perform_DO_REPEAT_substitutions ();
- if (getl_head->print)
- tab_output_text (TAB_LEFT | TAT_FIX | TAT_PRINTF, "+%s",
- ds_c_str (&getl_buf));
- return 1;
- }
-
- if (s->f == NULL)
- {
- msg (VM (1), _("%s: Opening as syntax file."), s->fn);
- s->f = fn_open (s->fn, "r");
-
- if (s->f == NULL)
- {
- msg (ME, _("Opening `%s': %s."), s->fn, strerror (errno));
- getl_close_file ();
- continue;
- }
- }
-
- if (!ds_gets (&getl_buf, s->f))
- {
- if (ferror (s->f))
- msg (ME, _("Reading `%s': %s."), s->fn, strerror (errno));
- getl_close_file ();
- continue;
- }
- if (ds_length (&getl_buf) > 0 && ds_end (&getl_buf)[-1] == '\n')
- ds_truncate (&getl_buf, ds_length (&getl_buf) - 1);
-
- if (get_echo())
- tab_output_text (TAB_LEFT | TAT_FIX, ds_c_str (&getl_buf));
-
- getl_head->ln++;
-
- /* Allows shebang invocation: `#! /usr/local/bin/pspp'. */
- if (ds_c_str (&getl_buf)[0] == '#'
- && ds_c_str (&getl_buf)[1] == '!')
- continue;
-
- return 1;
- }
-
- if (getl_interactive == 0)
- return 0;
-
- getl_mode = GETL_MODE_INTERACTIVE;
-
- if (getl_welcomed == 0)
- welcome ();
-
- return read_console ();
-}
-