projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge 'master' into 'gtk3'.
[pspp]
/
src
/
language
/
data-io
/
save-translate.c
diff --git
a/src/language/data-io/save-translate.c
b/src/language/data-io/save-translate.c
index dcfdb83c7c618b0af02c1dc80e679149a6b15dc7..6601f30b1833a3aa129fa5507b8f3ec24422a945 100644
(file)
--- a/
src/language/data-io/save-translate.c
+++ b/
src/language/data-io/save-translate.c
@@
-1,5
+1,5
@@
/* PSPP - a program for statistical analysis.
/* PSPP - a program for statistical analysis.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010
, 2011, 2013
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
@@
-22,10
+22,10
@@
#include "data/casereader.h"
#include "data/casewriter.h"
#include "data/csv-file-writer.h"
#include "data/casereader.h"
#include "data/casewriter.h"
#include "data/csv-file-writer.h"
+#include "data/dataset.h"
#include "data/dictionary.h"
#include "data/file-name.h"
#include "data/format.h"
#include "data/dictionary.h"
#include "data/file-name.h"
#include "data/format.h"
-#include "data/procedure.h"
#include "data/settings.h"
#include "language/command.h"
#include "language/data-io/file-handle.h"
#include "data/settings.h"
#include "language/command.h"
#include "language/data-io/file-handle.h"
@@
-45,6
+45,7
@@
cmd_save_translate (struct lexer *lexer, struct dataset *ds)
enum { CSV_FILE = 1, TAB_FILE } type;
struct dictionary *dict;
enum { CSV_FILE = 1, TAB_FILE } type;
struct dictionary *dict;
+ struct case_map_stage *stage;
struct case_map *map;
struct casewriter *writer;
struct file_handle *handle;
struct case_map *map;
struct casewriter *writer;
struct file_handle *handle;
@@
-67,6
+68,7
@@
cmd_save_translate (struct lexer *lexer, struct dataset *ds)
type = 0;
dict = dict_clone (dataset_dict (ds));
type = 0;
dict = dict_clone (dataset_dict (ds));
+ stage = NULL;
map = NULL;
handle = NULL;
map = NULL;
handle = NULL;
@@
-81,7
+83,7
@@
cmd_save_translate (struct lexer *lexer, struct dataset *ds)
delimiter = 0;
qualifier = '"';
delimiter = 0;
qualifier = '"';
-
case_map_prepare_dict
(dict);
+
stage = case_map_stage_create
(dict);
dict_delete_scratch_vars (dict);
while (lex_match (lexer, T_SLASH))
dict_delete_scratch_vars (dict);
while (lex_match (lexer, T_SLASH))
@@
-96,7
+98,7
@@
cmd_save_translate (struct lexer *lexer, struct dataset *ds)
lex_match (lexer, T_EQUALS);
lex_match (lexer, T_EQUALS);
- handle = fh_parse (lexer, FH_REF_FILE);
+ handle = fh_parse (lexer, FH_REF_FILE
, NULL
);
if (handle == NULL)
goto error;
}
if (handle == NULL)
goto error;
}
@@
-115,7
+117,7
@@
cmd_save_translate (struct lexer *lexer, struct dataset *ds)
type = TAB_FILE;
else
{
type = TAB_FILE;
else
{
- lex_error
(lexer, _("expecting %s or %s"), "CSV", "TAB"
);
+ lex_error
_expecting (lexer, "CSV", "TAB", NULL_SENTINEL
);
goto error;
}
}
goto error;
}
}
@@
-132,7
+134,7
@@
cmd_save_translate (struct lexer *lexer, struct dataset *ds)
recode_user_missing = true;
else
{
recode_user_missing = true;
else
{
- lex_error
(lexer, _("expecting %s or %s"), "IGNORE", "RECODE"
);
+ lex_error
_expecting (lexer, "IGNORE", "RECODE", NULL_SENTINEL
);
goto error;
}
}
goto error;
}
}
@@
-145,7
+147,7
@@
cmd_save_translate (struct lexer *lexer, struct dataset *ds)
use_value_labels = true;
else
{
use_value_labels = true;
else
{
- lex_error
(lexer, _("expecting %s or %s"), "VALUES", "LABELS"
);
+ lex_error
_expecting (lexer, "VALUES", "LABELS", NULL_SENTINEL
);
goto error;
}
}
goto error;
}
}
@@
-159,13
+161,14
@@
cmd_save_translate (struct lexer *lexer, struct dataset *ds)
lex_match (lexer, T_EQUALS);
if (!lex_force_string (lexer))
goto error;
lex_match (lexer, T_EQUALS);
if (!lex_force_string (lexer))
goto error;
- if (ds_length (lex_tokstr (lexer)) != 1)
+ /* XXX should support multibyte UTF-8 delimiters */
+ if (ss_length (lex_tokss (lexer)) != 1)
{
msg (SE, _("The %s string must contain exactly one "
"character."), "DELIMITER");
goto error;
}
{
msg (SE, _("The %s string must contain exactly one "
"character."), "DELIMITER");
goto error;
}
- delimiter =
ds_first (lex_tokstr
(lexer));
+ delimiter =
ss_first (lex_tokss
(lexer));
lex_get (lexer);
}
else if (lex_match_id (lexer, "QUALIFIER"))
lex_get (lexer);
}
else if (lex_match_id (lexer, "QUALIFIER"))
@@
-173,13
+176,14
@@
cmd_save_translate (struct lexer *lexer, struct dataset *ds)
lex_match (lexer, T_EQUALS);
if (!lex_force_string (lexer))
goto error;
lex_match (lexer, T_EQUALS);
if (!lex_force_string (lexer))
goto error;
- if (ds_length (lex_tokstr (lexer)) != 1)
+ /* XXX should support multibyte UTF-8 qualifiers */
+ if (ss_length (lex_tokss (lexer)) != 1)
{
msg (SE, _("The %s string must contain exactly one "
"character."), "QUALIFIER");
goto error;
}
{
msg (SE, _("The %s string must contain exactly one "
"character."), "QUALIFIER");
goto error;
}
- qualifier =
ds_first (lex_tokstr
(lexer));
+ qualifier =
ss_first (lex_tokss
(lexer));
lex_get (lexer);
}
else if (lex_match_id (lexer, "DECIMAL"))
lex_get (lexer);
}
else if (lex_match_id (lexer, "DECIMAL"))
@@
-191,8
+195,8
@@
cmd_save_translate (struct lexer *lexer, struct dataset *ds)
decimal = ',';
else
{
decimal = ',';
else
{
- lex_error
(lexer, _("expecting %s or %s")
,
-
"DOT", "COMMA"
);
+ lex_error
_expecting (lexer, "DOT", "COMMA"
,
+
NULL_SENTINEL
);
goto error;
}
}
goto error;
}
}
@@
-205,8
+209,8
@@
cmd_save_translate (struct lexer *lexer, struct dataset *ds)
use_print_formats = true;
else
{
use_print_formats = true;
else
{
- lex_error
(lexer, _("expecting %s or %s")
,
-
"PLAIN", "VARIABLE"
);
+ lex_error
_expecting (lexer, "PLAIN", "VARIABLE"
,
+
NULL_SENTINEL
);
goto error;
}
}
goto error;
}
}
@@
-223,7
+227,7
@@
cmd_save_translate (struct lexer *lexer, struct dataset *ds)
retain_unselected = false;
else
{
retain_unselected = false;
else
{
- lex_error
(lexer, _("expecting %s or %s"), "RETAIN", "DELETE"
);
+ lex_error
_expecting (lexer, "RETAIN", "DELETE", NULL_SENTINEL
);
goto error;
}
}
goto error;
}
}
@@
-235,12
+239,12
@@
cmd_save_translate (struct lexer *lexer, struct dataset *ds)
if (type == 0)
{
if (type == 0)
{
- lex_sbc_missing (
lexer,
"TYPE");
+ lex_sbc_missing ("TYPE");
goto error;
}
else if (handle == NULL)
{
goto error;
}
else if (handle == NULL)
{
- lex_sbc_missing (
lexer,
"OUTFILE");
+ lex_sbc_missing ("OUTFILE");
goto error;
}
else if (!replace && fn_exists (fh_get_file_name (handle)))
goto error;
}
else if (!replace && fn_exists (fh_get_file_name (handle)))
@@
-269,7
+273,8
@@
cmd_save_translate (struct lexer *lexer, struct dataset *ds)
goto error;
fh_unref (handle);
goto error;
fh_unref (handle);
- map = case_map_from_dict (dict);
+ map = case_map_stage_get_case_map (stage);
+ case_map_stage_destroy (stage);
if (map != NULL)
writer = case_map_create_output_translator (map, writer);
dict_destroy (dict);
if (map != NULL)
writer = case_map_create_output_translator (map, writer);
dict_destroy (dict);
@@
-281,6
+286,7
@@
cmd_save_translate (struct lexer *lexer, struct dataset *ds)
return ok ? CMD_SUCCESS : CMD_CASCADING_FAILURE;
error:
return ok ? CMD_SUCCESS : CMD_CASCADING_FAILURE;
error:
+ case_map_stage_destroy (stage);
fh_unref (handle);
dict_destroy (dict);
case_map_destroy (map);
fh_unref (handle);
dict_destroy (dict);
case_map_destroy (map);