Mercurial > forge
changeset 12436:b8b7b9fe9eb2 octave-forge
str2array: revert last change because it breaks beckward compatibility
author | schloegl |
---|---|
date | Tue, 15 Apr 2014 15:42:23 +0000 |
parents | 6488f1194a92 |
children | ff793245b5d2 |
files | extra/NaN/src/str2array.cpp extra/NaN/test/test_str2array.csv extra/NaN/test/test_str2array.m |
diffstat | 3 files changed, 22 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/extra/NaN/src/str2array.cpp Mon Apr 14 19:23:32 2014 +0000 +++ b/extra/NaN/src/str2array.cpp Tue Apr 15 15:42:23 2014 +0000 @@ -34,7 +34,7 @@ // // Output: // $Id: STR2ARRAY.cpp 7142 2010-03-30 18:48:06Z schloegl $ -// Copyright (C) 2010,2011,2014 Alois Schloegl <alois.schloegl@gmail.com> +// Copyright (C) 2010,2011 Alois Schloegl <alois.schloegl@gmail.com> // This function is part of the NaN-toolbox // http://pub.ist.ac.at/~schloegl/matlab/NaN/ // @@ -249,27 +249,15 @@ /* identify separators */ u = (uint8_t*) mxCalloc(1,slen+1); - int flag_newline; for (k = 0; k < slen; ) { if (strchr(cdelim,s[k]) != NULL) { - if (flag_newline) { - // ignore field delimiters after newline - s[k]==' '; - k++; - } - else { - u[k] = 1; // column delimiter - while (s[++k]==' '); // ignore extra space characters - } + u[k] = 1; // column delimiter + while (s[++k]==' '); // ignore extra space characters } - else if (strchr(rdelim,s[k]) != NULL) { + else if (strchr(rdelim,s[k]) != NULL) u[k++] = 2; // row delimiter - flag_newline = 1; - } - else { + else k++; // ordinary character - flag_newline = 0; - } } /* count dimensions and set delimiter elements to 0 */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/extra/NaN/test/test_str2array.csv Tue Apr 15 15:42:23 2014 +0000 @@ -0,0 +1,9 @@ +"remarks";"id";"type";"first";"last";"excluding";"list";"timestamp" +;"JK130515a";1;8;9;;"[8:9]"; +;"JK130612b";1;3;4;;"[3:4]"; +;"JK130925b";1;3;4;;"[3:4]"; +;"JK131004b";1;3;4;;"[3:4]"; +;"JK131010a";1;9;10;;"[9:10]"; +;;;;;;; +;;;;;;; +"cell type: 1=CA1";;;;;;;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/extra/NaN/test/test_str2array.m Tue Apr 15 15:42:23 2014 +0000 @@ -0,0 +1,8 @@ +fid = fopen('test_str2array.csv','r'); %% corrected directory +if fid<0, return; end; +s = fread(fid,[1,inf],'uint8=>char'); +fclose(fid); +s(s==10)=[]; +[n,v,c]=str2array(s,[';',char(9)],char([10,13])) + +