#include <config.h>
#include "getline.h"
-#include <assert.h>
+#include "error.h"
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#endif /* no readline/history.h */
#endif /* -lhistory */
+extern struct cmd_set cmd;
+
static struct string getl_include_path;
/* Number of levels of DO REPEAT structures we're nested inside. If
void
getl_initialize (void)
{
- ds_create (NULL, &getl_include_path,
+ ds_create (&getl_include_path,
fn_getenv_default ("STAT_INCLUDE_PATH", include_path));
- ds_init (NULL, &getl_buf, 256);
+ ds_init (&getl_buf, 256);
}
/* Close getline. */
void
getl_uninitialize (void)
{
-#if HAVE_LIBHISTORY && unix
+#if HAVE_LIBHISTORY && defined (unix)
if (history_file)
write_history (history_file);
#endif
getl_add_include_dir (const char *path)
{
if (ds_length (&getl_include_path))
- ds_putchar (&getl_include_path, PATH_DELIMITER);
+ ds_putc (&getl_include_path, PATH_DELIMITER);
- ds_concat (&getl_include_path, path);
+ ds_puts (&getl_include_path, path);
}
/* Adds FN to the tail end of the list of script files to execute.
{
char *cur_dir = getl_get_current_directory ();
- real_fn = fn_search_path (fn, ds_value (&getl_include_path), cur_dir);
+ real_fn = fn_search_path (fn, ds_c_str (&getl_include_path), cur_dir);
free (cur_dir);
}
welcome (void)
{
getl_welcomed = 1;
- fputs ("PSPP is free software and you are welcome to distribute copies of"
+ fputs ("PSPP is free software and you are welcome to distribute copies of "
"it\nunder certain conditions; type \"show copying.\" to see the "
"conditions.\nThere is ABSOLUTELY NO WARRANTY for PSPP; type \"show "
"warranty.\" for details.\n", stdout);
}
while (s->cur_line == NULL);
- ds_concat_buffer (&getl_buf, s->cur_line->line, s->cur_line->len);
+ ds_concat (&getl_buf, s->cur_line->line, s->cur_line->len);
/* Advance pointers. */
s->cur_line = s->cur_line->next;
perform_DO_REPEAT_substitutions ();
if (getl_head->print)
tab_output_text (TAB_LEFT | TAT_FIX | TAT_PRINTF, "+%s",
- ds_value (&getl_buf));
+ ds_c_str (&getl_buf));
return 1;
}
}
}
- if (!ds_getline (&getl_buf, s->f))
+ if (!ds_gets (&getl_buf, s->f))
{
if (ferror (s->f))
msg (ME, _("Reading `%s': %s."), s->fn, strerror (errno));
if (ds_length (&getl_buf) > 0 && ds_end (&getl_buf)[-1] == '\n')
ds_truncate (&getl_buf, ds_length (&getl_buf) - 1);
- if (set_echo)
- tab_output_text (TAB_LEFT | TAT_FIX, ds_value (&getl_buf));
+ 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_value (&getl_buf)[0] == '#'
- && ds_value (&getl_buf)[1] == '!')
+ if (ds_c_str (&getl_buf)[0] == '#'
+ && ds_c_str (&getl_buf)[1] == '!')
continue;
return 1;
#if HAVE_LIBHISTORY
if (!history_file)
{
-#if unix
+#ifdef unix
history_file = tilde_expand (HISTORY_FILE);
#endif
using_history ();
switch (getl_prompt)
{
case GETL_PRPT_STANDARD:
- prompt = set_prompt;
+ prompt = get_prompt();
break;
case GETL_PRPT_CONTINUATION:
- prompt = set_cprompt;
+ prompt = get_cprompt();
break;
case GETL_PRPT_DATA:
- prompt = set_dprompt;
+ prompt = get_dprompt();
break;
default:
assert (0);
+ abort ();
}
line = readline (prompt);
#endif
ds_clear (&getl_buf);
- ds_concat (&getl_buf, line);
+ ds_puts (&getl_buf, line);
return 1;
}
err_error_count = err_warning_count = 0;
err_already_flagged = 0;
- fputs (getl_prompt ? set_cprompt : set_prompt, stdout);
+ fputs (getl_prompt ? get_cprompt() : get_prompt(), stdout);
ds_clear (&getl_buf);
- if (ds_getline (&getl_buf, stdin))
+ if (ds_gets (&getl_buf, stdin))
return 1;
if (ferror (stdin))