X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fdata-io%2Ffile-handle.q;h=26dfc97e0c920d1fb9d9d8f90ec9a5115f65a7c1;hb=2814862a2c45a39f9822cf4c64ca3884822d064d;hp=9bf6a6bf52ffaa664aaea7db9717fcefbc23aee9;hpb=e195fccfab97205acb29f90fd1168488d49f1573;p=pspp diff --git a/src/language/data-io/file-handle.q b/src/language/data-io/file-handle.q index 9bf6a6bf52..26dfc97e0c 100644 --- a/src/language/data-io/file-handle.q +++ b/src/language/data-io/file-handle.q @@ -1,5 +1,5 @@ /* 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 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 @@ -16,20 +16,22 @@ #include +#include "data/file-handle-def.h" + #include #include #include #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" @@ -43,9 +45,10 @@ "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. + recform=recform:fixed/f/variable/v/spanned/vs; + encoding=string. */ /* (declarations) */ /* (functions) */ @@ -86,7 +89,7 @@ cmd_file_handle (struct lexer *lexer, struct dataset *ds) properties = *fh_default_properties (); if (cmd.s_name == NULL) { - lex_sbc_missing (lexer, "NAME"); + lex_sbc_missing ("NAME"); goto exit_free_cmd; } @@ -95,7 +98,12 @@ cmd_file_handle (struct lexer *lexer, struct dataset *ds) 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"); + } break; case FH_IMAGE: properties.mode = FH_MODE_FIXED; @@ -104,7 +112,7 @@ cmd_file_handle (struct lexer *lexer, struct dataset *ds) 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) @@ -141,6 +149,9 @@ cmd_file_handle (struct lexer *lexer, struct dataset *ds) 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;