/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 2010, 2011, 2012, 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
#include <config.h>
+#include "data/file-handle-def.h"
+
#include <limits.h>
#include <errno.h>
#include <stdlib.h>
#include "data/file-name.h"
#include "data/session.h"
+#include "data/variable.h"
#include "language/command.h"
#include "language/data-io/file-handle.h"
#include "language/lexer/lexer.h"
#include "libpspp/assertion.h"
+#include "libpspp/cast.h"
#include "libpspp/message.h"
#include "libpspp/str.h"
-#include "data/variable.h"
-#include "data/file-handle-def.h"
#include "gl/xalloc.h"
"FILE HANDLE" (fh_):
name=string;
lrecl=integer;
- tabwidth=integer "x>=0" "%s must be nonnegative";
+ tabwidth=integer;
mode=mode:!character/binary/image/360;
- recform=recform:fixed/f/variable/v/spanned/vs.
+ ends=ends:lf/crlf;
+ recform=recform:fixed/f/variable/v/spanned/vs;
+ encoding=string.
*/
/* (declarations) */
/* (functions) */
properties = *fh_default_properties ();
if (cmd.s_name == NULL)
{
- lex_sbc_missing (lexer, "NAME");
+ lex_sbc_missing ("NAME");
goto exit_free_cmd;
}
case FH_CHARACTER:
properties.mode = FH_MODE_TEXT;
if (cmd.sbc_tabwidth)
- properties.tab_width = cmd.n_tabwidth[0];
+ {
+ if (cmd.n_tabwidth[0] >= 0)
+ properties.tab_width = cmd.n_tabwidth[0];
+ else
+ msg (SE, _("%s must not be negative."), "TABWIDTH");
+ }
+ if (cmd.ends == FH_LF)
+ properties.line_ends = FH_END_LF;
+ else if (cmd.ends == FH_CRLF)
+ properties.line_ends = FH_END_CRLF;
break;
case FH_IMAGE:
properties.mode = FH_MODE_FIXED;
properties.mode = FH_MODE_VARIABLE;
break;
case FH_360:
- properties.encoding = "EBCDIC-US";
+ properties.encoding = CONST_CAST (char *, "EBCDIC-US");
if (cmd.recform == FH_FIXED || cmd.recform == FH_F)
properties.mode = FH_MODE_FIXED;
else if (cmd.recform == FH_VARIABLE || cmd.recform == FH_V)
properties.record_width = cmd.n_lrecl[0];
}
+ if (cmd.s_encoding != NULL)
+ properties.encoding = cmd.s_encoding;
+
fh_create_file (handle_name, cmd.s_name, &properties);
result = CMD_SUCCESS;