projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
moved knowledge of pspp_linreg_cache out of pspp_coeff_init
[pspp]
/
src
/
language
/
line-buffer.c
diff --git
a/src/language/line-buffer.c
b/src/language/line-buffer.c
index 0803f0825ed712e2be08b27f19263adc28fb0d9c..146ca00a92847e93d5179a85a8180fa53f1946c2 100644
(file)
--- a/
src/language/line-buffer.c
+++ b/
src/language/line-buffer.c
@@
-18,21
+18,26
@@
02110-1301, USA. */
#include <config.h>
02110-1301, USA. */
#include <config.h>
+
#include <language/line-buffer.h>
#include <language/line-buffer.h>
-#include <libpspp/message.h>
+
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
-#include <libpspp/alloc.h>
+
+#include <data/file-name.h>
+#include <data/settings.h>
+#include <data/variable.h>
#include <language/command.h>
#include <language/command.h>
-#include <libpspp/message.h>
-#include <data/filename.h>
#include <language/lexer/lexer.h>
#include <language/lexer/lexer.h>
-#include <data/settings.h>
+#include <libpspp/alloc.h>
+#include <libpspp/assertion.h>
+#include <libpspp/message.h>
+#include <libpspp/message.h>
#include <libpspp/str.h>
#include <libpspp/str.h>
-#include <output/table.h>
-#include <data/variable.h>
+#include <libpspp/verbose-msg.h>
#include <libpspp/version.h>
#include <libpspp/version.h>
+#include <output/table.h>
#include "gettext.h"
#define _(msgid) gettext (msgid)
#include "gettext.h"
#define _(msgid) gettext (msgid)
@@
-45,7
+50,7
@@
struct getl_source
struct getl_source *next; /* Next file in list. */
/* Current location. */
struct getl_source *next; /* Next file in list. */
/* Current location. */
- char *fn; /* Filename. */
+ char *fn; /* File
name. */
int ln; /* Line number. */
enum getl_source_type
int ln; /* Line number. */
enum getl_source_type
@@
-81,7
+86,7
@@
struct getl_source
function;
/* INTERACTIVE. */
function;
/* INTERACTIVE. */
- bool (*interactive) (struct string *line,
const char *prompt
);
+ bool (*interactive) (struct string *line,
enum getl_prompt_style
);
}
u;
}
u;
@@
-99,15
+104,15
@@
static void close_source (void);
static void init_prompts (void);
static void uninit_prompts (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)
{
/* 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 ();
}
init_prompts ();
}
@@
-123,9
+128,9
@@
void
getl_add_include_dir (const char *path)
{
if (ds_length (&getl_include_path))
getl_add_include_dir (const char *path)
{
if (ds_length (&getl_include_path))
- ds_put
c (&getl_include_path, PATH_DELIMITER
);
+ ds_put
_char (&getl_include_path, ':'
);
- ds_put
s
(&getl_include_path, path);
+ ds_put
_cstr
(&getl_include_path, path);
}
/* Appends source S to the list of source files. */
}
/* Appends source S to the list of source files. */
@@
-210,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,
/* 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;
{
struct getl_source *s = xmalloc (sizeof *s);
s->fn = NULL;
@@
-228,15
+233,15
@@
getl_append_syntax_file (const char *fn)
append_source (create_syntax_file_source (fn));
}
append_source (create_syntax_file_source (fn));
}
-/* Inserts the given file with
filename FN into the current file after
- the current line. */
+/* Inserts the given file with
name FN into the current file
+
after
the current line. */
void
getl_include_syntax_file (const char *fn)
{
if (cur_source != NULL)
{
void
getl_include_syntax_file (const char *fn)
{
if (cur_source != NULL)
{
- char *found_fn = fn_search_path (fn, ds_c
_
str (&getl_include_path),
- fn_dirname (cur_source->fn));
+ char *found_fn = fn_search_path (fn, ds_cstr (&getl_include_path),
+ fn_dir
_
name (cur_source->fn));
if (found_fn != NULL)
{
include_source (create_syntax_file_source (found_fn));
if (found_fn != NULL)
{
include_source (create_syntax_file_source (found_fn));
@@
-293,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,
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));
}
{
append_source (create_interactive_source (function));
}
@@
-372,7
+377,8
@@
getl_location (const char **fn, int *ln)
}
/* File locator stack. */
}
/* File locator stack. */
-static const struct file_locator **file_loc;
+static const struct msg_locator **file_loc;
+
static int nfile_loc, mfile_loc;
\f
/* Close getl. */
static int nfile_loc, mfile_loc;
\f
/* Close getl. */
@@
-394,7
+400,7
@@
getl_uninitialize (void)
/* Pushes F onto the stack of file locations. */
void
/* Pushes F onto the stack of file locations. */
void
-
err_push_file_locator (const struct file_locator *f
)
+
msg_push_msg_locator (const struct msg_locator *loc
)
{
if (nfile_loc >= mfile_loc)
{
{
if (nfile_loc >= mfile_loc)
{
@@
-406,28
+412,28
@@
err_push_file_locator (const struct file_locator *f)
file_loc = xnrealloc (file_loc, mfile_loc, sizeof *file_loc);
}
file_loc = xnrealloc (file_loc, mfile_loc, sizeof *file_loc);
}
- file_loc[nfile_loc++] =
f
;
+ file_loc[nfile_loc++] =
loc
;
}
/* Pops F off the stack of file locations.
Argument F is only used for verification that that is actually the
item on top of the stack. */
void
}
/* Pops F off the stack of file locations.
Argument F is only used for verification that that is actually the
item on top of the stack. */
void
-
err_pop_file_locator (const struct file_locator *f
)
+
msg_pop_msg_locator (const struct msg_locator *loc
)
{
{
- assert (nfile_loc >= 0 && file_loc[nfile_loc - 1] ==
f
);
+ assert (nfile_loc >= 0 && file_loc[nfile_loc - 1] ==
loc
);
nfile_loc--;
}
nfile_loc--;
}
-/* Puts the current file and line number in
F
, or NULL and -1 if
+/* Puts the current file and line number in
to LOC
, or NULL and -1 if
none. */
void
none. */
void
-
err_location (struct file_locator *f
)
+
get_msg_location (struct msg_locator *loc
)
{
if (nfile_loc)
{
if (nfile_loc)
- *
f
= *file_loc[nfile_loc - 1];
+ *
loc
= *file_loc[nfile_loc - 1];
else
else
- getl_location (&
f->filename, &f
->line_number);
+ getl_location (&
loc->file_name, &loc
->line_number);
}
/* Reads a line from syntax file source S into LINE.
}
/* Reads a line from syntax file source S into LINE.
@@
-438,7
+444,7
@@
read_syntax_file (struct string *line, struct getl_source *s)
/* Open file, if not yet opened. */
if (s->u.syntax_file == NULL)
{
/* Open file, if not yet opened. */
if (s->u.syntax_file == NULL)
{
-
msg (VM (1), _("%s: Opening as syntax file.
"), s->fn);
+
verbose_msg (1, _("opening \"%s\" as syntax file
"), s->fn);
s->u.syntax_file = fn_open (s->fn, "r");
if (s->u.syntax_file == NULL)
s->u.syntax_file = fn_open (s->fn, "r");
if (s->u.syntax_file == NULL)
@@
-453,7
+459,7
@@
read_syntax_file (struct string *line, struct getl_source *s)
do
{
s->ln++;
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));
{
if (ferror (s->u.syntax_file))
msg (ME, _("Reading `%s': %s."), s->fn, strerror (errno));
@@
-461,11
+467,11
@@
read_syntax_file (struct string *line, struct getl_source *s)
}
ds_chomp (line, '\n');
}
}
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 ())
/* Echo to listing file, if configured to do so. */
if (get_echo ())
- tab_output_text (TAB_LEFT | TA
T_FIX, ds_c_
str (line));
+ tab_output_text (TAB_LEFT | TA
B_FIX, ds_c
str (line));
return true;
}
return true;
}
@@
-485,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:
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.
}
/* Reads a single line into LINE.
@@
-585,8
+591,8
@@
getl_set_prompt_style (enum getl_prompt_style style)
}
/* Returns the current prompt. */
}
/* 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
;
}
}