# HG changeset patch # User jwe # Date 936940671 0 # Node ID fdc7dd08cd853854857e5d3f16fb9735620ff904 # Parent 8092e8197ce4ae40bb6055d6d7e7b1dc0af8898a [project @ 1999-09-10 05:16:49 by jwe] diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Sep 6 10:50:10 1999 John W. Eaton + + * emacs/octave-inf.el (inferior-octave-startup-args): + Add --no-line-editing to the list. + Fri Jul 9 09:15:24 1999 John W. Eaton * configure.in: Try to handle IEEE FP flags for g77 on Alphas. diff --git a/doc/interpreter/emacs.texi b/doc/interpreter/emacs.texi --- a/doc/interpreter/emacs.texi +++ b/doc/interpreter/emacs.texi @@ -345,7 +345,7 @@ Octave. Customization of Octave mode can be performed by modification of the -variable @code{octave-mode-hook}. It the value of this variable is +variable @code{octave-mode-hook}. If the value of this variable is non-@code{nil}, turning on Octave mode calls its value. If you discover a problem with Octave mode, you can conveniently send a diff --git a/doc/interpreter/image.texi b/doc/interpreter/image.texi --- a/doc/interpreter/image.texi +++ b/doc/interpreter/image.texi @@ -34,7 +34,7 @@ @deftypefn {Function File} {} gray (@var{n}) Return a gray colormap with @var{n} entries corresponding to values from -0 to @var{n}. The argument @var{n} should be a scalar. If it is +0 to @var{n}-1. The argument @var{n} should be a scalar. If it is omitted, 64 is assumed. @end deftypefn diff --git a/emacs/octave-inf.el b/emacs/octave-inf.el --- a/emacs/octave-inf.el +++ b/emacs/octave-inf.el @@ -41,7 +41,7 @@ The contents of this file are sent to the inferior Octave process on startup.") -(defvar inferior-octave-startup-args '("-i") +(defvar inferior-octave-startup-args '("-i" "--no-line-editing") "*List of command line arguments for the inferior Octave process. For example, for suppressing the startup message and using `traditional' mode, set this to (\"-q\" \"--traditional\").") diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,9 @@ +Fri Sep 3 12:39:17 1999 John W. Eaton + + * lo-mappers.cc: Include ieeefp.h and sunmath.h if we have them. + * lo-ieee.c: Likewise. + Delete extern "C" declarations for infinity and quiet_nan. + Fri Aug 20 07:58:00 1999 John W. Eaton * mx-inlines.cc (VS_OP, SV_OP, VV_OP): Delete `extern template' decls. diff --git a/liboctave/lo-ieee.cc b/liboctave/lo-ieee.cc --- a/liboctave/lo-ieee.cc +++ b/liboctave/lo-ieee.cc @@ -31,6 +31,14 @@ #include #endif +#if defined (HAVE_IEEEFP_H) +#include +#endif + +#if defined (HAVE_SUNMATH_H) +#include +#endif + #if defined (HAVE_NAN_H) #if defined (SCO) #define _IEEE 1 @@ -41,14 +49,6 @@ #endif #endif -#if defined (HAVE_INFINITY) -extern "C" double infinity (); -#endif - -#if defined (HAVE_QUIET_NAN) -extern "C" double quiet_nan (long); -#endif - #include "lo-ieee.h" // Octave's idea of infinity. diff --git a/liboctave/lo-mappers.cc b/liboctave/lo-mappers.cc --- a/liboctave/lo-mappers.cc +++ b/liboctave/lo-mappers.cc @@ -27,6 +27,14 @@ #include #include +#if defined (HAVE_IEEEFP_H) +#include +#endif + +#if defined (HAVE_SUNMATH_H) +#include +#endif + #include "lo-error.h" #include "lo-ieee.h" #include "lo-mappers.h" diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,11 @@ +Thu Sep 9 19:31:58 1999 John W. Eaton + + * image/saveimage.m: Initialize scale. + +Sun Sep 5 22:13:47 1999 John W. Eaton + + * general/reshape.m: Allow reshape (a, size (b)). + Fri Sep 3 00:01:38 1999 John W. Eaton * specfun/erfinv.m: Improve stopping criterion. diff --git a/scripts/general/reshape.m b/scripts/general/reshape.m --- a/scripts/general/reshape.m +++ b/scripts/general/reshape.m @@ -28,9 +28,13 @@ function retval = reshape (a, m, n) - if (nargin != 3) - usage ("reshape (a, m, n)"); - else + if (nargin == 2 && prod (size (m)) == 2) + n = m(2); + m = m(1); + nargin = 3; + endif + + if (nargin == 3) [nr, nc] = size (a); if (nr * nc == m * n) dfi = do_fortran_indexing; @@ -50,6 +54,8 @@ else error ("reshape: sizes must match"); endif + else + usage ("reshape (a, m, n) or reshape (a, size (b))"); endif endfunction diff --git a/scripts/image/saveimage.m b/scripts/image/saveimage.m --- a/scripts/image/saveimage.m +++ b/scripts/image/saveimage.m @@ -238,6 +238,7 @@ scols = img_nr * pixfac; srows = img_nc * pixfac; + scale = 1; if (scols > pagewid * MARGIN || srows > pagehgt * MARGIN) if (scols > pagewid * MARGIN) diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,21 @@ +Thu Sep 9 17:09:23 1999 John W. Eaton + + * oct-stream.cc (get_size): Allow zero values. + (get_size): New arg, one_elt_size_spec. + (do_scanf_conv): New arg, `conv_count'. Change instantiation + requests and all callers. + (octave_base_stream::do_scanf): Improve scanning of strings. + (octave_base_stream::do_oscanf): Remove size limit on %s conversions. + + * oct-stream.cc (scanf_format_list::all_character_conversions): + Don't count %p as a character conversion. + +Tue Sep 7 08:31:04 1999 John W. Eaton + + * pr-output.cc (set_real_matrix_format, set_complex_matrix_format): + Move check for fixed_point_format ahead of check for + int_or_inf_or_nan. + Thu Sep 2 11:54:51 1999 John W. Eaton * oct-obj.cc (make_argv): Correctly handle empty strings as args. diff --git a/src/oct-stream.cc b/src/oct-stream.cc --- a/src/oct-stream.cc +++ b/src/oct-stream.cc @@ -24,6 +24,7 @@ #include #endif +#include #include #include @@ -83,7 +84,7 @@ { if (! xisinf (d)) { - if (d > 0.0) + if (d >= 0.0) retval = NINT (d); else ::error ("%s: negative value invalid as size specification", @@ -99,11 +100,14 @@ } static void -get_size (const Matrix& size, int& nr, int& nc, const char *warn_for) +get_size (const Matrix& size, int& nr, int& nc, bool& one_elt_size_spec, + const char *warn_for) { nr = -1; nc = -1; + one_elt_size_spec = false; + double dnr = -1.0; double dnc = -1.0; @@ -112,6 +116,8 @@ if (sz_nr == 1 && sz_nc == 1) { + one_elt_size_spec = true; + dnr = size (0, 0); dnc = 1.0; } @@ -140,7 +146,7 @@ { nr = get_size (dnr, warn_for); - if (! error_state && dnc > 0.0) + if (! error_state && dnc >= 0.0) nc = get_size (dnc, warn_for); } } @@ -874,7 +880,9 @@ int nr = -1; int nc = -1; - get_size (size, nr, nc, "fread"); + bool ignore; + + get_size (size, nr, nc, ignore, "fread"); if (! error_state) { @@ -898,8 +906,8 @@ template void do_scanf_conv (istream& is, const char *fmt, T valptr, Matrix& mval, - double *data, int& idx, int nr, int max_size, - bool discard) + double *data, int& idx, int& conv_count, int nr, + int max_size, bool discard) { is.scan (fmt, valptr); @@ -918,41 +926,55 @@ } if (! discard) - data[idx++] = *(valptr); + { + conv_count++; + data[idx++] = *(valptr); + } } } template void do_scanf_conv (istream&, const char*, int*, Matrix&, double*, int&, - int, int, bool); + int&, int, int, bool); template void do_scanf_conv (istream&, const char*, long int*, Matrix&, double*, int&, - int, int, bool); + int&, int, int, bool); template void do_scanf_conv (istream&, const char*, short int*, Matrix&, double*, int&, - int, int, bool); + int&, int, int, bool); #if 0 template void do_scanf_conv (istream&, const char*, float*, Matrix&, double*, int&, - int, int, bool); + int&, int, int, bool); #endif template void do_scanf_conv (istream&, const char*, double*, Matrix&, double*, int&, - int, int, bool); + int&, int, int, bool); octave_value octave_base_stream::do_scanf (scanf_format_list& fmt_list, - int nr, int nc, int& count) + int nr, int nc, bool one_elt_size_spec, + int& conversion_count) { - count = 0; + conversion_count = 0; + + int data_index = 0; octave_value retval = Matrix (); + if (nr == 0 || nc == 0) + { + if (one_elt_size_spec) + nc = 0; + + return Matrix (nr, nc, 0.0); + } + istream *isp = input_stream (); bool all_char_conv = fmt_list.all_character_conversions (); @@ -960,17 +982,40 @@ Matrix mval; double *data = 0; int max_size = 0; + int max_conv = 0; int final_nr = 0; int final_nc = 0; - if (nr > 0) + if (all_char_conv) + { + if (one_elt_size_spec) + { + mval.resize (1, 512, 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); + data = mval.fortran_vec (); + max_size = nr * 32; + + max_conv = nr * nc; + } + } + else if (nr > 0) { if (nc > 0) { mval.resize (nr, nc, 0.0); data = mval.fortran_vec (); max_size = nr * nc; + + max_conv = max_size; } else { @@ -998,27 +1043,32 @@ { if (elt) { - if (count == max_size) + if (max_conv > 0 && conversion_count == max_conv) + { + if (all_char_conv && one_elt_size_spec) + { + final_nr = 1; + final_nc = data_index; + } + else + { + final_nr = nr; + final_nc = (data_index - 1) / nr + 1; + } + + break; + } + else if (data_index == max_size) { if (nr > 0) { - if (nc > 0) - { - final_nr = nr; - final_nc = nc; - - break; - } - else - { - max_size *= 2; - mval.resize (nr, max_size / nr, 0.0); - data = mval.fortran_vec (); - } + max_size *= 2; + mval.resize (nr, max_size / nr, 0.0); + data = mval.fortran_vec (); } else { - max_size *=2; + max_size *= 2; mval.resize (max_size, 1, 0.0); data = mval.fortran_vec (); } @@ -1045,7 +1095,8 @@ case 'h': { short int tmp; - do_scanf_conv (is, fmt, &tmp, mval, data, count, + do_scanf_conv (is, fmt, &tmp, mval, data, + data_index, conversion_count, nr, max_size, discard); } break; @@ -1053,7 +1104,8 @@ case 'l': { long int tmp; - do_scanf_conv (is, fmt, &tmp, mval, data, count, + do_scanf_conv (is, fmt, &tmp, mval, data, + data_index, conversion_count, nr, max_size, discard); } break; @@ -1061,7 +1113,8 @@ default: { int tmp; - do_scanf_conv (is, fmt, &tmp, mval, data, count, + do_scanf_conv (is, fmt, &tmp, mval, data, + data_index, conversion_count, nr, max_size, discard); } break; @@ -1073,7 +1126,8 @@ { double tmp; - do_scanf_conv (is, fmt, &tmp, mval, data, count, + do_scanf_conv (is, fmt, &tmp, mval, data, + data_index, conversion_count, nr, max_size, discard); } break; @@ -1084,21 +1138,46 @@ case 's': { - int len = strlen (fmt); - char *tmp_fmt = new char [len+1]; - strcpy (tmp_fmt, fmt); - if (tmp_fmt[len-1] == 's') - tmp_fmt[len-1] = 'c'; - - int width = elt->width ? elt->width : 1; - - char *tmp = new char [width+1]; - - is.scan (tmp_fmt, tmp); - - delete [] tmp_fmt; - - tmp[width] = '\0'; + int width = elt->width; + + if (elt->type == 'c' && width == 0) + width = 1; + + char *tmp = 0; + + if (width) + { + tmp = new char [width+1]; + + is.scan (fmt, tmp); + + tmp[width] = '\0'; + } + else + { + // We're looking at a `%s' format. We have to + // skip initial whitespace and then read until + // the next whitespace character. + + ostrstream buf; + + int c = EOF; + + while (is && (c = is.get ()) != EOF && isspace (c)) + /* skip leading whitespace */; + + if (is && c != EOF) + buf << (char) c; + + while (is && (c = is.get ()) != EOF && ! isspace (c)) + buf << (char) c; + + buf << ends; + + tmp = buf.str (); + } + + width = strlen (tmp); if (is) { @@ -1106,9 +1185,11 @@ if (! discard) { + conversion_count++; + while (i < width && tmp[i] != '\0') { - if (count == max_size) + if (data_index == max_size) { max_size *= 2; @@ -1120,7 +1201,7 @@ data = mval.fortran_vec (); } - data[count++] = tmp[i++]; + data[data_index++] = tmp[i++]; } } } @@ -1146,22 +1227,40 @@ } else if (! is) { - if (nr > 0) + if (all_char_conv) { - if (count > nr) + if (one_elt_size_spec) + { + final_nr = 1; + final_nc = data_index; + } + else if (data_index > nr) { final_nr = nr; - final_nc = (count - 1) / nr + 1; + final_nc = (data_index - 1) / nr + 1; } else { - final_nr = count; + final_nr = data_index; + final_nc = 1; + } + } + else if (nr > 0) + { + if (data_index > nr) + { + final_nr = nr; + final_nc = (data_index - 1) / nr + 1; + } + else + { + final_nr = data_index; final_nc = 1; } } else { - final_nr = count; + final_nr = data_index; final_nc = 1; } @@ -1194,17 +1293,10 @@ { mval.resize (final_nr, final_nc, 0.0); + retval = mval; + if (all_char_conv) - { - if (nr < 0) - mval = mval.transpose (); - - retval = mval; - - retval = retval.convert_to_str (); - } - else - retval = mval; + retval = retval.convert_to_str (); } return retval; @@ -1267,10 +1359,12 @@ int nr = -1; int nc = -1; - get_size (size, nr, nc, "fscanf"); + bool one_elt_size_spec; + + get_size (size, nr, nc, one_elt_size_spec, "fscanf"); if (! error_state) - retval = do_scanf (fmt_list, nr, nc, count); + retval = do_scanf (fmt_list, nr, nc, one_elt_size_spec, count); } break; } @@ -1367,23 +1461,49 @@ case 's': { - // XXX FIXME XXX -- this must be fixed! - - int width = elt->width ? elt->width : 65535; - char *tmp = new char [width+1]; - - if (is.scan (fmt, tmp)) + int width = elt->width; + + char *tmp = 0; + + if (width) { - if (! discard) - { - tmp[width] = '\0'; - retval = tmp; - } + tmp = new char [width+1]; + + is.scan (fmt, tmp); + + tmp[width] = '\0'; } else - quit = true; + { + // We're looking at a `%s' format. We have to + // skip initial whitespace and then read until + // the next whitespace character. + + ostrstream buf; + + int c = EOF; + + while (is && (c = is.get ()) != EOF && isspace (c)) + /* skip leading whitespace */; + + if (is && c != EOF) + buf << (char) c; + + while (is && (c = is.get ()) != EOF && ! isspace (c)) + buf << (char) c; + + buf << ends; + + tmp = buf.str (); + + if (! discard) + retval = tmp; + } delete [] tmp; + + if (! is) + quit = true; } break; diff --git a/src/oct-stream.h b/src/oct-stream.h --- a/src/oct-stream.h +++ b/src/oct-stream.h @@ -318,7 +318,7 @@ int nr, int nc, int& count); octave_value do_scanf (scanf_format_list& fmt_list, int nr, int nc, - int& count); + bool one_elt_size_spec, int& count); octave_value scanf (const string& fmt, const Matrix& size, int& count); diff --git a/src/pr-output.cc b/src/pr-output.cc --- a/src/pr-output.cc +++ b/src/pr-output.cc @@ -293,6 +293,14 @@ fw = 8 * sizeof (double); rd = 0; } + else if (Vfixed_point_format) + { + rd = prec; + fw = rd + 2; + if (inf_or_nan && fw < 3) + fw = 3; + fw += sign; + } else if (int_or_inf_or_nan) { int digits = x_max > x_min ? x_max : x_min; @@ -302,14 +310,6 @@ fw += sign; rd = 0; } - else if (Vfixed_point_format) - { - rd = prec; - fw = rd + 2; - if (inf_or_nan && fw < 3) - fw = 3; - fw += sign; - } else { int ld_max, rd_max; @@ -613,6 +613,14 @@ i_fw = 8 * sizeof (double); rd = 0; } + else if (Vfixed_point_format) + { + rd = prec; + i_fw = r_fw = rd + 2; + if (inf_or_nan && i_fw < 3) + i_fw = r_fw = 3; + r_fw += sign; + } else if (int_or_inf_or_nan) { int digits = x_max > x_min ? x_max : x_min; @@ -622,14 +630,6 @@ r_fw += sign; rd = 0; } - else if (Vfixed_point_format) - { - rd = prec; - i_fw = r_fw = rd + 2; - if (inf_or_nan && i_fw < 3) - i_fw = r_fw = 3; - r_fw += sign; - } else { int ld_max, rd_max;