+2007-07-25 Ben Pfaff <blp@gnu.org>
+
+ * devices: Add an "interactive" category that defaults to
+ tty-ascii. Make the tty-ascii device more user-friendly.
+
Tue Apr 4 20:20:49 2006 Ben Pfaff <blp@gnu.org>
* automake.mk: Fix bugs in installation targets.
# referenced with $var or ${var} syntax; the latter is preferred.
# Preferred devices.
-default=tty list
-tty=#tty-ibmpc
-list=list-ascii
+default=list-ascii
+interactive=tty-ascii
# Output files.
-define tty-output-file "/dev/tty"
+define tty-output-file "|more"
define list-output-file "pspp.list"
# Generic ASCII devices
-tty-ascii:ascii:screen:output-file=${tty-output-file}
+tty-ascii:ascii:screen:squeeze=on headers=off top-margin=0 bottom-margin=0 \
+ paginate=off length=${viewlength} width=${viewwidth} \
+ output-file=${tty-output-file}
list-ascii:ascii:listing:length=66 width=79 output-file=${list-output-file}
raw-ascii:ascii:screen:width=9999 length=9999 output-file=${list-output-file} \
emphasis=none headers=off paginate=off squeeze=on \
+2007-07-25 Ben Pfaff <blp@gnu.org>
+
+ Fix bugs related to bug #17213.
+
+ * settings.c: Use HAVE_LIBNCURSES instead of HAVE_LIBTERMCAP,
+ since the former is what config.h has. Include the needed ncurses
+ headers.
+ (static var echo) Rename to `do_echo' because the original name is
+ the same as an ncurses identifier.
+ (get_termcap_viewport) Use error instead of msg.
+
+ * file-name.c (fn_interp_vars): Fix interpolation of $VARS.
+ (fn_close): Don't close stdin, stdout, stderr.
+
2007-07-26 John Darrington <john@darrington.wattle.id.au>
* procedure.c procedure.h: Added callbacks which get invoked whenever
else if (ss_match_char (&src, '{'))
ss_get_until (&src, '}', &var_name);
else
- ss_get_chars (&src, MIN (1, ss_span (src, ss_cstr (CC_ALNUM))),
+ ss_get_chars (&src, MAX (1, ss_span (src, ss_cstr (CC_ALNUM))),
&var_name);
start = ds_length (&dst);
int
fn_close (const char *fn, FILE *f)
{
- if (!strcmp (fn, "-"))
+ if (fileno (f) == STDIN_FILENO
+ || fileno (f) == STDOUT_FILENO
+ || fileno (f) == STDERR_FILENO)
return 0;
#if HAVE_POPEN
else if (fn[0] == '|' || (*fn && fn[strlen (fn) - 1] == '|'))
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 2007 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "xalloc.h"
#include <libpspp/i18n.h>
+#include "error.h"
+
+#ifdef HAVE_LIBNCURSES
+#include <curses.h>
+#include <term.h>
+#endif
+
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
static int viewlength = 24;
static int viewwidth = 79;
static bool long_view = false;
static bool safer_mode = false;
-static bool echo = false;
+static bool do_echo = false;
static bool include = true;
static int epoch = -1;
viewwidth = viewwidth_;
}
-#if HAVE_LIBTERMCAP
+#if HAVE_LIBNCURSES
static void
get_termcap_viewport (void)
{
return;
else if (tgetent (term_buffer, getenv ("TERM")) <= 0)
{
- msg (IE, _("Could not access definition for terminal `%s'."), termtype);
+ error (0,0, _("could not access definition for terminal `%s'"),
+ getenv ("TERM"));
return;
}
if (tgetnum ("co") > 1)
viewwidth = tgetnum ("co") - 1;
}
-#endif /* HAVE_LIBTERMCAP */
+#endif /* HAVE_LIBNCURSES */
static void
init_viewport (void)
viewwidth = viewlength = -1;
-#if HAVE_LIBTERMCAP
+#if HAVE_LIBNCURSES
get_termcap_viewport ();
-#endif /* HAVE_LIBTERMCAP */
+#endif /* HAVE_LIBNCURSES */
if (viewwidth < 0 && getenv ("COLUMNS") != NULL)
viewwidth = atoi (getenv ("COLUMNS"));
bool
get_echo (void)
{
- return echo;
+ return do_echo;
}
/* Set echo. */
void
set_echo (bool echo_)
{
- echo = echo_;
+ do_echo = echo_;
}
/* If echo is on, whether commands from include files are echoed. */
+2007-07-25 Ben Pfaff <blp@gnu.org>
+
+ * getl.c (getl_append_source): Add source to *end* of list.
+ Otherwise the list ends up in reverse order.
+
+ * automake.mk (src/libpspp/version.c): Use $HOME instead of ~ in
+ paths. We don't interpolate ~.
+
2007-07-22 Ben Pfaff <blp@gnu.org>
* str.h: Include xstrndup.h also.
echo "const char host_system[] = \"$(host_triplet)\";" >> $@
echo "const char build_system[] = \"$(build_triplet)\";" >> $@
echo "const char default_config_path[] =\
-\"~/.pspp:$(pkgsysconfdir)\";" >> $@
+\"\$$HOME/.pspp:$(pkgsysconfdir)\";" >> $@
echo "const char include_path[] =\
-\"./:~/.pspp/include:$(pkgdatadir)\";" >> $@
+\"./:\$$HOME/.pspp/include:$(pkgdatadir)\";" >> $@
echo "const char locale_dir[] = \"$(datadir)/locale\";" >> $@
echo "const char *const authors[] = {" >> $@
sed -e 's/^/ \"/' -e 's/$$/\",/' $(top_srcdir)/AUTHORS >> $@
s->interface = i ;
- ll_push_head (&ss->sources, &s->ll);
+ ll_push_tail (&ss->sources, &s->ll);
}
/* Nests source S within the current source file. */
+2007-07-25 Ben Pfaff <blp@gnu.org>
+
+ Make interactive output go to the terminal (bug #17213), by
+ causing the UI to flush output to the user when it prompts for a
+ command.
+
+ * ascii.c (ascii_open_driver): Move the file open into
+ ascii_open_page, so that we can re-open after a flush.
+ (ascii_close_driver): Close file using ascii_flush.
+ (ascii_open_page): Open the output file if it's not already open.
+ Use fn_open so that we can support pipes.
+ (ascii_close_page): Do nothing if output file not open.
+ (ascii_flush): New function.
+ (static var ascii_class): Add ascii_flush.
+
+ * manager.c (som_flush): New function.
+
+ * output.c (outp_flush): New function.
+
Tue Feb 20 07:03:48 2007 Ben Pfaff <blp@gnu.org>
* html.c: Don't need to include "getlogin_r.h" anymore, because
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2007 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
int line_cap; /* Number of lines allocated. */
};
+static void ascii_flush (struct outp_driver *);
static int get_default_box_char (size_t idx);
static bool handle_option (struct outp_driver *this, const char *key,
const struct string *val);
if (!outp_parse_options (options, handle_option, this))
goto error;
- x->file = pool_fopen (x->pool, x->file_name, "w");
- if (x->file == NULL)
- {
- error (0, errno, _("ascii: opening output file \"%s\""), x->file_name);
- goto error;
- }
-
this->length = x->page_length - x->top_margin - x->bottom_margin - 1;
if (x->headers)
this->length -= 3;
{
struct ascii_driver_ext *x = this->ext;
- if (fn_close (x->file_name, x->file) != 0)
- error (0, errno, _("ascii: closing output file \"%s\""), x->file_name);
+ ascii_flush (this);
pool_detach_file (x->pool, x->file);
pool_destroy (x->pool);
struct ascii_driver_ext *x = this->ext;
int i;
+ if (x->file == NULL)
+ {
+ x->file = fn_open (x->file_name, "w");
+ if (x->file == NULL)
+ {
+ error (0, errno, _("ascii: opening output file \"%s\""),
+ x->file_name);
+ return;
+ }
+ pool_attach_file (x->pool, x->file);
+ }
+
x->page_number++;
if (this->length > x->line_cap)
struct string out;
int line_num;
+ if (x->file == NULL)
+ return;
+
ds_init_empty (&out);
ds_put_char_multiple (&out, '\n', x->top_margin);
ds_destroy (&out);
}
+/* Flushes all output to the user and lets the user deal with it.
+ This is applied only to output drivers that are designated as
+ "screen" drivers that the user is interacting with in real
+ time. */
+static void
+ascii_flush (struct outp_driver *this)
+{
+ struct ascii_driver_ext *x = this->ext;
+
+ if (x->file != NULL)
+ {
+ if (fn_close (x->file_name, x->file) != 0)
+ error (0, errno, _("ascii: closing output file \"%s\""),
+ x->file_name);
+ pool_detach_file (x->pool, x->file);
+ x->file = NULL;
+ }
+}
+
static void
ascii_chart_initialise (struct outp_driver *d UNUSED, struct chart *ch)
{
ascii_open_page,
ascii_close_page,
+ ascii_flush,
NULL,
html_open_driver,
html_close_driver,
+ NULL,
NULL,
NULL,
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2007 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
outp_eject_page (d);
}
+/* Flushes output on all active devices. */
+void
+som_flush (void)
+{
+ struct outp_driver *d;
+
+ for (d = outp_drivers (NULL); d; d = outp_drivers (d))
+ outp_flush (d);
+}
+
/* Skip down a single line on all active devices. */
void
som_blank_line (void)
/* Miscellaneous. */
void som_eject_page (void);
void som_blank_line (void);
+void som_flush (void);
#endif /* som_h */
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2007 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
outp_configure_vec = n;
}
-/* Checks that outp_configure_vec is empty, bitches & clears it if it
- isn't. */
+/* Checks that outp_configure_vec is empty, complains and clears
+ it if it isn't. */
static void
check_configure_vec (void)
{
d->class = c->class;
d->name = ss_xstrdup (driver_name);
d->page_open = false;
- d->device = OUTP_DEV_NONE;
+ d->device = device;
d->cp_x = d->cp_y = 0;
d->ext = NULL;
d->prc = NULL;
outp_open_page (d);
}
+/* Flushes output to screen devices, so that the user can see
+ output that doesn't fill up an entire page. */
+void
+outp_flush (struct outp_driver *d)
+{
+ if (d->device & OUTP_DEV_SCREEN && d->class->flush != NULL)
+ {
+ outp_close_page (d);
+ d->class->flush (d);
+ }
+}
+
/* Returns the width of string S, in device units, when output on
device D. */
int
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2007 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
void (*open_page) (struct outp_driver *);
void (*close_page) (struct outp_driver *);
+ void (*flush) (struct outp_driver *);
+
/* special != 0 only. */
void (*submit) (struct outp_driver *, struct som_entity *);
void outp_open_page (struct outp_driver *);
void outp_close_page (struct outp_driver *);
void outp_eject_page (struct outp_driver *);
+void outp_flush (struct outp_driver *);
int outp_string_width (struct outp_driver *, const char *, enum outp_font);
ps_open_page,
ps_close_page,
+ NULL,
ps_submit,
+2007-07-25 Ben Pfaff <blp@gnu.org>
+
+ Make interactive output go to the terminal (bug #17213), by
+ causing the UI to flush output to the user when it prompts for a
+ command.
+
+ * command-line.c (parse_command_line): Configure interactive
+ output devices if appropriate.
+
+ * read-line.c (readln_read): Flush output if this is a prompt for
+ the first line of a command.
+
2007-06-06 Ben Pfaff <blp@gnu.org>
Adapt case sources, sinks, and clients of procedure code to the
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2007 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
-void welcome (void);
static void usage (void);
-char *subst_vars (char *);
-
-
/* Parses the command line specified by ARGC and ARGV as received by
main(). Returns true if normal execution should proceed,
false if the command-line indicates that PSPP should exit. */
}
if (!syntax_files || interactive_mode)
- getl_append_source (ss, create_readln_source () );
+ {
+ getl_append_source (ss, create_readln_source () );
+ if (!cleared_device_defaults)
+ outp_configure_add ("interactive");
+ }
return true;
}
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2007 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <libpspp/str.h>
#include <libpspp/version.h>
#include <language/prompt.h>
+#include <output/manager.h>
#include "xalloc.h"
welcome ();
+ if (style == PROMPT_FIRST)
+ som_flush ();
+
#if HAVE_READLINE
rl_attempted_completion_function = (style == PROMPT_FIRST
? complete_command_name