From a860739c34aad93afd7cb2cb24bcaef3e6eeae8a Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 21 Mar 2013 21:42:23 -0700 Subject: [PATCH] FILE HANDLE: Use system native line ends by default. Requested by Ronald Crichton. --- NEWS | 4 ++++ doc/data-io.texi | 9 +++++---- src/data/file-handle-def.c | 8 +++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 7b20d4e9f7..bf043140e1 100644 --- a/NEWS +++ b/NEWS @@ -136,6 +136,10 @@ Changes from 0.6.2 to 0.7.9: See the documentation for the INSERT command in the PSPP manual for more information. + * Text data files that PRINT and WRITE creates now use the system + native line ends by default (CRLF on Windows, LF only elsewhere). + Use the new ENDS subcommand on FILE HANDLE to override the default. + * A new Perl module allows Perl programs to read and write PSPP system files. diff --git a/doc/data-io.texi b/doc/data-io.texi index 79deb4a3ac..313e543205 100644 --- a/doc/data-io.texi +++ b/doc/data-io.texi @@ -629,10 +629,11 @@ Each tab is 4 characters wide by default, but TABWIDTH (a @pspp{} extension) may be used to specify an alternate width. Use a TABWIDTH of 0 to suppress tab expansion. -By default, a file written in CHARACTER mode uses line feeds only at -ends of lines, which is customary on Unix-like system. Specify ENDS -as CR or CRLF to override the default. PSPP reads files using either -convention on any kind of system, regardless of ENDS. +A file written in CHARACTER mode by default uses the line ends of the +system on which PSPP is running, that is, on Windows, the default is +CR LF line ends, and on other systems the default is LF only. Specify +ENDS as CR or CRLF to override the default. PSPP reads files using +either convention on any kind of system, regardless of ENDS. @item In IMAGE mode, the data file is treated as a series of fixed-length diff --git a/src/data/file-handle-def.c b/src/data/file-handle-def.c index 78848c2019..9c853e5e98 100644 --- a/src/data/file-handle-def.c +++ b/src/data/file-handle-def.c @@ -265,8 +265,14 @@ fh_create_dataset (struct dataset *ds) const struct fh_properties * fh_default_properties (void) { +#if defined _WIN32 || defined __WIN32__ +#define DEFAULT_LINE_ENDS FH_END_CRLF +#else +#define DEFAULT_LINE_ENDS FH_END_LF +#endif + static const struct fh_properties default_properties - = {FH_MODE_TEXT, FH_END_LF, 1024, 4, (char *) "Auto"}; + = {FH_MODE_TEXT, DEFAULT_LINE_ENDS, 1024, 4, (char *) "Auto"}; return &default_properties; } -- 2.30.2