# HG changeset patch # User Rik # Date 1361830974 28800 # Node ID 4b6c44096862cda8c610134145bccfc4087396ed # Parent 24b3800d30e77f796ed05edef1bb006c026accb6 Backout changeset 238e499c5fea (locale support in scanf) diff -r 24b3800d30e7 -r 4b6c44096862 libinterp/interp-core/oct-stream.h --- a/libinterp/interp-core/oct-stream.h Mon Feb 25 01:04:15 2013 -0500 +++ b/libinterp/interp-core/oct-stream.h Mon Feb 25 14:22:54 2013 -0800 @@ -371,12 +371,6 @@ virtual std::ostream *output_stream (void) { return 0; } - // If the derived class is locale-aware, it must implement this function - // in order to set a new locale. By default, this function avoids messing - // with locales and ignores its input argument. - virtual std::locale imbue ( const std::locale &) - { return std::locale::classic (); } - // Return TRUE if this stream is open. bool is_open (void) const { return open_state; } @@ -619,23 +613,7 @@ { return rep ? rep->output_stream () : 0; } - - std::locale imbue (const std::locale & loc ) - { - if (!rep) return std::locale::classic (); - - std::istream *is = rep->input_stream (); - std::ostream *os = rep->output_stream (); - - if (os) - { - if (is) - (void) is->imbue (loc); - return os->imbue (loc); - } - return is ? is->imbue (loc) : std::locale::classic (); - } - + void clearerr (void) { if (rep) rep->clearerr (); } private: diff -r 24b3800d30e7 -r 4b6c44096862 libinterp/interpfcn/file-io.cc --- a/libinterp/interpfcn/file-io.cc Mon Feb 25 01:04:15 2013 -0500 +++ b/libinterp/interpfcn/file-io.cc Mon Feb 25 14:22:54 2013 -0800 @@ -43,9 +43,7 @@ #include #include -#include #include -#include #include #include @@ -1087,7 +1085,7 @@ DEFUN (fscanf, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{val}, @var{count}, @var{errmsg}] =} fscanf (@var{fid}, @var{template}, @var{size})\n\ -@deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}] =} fscanf (@var{fid}, @var{template}, @var{locale})\n\ +@deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}, @var{errmsg}] =} fscanf (@var{fid}, @var{template}, \"C\")\n\ In the first form, read from @var{fid} according to @var{template},\n\ returning the result in the matrix @var{val}.\n\ \n\ @@ -1126,10 +1124,7 @@ with each conversion specifier in @var{template} corresponding to a\n\ single scalar return value. This form is more `C-like', and also\n\ compatible with previous versions of Octave. The number of successful\n\ -conversions is returned in @var{count}. It permits to explicitly\n\ -specify a locale to take into account language specific features, \n\ -such as decimal separator. This operation restores the previous locales\n\ -setting at the end of the conversion.\n\ +conversions is returned in @var{count}\n\ @ifclear OCTAVE_MANUAL\n\ \n\ See the Formatted Input section of the GNU Octave manual for a\n\ @@ -1151,25 +1146,7 @@ if (! error_state) { if (args(1).is_string ()) - { - std::locale oldloc; - try - { - // Use args(2) val as the new locale setting. Keep - // old val for restoring afterwards. - oldloc = - os.imbue (std::locale (args(2).string_value ().c_str ())); - - } - catch (std::runtime_error) - { - // Display a warning if the specified locale is unknown - warning ("fscanf: invalid locale. Try 'locale -a' for a list of supported values."); - oldloc = std::locale::classic (); - } - retval = os.oscanf (args(1), who); - os.imbue (oldloc); - } + retval = os.oscanf (args(1), who); else ::error ("%s: format TEMPLATE must be a string", who.c_str ()); } @@ -1237,7 +1214,7 @@ DEFUN (sscanf, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{val}, @var{count}, @var{errmsg}, @var{pos}] =} sscanf (@var{string}, @var{template}, @var{size})\n\ -@deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}] =} sscanf (@var{string}, @var{template}, @var{locale})\n\ +@deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}, @var{errmsg}] =} sscanf (@var{string}, @var{template}, \"C\")\n\ This is like @code{fscanf}, except that the characters are taken from the\n\ string @var{string} instead of from a stream. Reaching the end of the\n\ string is treated as an end-of-file condition. In addition to the values\n\ @@ -1262,22 +1239,8 @@ if (os.is_valid ()) { - if (args(1).is_string ()) - { - // Use args(2) val as the new locale setting. As the os - // object is short lived, we don't need to restore - // locale afterwards. - try - { - os.imbue (std::locale (args(2).string_value ().c_str ())); - } - catch (std::runtime_error) - { - // Display a warning if the specified locale is unknown - warning ("sscanf: invalid locale. Try 'locale -a' for a list of supported values."); - } - retval = os.oscanf (args(1), who); - } + if (args(1).is_string ()) + retval = os.oscanf (args(1), who); else ::error ("%s: format TEMPLATE must be a string", who.c_str ()); } @@ -1345,16 +1308,10 @@ return retval; } -/* -%!test -%! assert (sscanf ("1,2", "%f", "C"), 1) -%! assert (sscanf ("1,2", "%f", "fr_FR"), 1.2) -*/ - DEFUN (scanf, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{val}, @var{count}, @var{errmsg}] =} scanf (@var{template}, @var{size})\n\ -@deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}] =} scanf (@var{template}, @var{locale})\n\ +@deftypefnx {Built-in Function} {[@var{v1}, @var{v2}, @dots{}, @var{count}, @var{errmsg}]] =} scanf (@var{template}, \"C\")\n\ This is equivalent to calling @code{fscanf} with @var{fid} = @code{stdin}.\n\ \n\ It is currently not useful to call @code{scanf} in interactive\n\