[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pspp-cvs] pspp doc/utilities.texi src/language/lexer/Chan...
From: |
Ben Pfaff |
Subject: |
[Pspp-cvs] pspp doc/utilities.texi src/language/lexer/Chan... |
Date: |
Fri, 24 Aug 2007 05:00:51 +0000 |
CVSROOT: /cvsroot/pspp
Module name: pspp
Changes by: Ben Pfaff <blp> 07/08/24 05:00:51
Modified files:
doc : utilities.texi
src/language/lexer: ChangeLog lexer.c
src/language/utilities: ChangeLog set.q
src/output : ChangeLog automake.mk
src/ui/terminal: ChangeLog msg-ui.c read-line.c
Added files:
src/output : journal.c journal.h
Log message:
Implement journaling. Bug #17240.
* msg-ui.c (handle_msg): Send message to write_journal function
as well as msg_file.
(dump_message): Change interface so that it takes a function
pointer instead of a FILE.
(write_stream): New function.
(write_journal): New function.
* read-line.c (welcome): Call journal_enable, so that the journal
is enabled by default.
* automake.mk (output_sources): Add journal.c, journal.h.
* journal.c: New file.
* journal.h: New file.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/doc/utilities.texi?cvsroot=pspp&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/lexer/ChangeLog?cvsroot=pspp&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/lexer/lexer.c?cvsroot=pspp&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/utilities/ChangeLog?cvsroot=pspp&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/utilities/set.q?cvsroot=pspp&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/pspp/src/output/ChangeLog?cvsroot=pspp&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/pspp/src/output/automake.mk?cvsroot=pspp&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/pspp/src/output/journal.c?cvsroot=pspp&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/pspp/src/output/journal.h?cvsroot=pspp&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/terminal/ChangeLog?cvsroot=pspp&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/terminal/msg-ui.c?cvsroot=pspp&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/terminal/read-line.c?cvsroot=pspp&r1=1.16&r2=1.17
Patches:
Index: doc/utilities.texi
===================================================================
RCS file: /cvsroot/pspp/pspp/doc/utilities.texi,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- doc/utilities.texi 30 Jul 2007 09:43:27 -0000 1.15
+++ doc/utilities.texi 24 Aug 2007 05:00:50 -0000 1.16
@@ -592,8 +592,16 @@
@table @asis
@item JOURNAL
address@hidden LOG
-Not currently used.
address@hidden LOG
+These subcommands, which are synonyms, control the journal. The
+default is ON, which causes commands entered interactively to be
+written to the journal file. Commands included from syntax files that
+are included interactively and error messages printed by PSPP are also
+written to the journal file, prefixed by @samp{>}. OFF disables use
+of the journal.
+
+The journal is named @file{pspp.jnl} by default. A different name may
+be specified.
@end table
System file subcommands affect the default format of system files
Index: src/language/lexer/ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/lexer/ChangeLog,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- src/language/lexer/ChangeLog 3 Jun 2007 22:07:48 -0000 1.27
+++ src/language/lexer/ChangeLog 24 Aug 2007 05:00:50 -0000 1.28
@@ -1,3 +1,9 @@
+2007-08-16 Ben Pfaff <address@hidden>
+
+ Implement journaling. Bug #17240.
+
+ * lexer.c (lex_get_line_raw): Pass the line read to journal_write.
+
2007-06-03 Ben Pfaff <address@hidden>
Implement missing functions for subcommand integer lists.
Index: src/language/lexer/lexer.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/lexer/lexer.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- src/language/lexer/lexer.c 2 Aug 2007 11:51:52 -0000 1.24
+++ src/language/lexer/lexer.c 24 Aug 2007 05:00:50 -0000 1.25
@@ -31,6 +31,7 @@
#include <data/settings.h>
#include <libpspp/getl.h>
#include <libpspp/str.h>
+#include <output/journal.h>
#include "size_max.h"
@@ -856,8 +857,13 @@
lex_get_line_raw (struct lexer *lexer, enum getl_syntax *syntax)
{
enum getl_syntax dummy;
- bool ok = getl_read_line (lexer->ss, &lexer->line_buffer,
- syntax != NULL ? syntax : &dummy);
+ bool ok;
+
+ if (syntax == NULL)
+ syntax = &dummy;
+ ok = getl_read_line (lexer->ss, &lexer->line_buffer, syntax);
+ journal_write (*syntax == GETL_BATCH, ds_cstr (&lexer->line_buffer));
+
return ok;
}
Index: src/language/utilities/ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/utilities/ChangeLog,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- src/language/utilities/ChangeLog 6 May 2007 22:05:22 -0000 1.9
+++ src/language/utilities/ChangeLog 24 Aug 2007 05:00:50 -0000 1.10
@@ -1,3 +1,11 @@
+2007-08-16 Ben Pfaff <address@hidden>
+
+ Implement journaling. Bug #17240.
+
+ * set.q: Add LOG subcommand as synonym for JOURNAL.
+ (stc_custom_journal): Implement.
+ (stc_custom_log): New function.
+
2007-05-06 Ben Pfaff <address@hidden>
Abstract the documents within a dictionary a little better.
Index: src/language/utilities/set.q
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/utilities/set.q,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- src/language/utilities/set.q 7 Jul 2007 06:14:18 -0000 1.27
+++ src/language/utilities/set.q 24 Aug 2007 05:00:50 -0000 1.28
@@ -41,6 +41,7 @@
#include <libpspp/magic.h>
#include <libpspp/message.h>
#include <math/random.h>
+#include <output/journal.h>
#include <output/output.h>
#if HAVE_LIBTERMCAP
@@ -83,6 +84,7 @@
histogram=string "x==1" "one character long";
include=inc:on/off;
journal=custom;
+ log=custom;
length=custom;
listing=custom;
lowres=lores:auto/on/off;
@@ -507,20 +509,30 @@
stc_custom_journal (struct lexer *lexer, struct dataset *ds UNUSED, struct
cmd_set *cmd UNUSED, void *aux UNUSED)
{
lex_match (lexer, '=');
- if (!lex_match_id (lexer, "ON") && !lex_match_id (lexer, "OFF"))
+ if (lex_match_id (lexer, "ON") || lex_match_id (lexer, "YES"))
+ journal_enable ();
+ else if (lex_match_id (lexer, "OFF") || lex_match_id (lexer, "NO"))
+ journal_disable ();
+ else if (lex_token (lexer) == T_STRING || lex_token (lexer) == T_ID)
{
- if (lex_token (lexer) == T_STRING)
+ journal_set_file_name (ds_cstr (lex_tokstr (lexer)));
lex_get (lexer);
+ }
else
{
lex_error (lexer, NULL);
return 0;
}
- }
return 1;
}
static int
+stc_custom_log (struct lexer *lexer, struct dataset *ds UNUSED, struct cmd_set
*cmd UNUSED, void *aux UNUSED)
+{
+ return stc_custom_journal (lexer, ds, cmd, aux);
+}
+
+static int
stc_custom_listing (struct lexer *lexer, struct dataset *ds UNUSED, struct
cmd_set *cmd UNUSED, void *aux UNUSED)
{
bool listing;
Index: src/output/ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/src/output/ChangeLog,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- src/output/ChangeLog 16 Aug 2007 06:30:23 -0000 1.25
+++ src/output/ChangeLog 24 Aug 2007 05:00:50 -0000 1.26
@@ -1,3 +1,13 @@
+2007-08-23 Ben Pfaff <address@hidden>
+
+ Implement journaling. Bug #17240.
+
+ * automake.mk (output_sources): Add journal.c, journal.h.
+
+ * journal.c: New file.
+
+ * journal.h: New file.
+
2007-08-16 Ben Pfaff <address@hidden>
* output.c output.h: export function outp_configure_driver_line.
Index: src/output/automake.mk
===================================================================
RCS file: /cvsroot/pspp/pspp/src/output/automake.mk,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- src/output/automake.mk 3 Apr 2006 20:07:54 -0000 1.3
+++ src/output/automake.mk 24 Aug 2007 05:00:50 -0000 1.4
@@ -11,6 +11,8 @@
src/output/ascii.c \
src/output/html.c \
src/output/htmlP.h \
+ src/output/journal.c \
+ src/output/journal.h \
src/output/output.c \
src/output/output.h \
src/output/postscript.c \
Index: src/ui/terminal/ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/src/ui/terminal/ChangeLog,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- src/ui/terminal/ChangeLog 27 Jul 2007 22:58:03 -0000 1.24
+++ src/ui/terminal/ChangeLog 24 Aug 2007 05:00:51 -0000 1.25
@@ -1,3 +1,17 @@
+2007-08-23 Ben Pfaff <address@hidden>
+
+ Implement journaling. Bug #17240.
+
+ * msg-ui.c (handle_msg): Send message to write_journal function
+ as well as msg_file.
+ (dump_message): Change interface so that it takes a function
+ pointer instead of a FILE.
+ (write_stream): New function.
+ (write_journal): New function.
+
+ * read-line.c (welcome): Call journal_enable, so that the journal
+ is enabled by default.
+
2007-07-25 Ben Pfaff <address@hidden>
Make interactive output go to the terminal (bug #17213), by
Index: src/ui/terminal/msg-ui.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/ui/terminal/msg-ui.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- src/ui/terminal/msg-ui.c 7 Jul 2007 06:14:31 -0000 1.13
+++ src/ui/terminal/msg-ui.c 24 Aug 2007 05:00:51 -0000 1.14
@@ -25,6 +25,7 @@
#include <data/settings.h>
#include <libpspp/message.h>
#include <libpspp/str.h>
+#include <output/journal.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -112,9 +113,11 @@
return error_count > 0;
}
-static void dump_message (char *msg, unsigned width, unsigned indent, FILE *);
-static void dump_line (int line_indent, const char *line, size_t length,
- FILE *);
+typedef void write_line_func (int indent, struct substring line, void *aux);
+static void dump_message (char *msg, unsigned width, unsigned indent,
+ write_line_func *, void *aux);
+static write_line_func write_stream;
+static write_line_func write_journal;
static void
handle_msg (const struct msg *m)
@@ -169,16 +172,21 @@
ds_put_cstr (&string, m->text);
if (msg_file != stdout || get_error_routing_to_terminal ())
- dump_message (ds_cstr (&string), get_viewwidth (), 8, msg_file);
+ dump_message (ds_cstr (&string), get_viewwidth (), 8,
+ write_stream, msg_file);
+
+ dump_message (ds_cstr (&string), 78, 0, write_journal, NULL);
ds_destroy (&string);
}
/* Divides MSG into lines of WIDTH width for the first line and
WIDTH - INDENT width for each succeeding line, and writes the
- lines to STREAM. */
+ lines by calling DUMP_LINE for each line, passing AUX as
+ auxiliary data. */
static void
-dump_message (char *msg, unsigned width, unsigned indent, FILE *stream)
+dump_message (char *msg, unsigned width, unsigned indent,
+ write_line_func *dump_line, void *aux)
{
size_t length = strlen (msg);
char *string, *breaks;
@@ -194,8 +202,7 @@
{
free (string);
free (breaks);
- fputs (msg, stream);
- putc ('\n', stream);
+ dump_line (0, ss_cstr (msg), aux);
return;
}
@@ -210,42 +217,44 @@
line_start = 0;
line_indent = 0;
for (i = 0; i < length; i++)
- switch (breaks[i])
+ if (breaks[i] == UC_BREAK_POSSIBLE || breaks[i] == UC_BREAK_MANDATORY)
{
- case UC_BREAK_POSSIBLE:
- /* Break before this character,
- and include this character in the next line. */
- dump_line (line_indent, &string[line_start], i - line_start, stream);
- line_start = i;
+ dump_line (line_indent,
+ ss_buffer (string + line_start, i - line_start), aux);
line_indent = indent;
- break;
- case UC_BREAK_MANDATORY:
- /* Break before this character,
- but don't include this character in the next line
- (because it'string a new-line). */
- dump_line (line_indent, &string[line_start], i - line_start, stream);
- line_start = i + 1;
- line_indent = indent;
- break;
- default:
- break;
+
+ /* UC_BREAK_POSSIBLE means that a line break can be
+ inserted, and that the character should be included
+ in the next line.
+ UC_BREAK_MANDATORY means that this character is a line
+ break, so it should not be included in the next line. */
+ line_start = i + (breaks[i] == UC_BREAK_MANDATORY);
}
if (line_start < length)
- dump_line (line_indent, &string[line_start], length - line_start, stream);
+ dump_line (line_indent,
+ ss_buffer (string + line_start, length - line_start), aux);
free (string);
free (breaks);
}
-/* Write LINE_INDENT spaces, the LENGTH characters in LINE, then
- a new-line to STREAM. */
+/* Write LINE_INDENT spaces, LINE, then a new-line to STREAM. */
static void
-dump_line (int line_indent, const char *line, size_t length, FILE *stream)
+write_stream (int line_indent, struct substring line, void *stream_)
{
+ FILE *stream = stream_;
int i;
for (i = 0; i < line_indent; i++)
putc (' ', stream);
- fwrite (line, 1, length, stream);
+ fwrite (ss_data (line), 1, ss_length (line), stream);
putc ('\n', stream);
}
+/* Writes LINE to the journal. */
+static void
+write_journal (int line_indent, struct substring line, void *unused UNUSED)
+{
+ char *s = xstrndup (ss_data (line), ss_length (line));
+ journal_write (true, s);
+ free (s);
+}
Index: src/ui/terminal/read-line.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/ui/terminal/read-line.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- src/ui/terminal/read-line.c 27 Jul 2007 22:58:03 -0000 1.16
+++ src/ui/terminal/read-line.c 24 Aug 2007 05:00:51 -0000 1.17
@@ -32,6 +32,7 @@
#include <libpspp/str.h>
#include <libpspp/version.h>
#include <language/prompt.h>
+#include <output/journal.h>
#include <output/manager.h>
#include "xalloc.h"
@@ -129,6 +130,7 @@
"warranty.\" for details.\n", stdout);
puts (stat_version);
readln_initialize ();
+ journal_enable ();
}
/* Gets a line from the user and stores it into LINE.
Index: src/output/journal.c
===================================================================
RCS file: src/output/journal.c
diff -N src/output/journal.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/output/journal.c 24 Aug 2007 05:00:51 -0000 1.1
@@ -0,0 +1,101 @@
+/* PSPP - a program for statistical analysis.
+ Copyright (C) 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include <output/journal.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <libpspp/str.h>
+
+#include "fwriteerror.h"
+#include "error.h"
+#include "xalloc.h"
+
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
+/* Journaling enabled? */
+static bool journal_enabled = false;
+
+/* Name of the journal file. */
+static char *journal_file_name = NULL;
+
+/* Journal file. */
+static FILE *journal_file = NULL;
+
+/* Enables journaling. */
+void
+journal_enable (void)
+{
+ journal_enabled = true;
+}
+
+/* Disables journaling. */
+void
+journal_disable (void)
+{
+ journal_enabled = false;
+ if (journal_file != NULL)
+ fflush (journal_file);
+}
+
+/* Sets the name of the journal file to FILE_NAME. */
+void
+journal_set_file_name (const char *file_name)
+{
+ assert (file_name != NULL);
+
+ if (journal_file != NULL)
+ {
+ if (fwriteerror (journal_file))
+ error (0, errno, _("error writing \"%s\""), journal_file_name);
+ }
+
+ free (journal_file_name);
+ journal_file_name = xstrdup (file_name);
+}
+
+/* Writes LINE to the journal file (if journaling is enabled).
+ If PREFIX is non-null, the line will be prefixed by "> ". */
+void
+journal_write (bool prefix, const char *line)
+{
+ if (!journal_enabled)
+ return;
+
+ if (journal_file == NULL)
+ {
+ if (journal_file_name == NULL)
+ journal_file_name = xstrdup ("pspp.jnl");
+ journal_file = fopen (journal_file_name, "w");
+ if (journal_file == NULL)
+ {
+ error (0, errno, _("error creating \"%s\""), journal_file_name);
+ journal_enabled = false;
+ return;
+ }
+ }
+
+ if (prefix)
+ fputs ("> ", journal_file);
+ fputs (line, journal_file);
+ if (strchr (line, '\n') == NULL)
+ putc ('\n', journal_file);
+}
Index: src/output/journal.h
===================================================================
RCS file: src/output/journal.h
diff -N src/output/journal.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/output/journal.h 24 Aug 2007 05:00:51 -0000 1.1
@@ -0,0 +1,34 @@
+/* PSPP - a program for statistical analysis.
+ Copyright (C) 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Journal for commands and errors.
+
+ The journal file records the commands entered interactively
+ during a PSPP session. It also records, prefixed by "> ",
+ commands from files included with interactive commands and
+ errors. */
+
+#ifndef OUTPUT_JOURNAL_H
+#define OUTPUT_JOURNAL_H 1
+
+#include <stdbool.h>
+
+void journal_enable (void);
+void journal_disable (void);
+void journal_set_file_name (const char *);
+void journal_write (bool prefix, const char *);
+
+#endif /* output/journal.h */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pspp-cvs] pspp doc/utilities.texi src/language/lexer/Chan...,
Ben Pfaff <=