Hello,

There is a bug in dlmwrite in the current io pcakage regaring 
text/binary file open mode.
Currently the file is opened in text mode, which implies automatic 
LF->CRLF translation under windows.
But the line endings to be used are explicitly specified and determined 
by the option "newline".
So if "newline" is set to "pc", "\r\n" will be written to the text file, 
which is translated into "\r\r\n", since the file is opened in text mode.

So the openmode should be binary.

 > svn diff dlmwrite.m
Index: dlmwrite.m
===================================================================
--- dlmwrite.m  (revision 5906)
+++ dlmwrite.m  (working copy)
@@ -92,7 +92,7 @@
    c = 0;
    newline = "\n";
    precision = "%.16g";
-  opentype = "wt";
+  opentype = "wb";

    ## process the input arguements
    i = 0;
@@ -124,13 +124,13 @@
         precision = sprintf ("%.%gg", precision);
        endif
      elseif (strcmpi (varargin{i}, "-append"))
-      opentype = "at";
+      opentype = "ab";
      elseif (strcmpi (varargin{i}, "append"))
        i = i + 1;
        if (strcmpi (varargin{i}, "on"))
-       opentype = "at";
+       opentype = "ab";
        elseif (strcmpi (varargin{i}, "off"))
-       opentype = "wt";
+       opentype = "wb";
        else
         error ("dlmwrite: append must be \"on\" or \"off\".");
        endif


then
dlmwrite("test.dos.txt", eye(3), "newline","pc");
dlmwrite("test.unix.txt", eye(3), "newline","unix");
dlmwrite("test.mac.txt", eye(3), "newline","mac");

yield correct results under windows.

benjamin

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Octave-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to