#include <errno.h>
#include <stdlib.h>
#include <time.h>
+#include <unistd.h>
+#include "gl/vasnprintf.h"
+
+#include "data/casereader.h"
#include "data/data-in.h"
#include "data/data-out.h"
#include "data/dataset.h"
#include "language/lexer/lexer.h"
#include "libpspp/compiler.h"
#include "libpspp/copyleft.h"
+#include "libpspp/temp-file.h"
+#include "libpspp/version.h"
#include "libpspp/float-format.h"
#include "libpspp/i18n.h"
#include "libpspp/integer-format.h"
return xasprintf ("%d", settings_get_viewwidth ());
}
+static char *
+show_current_directory (const struct dataset *ds UNUSED)
+{
+ char *buf = NULL;
+ char *wd = NULL;
+ size_t len = 256;
+
+ do
+ {
+ len <<= 1;
+ buf = xrealloc (buf, len);
+ }
+ while (NULL == (wd = getcwd (buf, len)));
+
+ return wd;
+}
+
+static char *
+show_tempdir (const struct dataset *ds UNUSED)
+{
+ return strdup (temp_dir_name ());
+}
+
+static char *
+show_version (const struct dataset *ds UNUSED)
+{
+ return strdup (version);
+}
+
+static char *
+show_system (const struct dataset *ds UNUSED)
+{
+ return strdup (host_system);
+}
+
+static char *
+show_n (const struct dataset *ds)
+{
+ casenumber n;
+ size_t l;
+
+ const struct casereader *reader = dataset_source (ds);
+
+ if (reader == NULL)
+ return strdup (_("Unknown"));
+
+ n = casereader_count_cases (reader);
+
+ return asnprintf (NULL, &l, "%ld", n);
+}
+
+
struct show_sbc
{
const char *name;
{"CCD", show_ccd},
{"CCE", show_cce},
{"DECIMALS", show_decimals},
+ {"DIRECTORY", show_current_directory},
+ {"ENVIRONMENT", show_system},
{"ERRORS", show_errors},
{"FORMAT", show_format},
{"LENGTH", show_length},
{"MXERRS", show_mxerrs},
{"MXLOOPS", show_mxloops},
{"MXWARNS", show_mxwarns},
+ {"N", show_n},
{"PRINTBACk", show_printback},
{"RESULTS", show_results},
{"RIB", show_rib},
{"RRB", show_rrb},
{"SCOMPRESSION", show_scompression},
+ {"TEMPDIR", show_tempdir},
{"UNDEFINED", show_undefined},
+ {"VERSION", show_version},
{"WEIGHT", show_weight},
{"WIB", show_wib},
{"WRB", show_wrb},
fputs (copyleft, stdout);
}
+
int
cmd_show (struct lexer *lexer, struct dataset *ds)
{
show_all_cc (ds);
else if (lex_match_id (lexer, "WARRANTY"))
show_warranty (ds);
- else if (lex_match_id (lexer, "COPYING"))
+ else if (lex_match_id (lexer, "COPYING") || lex_match_id (lexer, "LICENSE"))
show_copying (ds);
else if (lex_token (lexer) == T_ID)
{