projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
work on SAVE DATA COLLECTION
[pspp]
/
src
/
language
/
data-io
/
save.c
diff --git
a/src/language/data-io/save.c
b/src/language/data-io/save.c
index 7f1347db982a0292895e367cc0571aa3107c4c38..cec878766ad07b2375c37afe5c044583ef8d834a 100644
(file)
--- a/
src/language/data-io/save.c
+++ b/
src/language/data-io/save.c
@@
-1,5
+1,5
@@
/* PSPP - a program for statistical analysis.
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
, 2014
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
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
@@
-25,6
+25,7
@@
#include "data/casewriter.h"
#include "data/dataset.h"
#include "data/dictionary.h"
#include "data/casewriter.h"
#include "data/dataset.h"
#include "data/dictionary.h"
+#include "data/mdd-writer.h"
#include "data/por-file-writer.h"
#include "data/sys-file-writer.h"
#include "data/transformations.h"
#include "data/por-file-writer.h"
#include "data/sys-file-writer.h"
#include "data/transformations.h"
@@
-68,6
+69,12
@@
cmd_save (struct lexer *lexer, struct dataset *ds)
return parse_output_proc (lexer, ds, SYSFILE_WRITER);
}
return parse_output_proc (lexer, ds, SYSFILE_WRITER);
}
+int
+cmd_save_data_collection (struct lexer *lexer, struct dataset *ds)
+{
+ return parse_output_proc (lexer, ds, SYSFILE_WRITER);
+}
+
int
cmd_export (struct lexer *lexer, struct dataset *ds)
{
int
cmd_export (struct lexer *lexer, struct dataset *ds)
{
@@
-154,6
+161,7
@@
parse_write_command (struct lexer *lexer, struct dataset *ds,
{
/* Common data. */
struct file_handle *handle; /* Output file. */
{
/* Common data. */
struct file_handle *handle; /* Output file. */
+ struct file_handle *metadata; /* MDD output file. */
struct dictionary *dict; /* Dictionary for output file. */
struct casewriter *writer; /* Writer. */
struct case_map_stage *stage; /* Preparation for 'map'. */
struct dictionary *dict; /* Dictionary for output file. */
struct casewriter *writer; /* Writer. */
struct case_map_stage *stage; /* Preparation for 'map'. */
@@
-171,6
+179,7
@@
parse_write_command (struct lexer *lexer, struct dataset *ds,
*retain_unselected = true;
handle = NULL;
*retain_unselected = true;
handle = NULL;
+ metadata = NULL;
dict = dict_clone (dataset_dict (ds));
writer = NULL;
stage = NULL;
dict = dict_clone (dataset_dict (ds));
writer = NULL;
stage = NULL;
@@
-198,6
+207,20
@@
parse_write_command (struct lexer *lexer, struct dataset *ds,
if (handle == NULL)
goto error;
}
if (handle == NULL)
goto error;
}
+ else if (lex_match_id (lexer, "METADATA"))
+ {
+ if (metadata != NULL)
+ {
+ lex_sbc_only_once ("METADATA");
+ goto error;
+ }
+
+ lex_match (lexer, T_EQUALS);
+
+ metadata = fh_parse (lexer, FH_REF_FILE, NULL);
+ if (metadata == NULL)
+ goto error;
+ }
else if (lex_match_id (lexer, "NAMES"))
{
/* Not yet implemented. */
else if (lex_match_id (lexer, "NAMES"))
{
/* Not yet implemented. */
@@
-234,13
+257,13
@@
parse_write_command (struct lexer *lexer, struct dataset *ds,
}
else if (writer_type == SYSFILE_WRITER
&& lex_match_id (lexer, "COMPRESSED"))
}
else if (writer_type == SYSFILE_WRITER
&& lex_match_id (lexer, "COMPRESSED"))
- sysfile_opts.compression =
SFM
_COMP_SIMPLE;
+ sysfile_opts.compression =
ANY
_COMP_SIMPLE;
else if (writer_type == SYSFILE_WRITER
&& lex_match_id (lexer, "UNCOMPRESSED"))
else if (writer_type == SYSFILE_WRITER
&& lex_match_id (lexer, "UNCOMPRESSED"))
- sysfile_opts.compression =
SFM
_COMP_NONE;
+ sysfile_opts.compression =
ANY
_COMP_NONE;
else if (writer_type == SYSFILE_WRITER
&& lex_match_id (lexer, "ZCOMPRESSED"))
else if (writer_type == SYSFILE_WRITER
&& lex_match_id (lexer, "ZCOMPRESSED"))
- sysfile_opts.compression =
SFM
_COMP_ZLIB;
+ sysfile_opts.compression =
ANY
_COMP_ZLIB;
else if (writer_type == SYSFILE_WRITER
&& lex_match_id (lexer, "VERSION"))
{
else if (writer_type == SYSFILE_WRITER
&& lex_match_id (lexer, "VERSION"))
{
@@
-306,6
+329,15
@@
parse_write_command (struct lexer *lexer, struct dataset *ds,
if (writer == NULL)
goto error;
if (writer == NULL)
goto error;
+ if (metadata)
+ {
+ const char *sav_name = (fh_get_referent (handle) == FH_REF_FILE
+ ? fh_get_file_name (handle)
+ : fh_get_name (handle));
+ if (!mdd_write (metadata, dict, sav_name))
+ goto error;
+ }
+
map = case_map_stage_get_case_map (stage);
case_map_stage_destroy (stage);
if (map != NULL)
map = case_map_stage_get_case_map (stage);
case_map_stage_destroy (stage);
if (map != NULL)
@@
-313,11
+345,13
@@
parse_write_command (struct lexer *lexer, struct dataset *ds,
dict_destroy (dict);
fh_unref (handle);
dict_destroy (dict);
fh_unref (handle);
+ fh_unref (metadata);
return writer;
error:
case_map_stage_destroy (stage);
fh_unref (handle);
return writer;
error:
case_map_stage_destroy (stage);
fh_unref (handle);
+ fh_unref (metadata);
casewriter_destroy (writer);
dict_destroy (dict);
case_map_destroy (map);
casewriter_destroy (writer);
dict_destroy (dict);
case_map_destroy (map);