Mercurial > hg > octave-lyh
changeset 3867:81552337b120
[project @ 2002-01-03 18:31:08 by jwe]
author | jwe |
---|---|
date | Thu, 03 Jan 2002 18:31:09 +0000 |
parents | 67c500559ac1 |
children | 60cf0328874e |
files | liboctave/ChangeLog liboctave/data-conv.cc src/ChangeLog src/lex.l |
diffstat | 4 files changed, 36 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2001-12-17 John W. Eaton <jwe@bevo.che.wisc.edu> + + * data-conv.cc (LS_DO_READ): Don't do anything unless len > 0. + (LS_DO_WRITE): Likewise. + 2001-11-16 John W. Eaton <jwe@bevo.che.wisc.edu> * mx-inlines.cc (MX_CUMMULATIVE_OP): New macro.
--- a/liboctave/data-conv.cc +++ b/liboctave/data-conv.cc @@ -188,14 +188,17 @@ #define LS_DO_READ(TYPE, swap, data, size, len, stream) \ do \ { \ - volatile TYPE *ptr = X_CAST (volatile TYPE *, data); \ - stream.read (X_CAST (char *, ptr), size * len); \ - if (swap) \ - swap_ ## size ## _bytes (ptr, len); \ - TYPE tmp = ptr[0]; \ - for (int i = len - 1; i > 0; i--) \ - data[i] = ptr[i]; \ - data[0] = tmp; \ + if (len > 0) \ + { \ + volatile TYPE *ptr = X_CAST (volatile TYPE *, data); \ + stream.read (X_CAST (char *, ptr), size * len); \ + if (swap) \ + swap_ ## size ## _bytes (ptr, len); \ + TYPE tmp = ptr[0]; \ + for (int i = len - 1; i > 0; i--) \ + data[i] = ptr[i]; \ + data[0] = tmp; \ + } \ } \ while (0) @@ -205,13 +208,16 @@ #define LS_DO_WRITE(TYPE, data, size, len, stream) \ do \ { \ - char tmp_type = static_cast<char> (type); \ - stream.write (&tmp_type, 1); \ - TYPE *ptr = new TYPE [len]; \ - for (int i = 0; i < len; i++) \ - ptr[i] = X_CAST (TYPE, data[i]); \ - stream.write (X_CAST (char *, ptr), size * len); \ - delete [] ptr ; \ + if (len > 0) \ + { \ + char tmp_type = static_cast<char> (type); \ + stream.write (&tmp_type, 1); \ + TYPE *ptr = new TYPE [len]; \ + for (int i = 0; i < len; i++) \ + ptr[i] = X_CAST (TYPE, data[i]); \ + stream.write (X_CAST (char *, ptr), size * len); \ + delete [] ptr ; \ + } \ } \ while (0)
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2002-01-03 John W. Eaton <jwe@bevo.che.wisc.edu> + + * lex.l (.): Remove test for EOF since it is already handled + separately. + 2001-12-05 John W. Eaton <jwe@bevo.che.wisc.edu> * load-save.cc (save_mat5_binary_element):
--- a/src/lex.l +++ b/src/lex.l @@ -719,13 +719,11 @@ . { current_input_column++; - if (static_cast<int> (yytext[0]) == EOF) - error ("unexpected end of file near line %d, column %d", - input_line_number, current_input_column); - else - error ("invalid character `%s' (ASCII %d) near line %d, column %d", - undo_string_escape (yytext[0]), static_cast<int> (yytext[0]), - input_line_number, current_input_column); + // EOF can't happen here (we catch it above). + + error ("invalid character `%s' (ASCII %d) near line %d, column %d", + undo_string_escape (yytext[0]), static_cast<int> (yytext[0]), + input_line_number, current_input_column); return LEXICAL_ERROR; }