[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
locale support patch for [fs]sscanf function
From: |
CdeMills |
Subject: |
locale support patch for [fs]sscanf function |
Date: |
Tue, 17 Jan 2012 06:33:34 -0800 (PST) |
Hello,
herewith enclosed a patch proposal against 3.6.0 implementing locales
support in [fs]sscanf. There is no API change; the "C" argument is re-used
to pass the locale value. And "C" is BTW a valid locale name.
Mechanism:
- class octave_base_stream gets a new virtual member, imbue, which does
nothing
- class octave_stream gets the real implementation, its a mere proxy to
underlying std::[io]stream::imbue
- function ffscanf and scanf detect it the right argument is a stream, and
call stream::imbue in this case. For the scanf implementation, the original
locale is not preserved. For the ffscanf, it goes as:
{
// Use its val as the new locale setting. Keep old val
// for restoring afterwards.
std::locale oldloc =
os.imbue (std::locale (args(2).string_value ().c_str ()));
retval = os.oscanf (args(1), who);
os.imbue (oldloc);
}
This way, locale setting is preserved. This is a bit overkill in case of
repeated accesses, but this avoids the need to introduce a new interface to
set/reset the locale.
Advices ? Comment ?
Pascal
http://octave.1599824.n4.nabble.com/file/n4303471/sscanf-locale.pat
sscanf-locale.pat
--
View this message in context:
http://octave.1599824.n4.nabble.com/locale-support-patch-for-fs-sscanf-function-tp4303471p4303471.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.
- locale support patch for [fs]sscanf function,
CdeMills <=
- Re: locale support patch for [fs]sscanf function, CdeMills, 2012/01/18
- Re: locale support patch for [fs]sscanf function, Jordi Gutiérrez Hermoso, 2012/01/18
- Re: locale support patch for [fs]sscanf function, CdeMills, 2012/01/18
- Re: locale support patch for [fs]sscanf function, Jordi Gutiérrez Hermoso, 2012/01/18
- Re: locale support patch for [fs]sscanf function, John W. Eaton, 2012/01/18
- Re: locale support patch for [fs]sscanf function, CdeMills, 2012/01/19
- Re: locale support patch for [fs]sscanf function, John W. Eaton, 2012/01/19
- Re: locale support patch for [fs]sscanf function, CdeMills, 2012/01/19
- Re: locale support patch for [fs]sscanf function, CdeMills, 2012/01/19
- Re: locale support patch for [fs]sscanf function, Jordi Gutiérrez Hermoso, 2012/01/19