Mercurial > hg > octave-lyh
changeset 3410:ee5f222025c3
[project @ 2000-01-07 04:19:05 by jwe]
author | jwe |
---|---|
date | Fri, 07 Jan 2000 04:19:06 +0000 |
parents | 010909651e84 |
children | 7c203c3033f6 |
files | src/ChangeLog src/oct-stream.cc |
diffstat | 2 files changed, 79 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2000-01-06 John W. Eaton <jwe@bevo.che.wisc.edu> + * oct-stream.cc (do_scanf): Do the right thing again for character + conversions. + * help.cc (display_help_text): Also strip out leading spaces before Texinfo @-commands before sending doc string to makeinfo. (display_help_text): Improve format of `See also' string.
--- a/src/oct-stream.cc +++ b/src/oct-stream.cc @@ -956,6 +956,46 @@ do_scanf_conv (istream&, const char*, double*, Matrix&, double*, int&, int&, int, int, bool); +#define FINISH_CHARACTER_CONVERSION() \ + do \ + { \ + width = strlen (tmp); \ + \ + if (is) \ + { \ + int i = 0; \ + \ + if (! discard) \ + { \ + conversion_count++; \ + \ + while (i < width && tmp[i] != '\0') \ + { \ + if (data_index == max_size) \ + { \ + max_size *= 2; \ + \ + if (nr > 0) \ + mval.resize (nr, max_size / nr, 0.0); \ + else \ + { \ + if (all_char_conv && one_elt_size_spec) \ + mval.resize (1, max_size, 0.0); \ + else \ + mval.resize (max_size, 1, 0.0); \ + } \ + \ + data = mval.fortran_vec (); \ + } \ + \ + data[data_index++] = tmp[i++]; \ + } \ + } \ + } \ + \ + delete [] tmp; \ + } \ + while (0) octave_value octave_base_stream::do_scanf (scanf_format_list& fmt_list, @@ -992,20 +1032,18 @@ { if (one_elt_size_spec) { - mval.resize (1, 512, 0.0); + max_size = 512; + mval.resize (1, max_size, 0.0); data = mval.fortran_vec (); - max_size = 512; - + if (nr > 0) max_conv = nr; } else if (nr > 0 && nc > 0) { - mval.resize (nr, 32, 0.0); + mval.resize (nr, nc, 0.0); data = mval.fortran_vec (); - max_size = nr * 32; - - max_conv = nr * nc; + max_size = max_conv = nr * nc; } } else if (nr > 0) @@ -1061,18 +1099,19 @@ } else if (data_index == max_size) { + max_size *= 2; + if (nr > 0) - { - max_size *= 2; - mval.resize (nr, max_size / nr, 0.0); - data = mval.fortran_vec (); - } + mval.resize (nr, max_size / nr, 0.0); else { - max_size *= 2; - mval.resize (max_size, 1, 0.0); - data = mval.fortran_vec (); + if (all_char_conv && one_elt_size_spec) + mval.resize (1, max_size, 0.0); + else + mval.resize (max_size, 1, 0.0); } + + data = mval.fortran_vec (); } const char *fmt = elt->text; @@ -1134,16 +1173,32 @@ break; case 'c': - is.unsetf (ios::skipws); - // Fall through... + { + is.unsetf (ios::skipws); + + int width = elt->width; + + if (width == 0) + width = 1; + + char *tmp = new char[width+1]; + + int c = EOF; + int n = 0; + + while (is && n < width && (c = is.get ()) != EOF) + tmp[n++] = (char) c; + + tmp[n] = '\0'; + + FINISH_CHARACTER_CONVERSION (); + } + break; case 's': { int width = elt->width; - if (elt->type == 'c' && width == 0) - width = 1; - char *tmp = 0; if (width) @@ -1178,36 +1233,7 @@ tmp = buf.str (); } - width = strlen (tmp); - - if (is) - { - int i = 0; - - if (! discard) - { - conversion_count++; - - while (i < width && tmp[i] != '\0') - { - if (data_index == max_size) - { - max_size *= 2; - - if (nr > 0) - mval.resize (nr, max_size / nr, 0.0); - else - mval.resize (max_size, 1, 0.0); - - data = mval.fortran_vec (); - } - - data[data_index++] = tmp[i++]; - } - } - } - - delete [] tmp; + FINISH_CHARACTER_CONVERSION (); is.setf (flags); }