X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fline-buffer.c;h=146ca00a92847e93d5179a85a8180fa53f1946c2;hb=138216a0d401770c367d8f515ac06c98e5dfb528;hp=e451532082b06a9f88ac10ed8fcf0cf6ed289892;hpb=9f1d9ea8ac4f5e35a773581cf3d5ebd9e219bff8;p=pspp diff --git a/src/language/line-buffer.c b/src/language/line-buffer.c index e451532082..146ca00a92 100644 --- a/src/language/line-buffer.c +++ b/src/language/line-buffer.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -85,7 +86,7 @@ struct getl_source function; /* INTERACTIVE. */ - bool (*interactive) (struct string *line, const char *prompt); + bool (*interactive) (struct string *line, enum getl_prompt_style); } u; @@ -103,15 +104,15 @@ static void close_source (void); static void init_prompts (void); static void uninit_prompts (void); -static const char *get_prompt (void); +static enum getl_prompt_style get_prompt_style (void); /* Initialize getl. */ void getl_initialize (void) { - ds_create (&getl_include_path, - fn_getenv_default ("STAT_INCLUDE_PATH", include_path)); - ds_init (&getl_buf, 256); + ds_init_cstr (&getl_include_path, + fn_getenv_default ("STAT_INCLUDE_PATH", include_path)); + ds_init_empty (&getl_buf); init_prompts (); } @@ -127,9 +128,9 @@ void getl_add_include_dir (const char *path) { if (ds_length (&getl_include_path)) - ds_putc (&getl_include_path, ':'); + ds_put_char (&getl_include_path, ':'); - ds_puts (&getl_include_path, path); + ds_put_cstr (&getl_include_path, path); } /* Appends source S to the list of source files. */ @@ -214,7 +215,7 @@ create_function_source (bool (*read) (struct string *line, /* Creates an interactive source with the given FUNCTION. */ static struct getl_source * create_interactive_source (bool (*function) (struct string *line, - const char *prompt)) + enum getl_prompt_style)) { struct getl_source *s = xmalloc (sizeof *s); s->fn = NULL; @@ -239,7 +240,7 @@ getl_include_syntax_file (const char *fn) { if (cur_source != NULL) { - char *found_fn = fn_search_path (fn, ds_c_str (&getl_include_path), + char *found_fn = fn_search_path (fn, ds_cstr (&getl_include_path), fn_dir_name (cur_source->fn)); if (found_fn != NULL) { @@ -297,7 +298,7 @@ getl_include_function (bool (*read) (struct string *line, obtained or false at end of file. */ void getl_append_interactive (bool (*function) (struct string *line, - const char *prompt)) + enum getl_prompt_style)) { append_source (create_interactive_source (function)); } @@ -377,6 +378,7 @@ getl_location (const char **fn, int *ln) /* File locator stack. */ static const struct msg_locator **file_loc; + static int nfile_loc, mfile_loc; /* Close getl. */ @@ -423,10 +425,10 @@ msg_pop_msg_locator (const struct msg_locator *loc) nfile_loc--; } -/* Puts the current file and line number in F, or NULL and -1 if +/* Puts the current file and line number into LOC, or NULL and -1 if none. */ void -msg_location (struct msg_locator *loc) +get_msg_location (struct msg_locator *loc) { if (nfile_loc) *loc = *file_loc[nfile_loc - 1]; @@ -457,7 +459,7 @@ read_syntax_file (struct string *line, struct getl_source *s) do { s->ln++; - if (!ds_gets (line, s->u.syntax_file)) + if (!ds_read_line (line, s->u.syntax_file)) { if (ferror (s->u.syntax_file)) msg (ME, _("Reading `%s': %s."), s->fn, strerror (errno)); @@ -465,11 +467,11 @@ read_syntax_file (struct string *line, struct getl_source *s) } ds_chomp (line, '\n'); } - while (s->ln == 1 && !memcmp (ds_c_str (line), "#!", 2)); + while (s->ln == 1 && !memcmp (ds_cstr (line), "#!", 2)); /* Echo to listing file, if configured to do so. */ if (get_echo ()) - tab_output_text (TAB_LEFT | TAB_FIX, ds_c_str (line)); + tab_output_text (TAB_LEFT | TAB_FIX, ds_cstr (line)); return true; } @@ -489,10 +491,10 @@ read_line_from_source (struct string *line, struct getl_source *s) case FUNCTION: return s->u.function.read (line, &s->fn, &s->ln, s->u.function.aux); case INTERACTIVE: - return s->u.interactive (line, get_prompt ()); + return s->u.interactive (line, get_prompt_style ()); } - abort (); + NOT_REACHED (); } /* Reads a single line into LINE. @@ -589,8 +591,8 @@ getl_set_prompt_style (enum getl_prompt_style style) } /* Returns the current prompt. */ -static const char * -get_prompt (void) +static enum getl_prompt_style +get_prompt_style (void) { - return prompts[current_style]; + return current_style; }