# HG changeset patch # User Philip Nienhuis # Date 1328208412 28800 # Node ID 7dee2bb231c149fc264b86c5912e5606c8b2c071 # Parent 0216b5d6c80c0e19ac4db9d8d61c717b0d96c4d0 strread.m: Fix missing semicolon and unnecessary "unable to parse" messages (Bug #35418). * strread.m: Fix missing semicolon and unnecessary "unable to parse" messages (Bug #35418). diff -r 0216b5d6c80c -r 7dee2bb231c1 scripts/io/strread.m --- a/scripts/io/strread.m Thu Feb 02 10:08:35 2012 -0800 +++ b/scripts/io/strread.m Thu Feb 02 10:46:52 2012 -0800 @@ -439,14 +439,13 @@ iwrd = 1; iwrdp = 0; iwrdl = length (words{iwrd}); for ii = 1:numel (fmt_words) + nxt_wrd = 0; + if (idf(ii)) ## Literal expected if (isempty (strfind (fmt_words{ii}, words(iwrd)))) ## Not found in current word; supposed to be in next word - ++iwrd; iwrdp = 0; - if (ii < numel (fmt_words)) - iwrdl = length (words{iwrd}); - endif + nxt_wrd = 1; else ## Found it in current word. Subtract literal length iwrdp += length (fmt_words{ii}); @@ -455,34 +454,28 @@ warning ("strread: literal '%s' (fmt spec # %d) does not match data", ... fmt_words{ii}, ii); ## Word assumed to be completely "used up". Next word - ++iwrd; iwrdp = 0; - if (ii < numel (fmt_words)) - iwrdl = length (words{iwrd}); - endif + nxt_wrd = 1; elseif (iwrdp == iwrdl) ## Word completely "used up". Next word - ++iwrd; iwrdp = 0; - if (ii < numel (fmt_words)) - iwrdl = length (words{iwrd}); - endif + nxt_wrd = 1; endif endif elseif (idg(ii)) ## Fixed width specifier (%N or %*N): read just a part of word - iwrdp += floor ... - (str2double (fmt_words{ii}(regexp(fmt_words{ii}, '\d') : end-1))); - if (iwrdp > iwrdl) - ## Match error. Field extends beyond word boundary. - warning ... - ("strread: field width '%s' (fmt spec # %d) extends beyond actual word limit", ... - fmt_words{ii}, ii); - ## Assume word to be completely "used up". Next word - ++iwrd; iwrdp = 0; iwrdl = length (words{iwrd}); - elseif (iwrdp == iwrdl) - ## Word completely "used up". Next word - ++iwrd; iwrdp = 0; iwrdl = length (words{iwrd}); - endif + iwrdp += floor ... + (str2double (fmt_words{ii}(regexp(fmt_words{ii}, '\d') : end-1))); + if (iwrdp > iwrdl) + ## Match error. Field extends beyond word boundary. + warning ... + ("strread: field width '%s' (fmt spec # %d) extends beyond actual word limit", ... + fmt_words{ii}, ii); + ## Assume word to be completely "used up". Next word + nxt_wrd = 1; + elseif (iwrdp == iwrdl) + ## Word completely "used up". Next word + nxt_wrd = 1; + endif else ## A simple format conv. specifier. Either (1) uses rest of word, or @@ -492,20 +485,25 @@ ## Next fmt_word is a literal... if (! index (words{iwrd}(iwrdp+1:end), fmt_words{ii+1})) ## ...but not found in current word => field uses rest of word - ++iwrd; iwrdp = 0; iwrdl = length (words{iwrd}); + nxt_wrd = 1; else ## ..or it IS found. Add inferred width of current conversion field iwrdp += index (words{iwrd}(iwrdp+1:end), fmt_words{ii+1}) - 1; endif elseif (iwrdp < iwrdl) ## No bordering literal to the right => field occupies (rest of) word - ++iwrd; iwrdp = 0; - if (ii < numel (fmt_words)) - iwrdl = length (words{iwrd}); - endif + nxt_wrd = 1; endif endif + + if (nxt_wrd) + ++iwrd; iwrdp = 0; + if (ii < numel (fmt_words)) + iwrdl = length (words{iwrd}); + endif + endif + endfor ## Done words_period = max (iwrd - 1, 1); @@ -670,7 +668,7 @@ k++; case "s" if (pad_out) - data(end+1:num_lines) = {""} + data(end+1:num_lines) = {""}; endif varargout{k} = strtrunc (data, swidth)'; k++;