octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: locale support patch for [fs]sscanf function


From: Jordi Gutiérrez Hermoso
Subject: Re: locale support patch for [fs]sscanf function
Date: Wed, 18 Jan 2012 17:51:47 -0500

On 18 January 2012 16:23, CdeMills <address@hidden> wrote:
>
> Jordi Gutiérrez Hermoso-2 wrote
>>
>>
>> Thanks.
>>
>> Would it be too troublesome to generate a commit message?
>>
>> Something like what Ben wrote here, for example:
>>
>>     http://hg.savannah.gnu.org/hgweb/octave/rev/df695e37d404
>>
>> - Jordi G. H.
>>
> Here you are:
>
> Locale support implementation in [fs]scanf functions, i.e. the ability to
> scan "1,2" and get 1.2 as results under french locale, where the decimal
> separator is ','. This uses the C++ standard library locale approach: the
> interpretation of some stream locale is modified using the "imbue" function.
> In case of fscanf, the previous locale is restored after each call. The
> functions interface is not modified. When the last argument is a string, its
> value is used as the new locale setting.
>
> *src/oct-stream.h: Class octave_base_stream: add a virtual imbue function,
> which merely ignore its argument. Class octave_stream: add a real
> implementation, which is a proxy to std::[io]stream.imbue ().
> *src/file_io.cc: Function fscanf: when the last argument is a string, save
> the actual locale value and set a new value from this string. Generate a
> warning in case the requested locale is not supported. Revert to previous
> locale if OK, or to standard locale in case of problem. Function scanf:
> Likewise, except the stream is generated on-the-fly, there is no need to
> restore its locale value. Added a test case. Updated the doc for both
> functions.

Thanks again. I've pushed your patch:

    http://hg.savannah.gnu.org/hgweb/octave/rev/238e499c5fea

Note that your test on my system fails because I don't have a fr_FR
locale generated. I don't know how to test this function in a
system-independent way. I'm thinking just getting rid of that test.
What do you propose?

- Jordi G. H.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]