patchGNU Octave - Patches: patch #7924, Added two functions: locale() and...

 
 

patch #7924: Added two functions: locale() and setlocale()

Submitted by:  Júlio Hoffimann Mendes <juliohm>
Submitted on:  Tue 15 Jan 2013 12:25:44 AM UTC  
 
Category:  Core : new function Priority:  3 - Low
Status:  Wont Do Privacy:  Public
Assigned to:  None Open/Closed:  Closed

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat 18 Jan 2020 04:56:30 PM UTC, comment #3: 

Review for Octave 6.

Thank you for your contribution.  Sorry for the first reply after almost 7 years.  I changing the system locale is too platform specific.  For example I extracted a portion of your patch.

#include <locale>
#include <stdexcept>

#include <octave/oct.h>

DEFUN_DLD (locale, args, , "")
{
  int nargin = args.length ();
  octave_value retval;

  if (nargin > 1)
    print_usage ();

  if (nargin == 0)
  {
    retval = std::locale("").name ();
  }
  else
  {
    try
    {
      std::string loc_name = args(0).string_value ();
      std::locale _(loc_name.c_str ());

      retval = true;

      // the empty string represents the user's locale
      // in C++, this should be hidden from the end user
      if (loc_name.empty ())
        retval = false;
    }
    catch (std::runtime_error& e)
    {
      retval = false;
    }
  }
  return retval;
}

and on my system (openSUSE 15.1; Octave 5.1.0) the output is

>> mkoctfile locale.cc
>> locale
ans = LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=en_US.UTF-8;LC_ADDRESS=en_US.UTF-8;LC_TELEPHONE=en_US.UTF-8;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=en_US.UTF-8

while

>> system("locale")
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=C
LC_TIME=C
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

On MS Windows (Octave 5.1.0) your patch results in

>> mkoctfile locale.cc
>> locale
ans = C

While `system("locale")` doesn't work on MS Windows.  You claimed the output should be that of the LANG variable:

"en_US.UTF-8"

My humble opinion is, that tampering with the OS settings should be done only as little as needed by Octave to guarantee reliable numerical results and I kindly refuse this patch.

Closing item.

Kai Torben Ohlhus <siko1056>
Project Member
Fri 08 Feb 2013 07:02:24 PM UTC, comment #2: 

This patch is ready. If there is something you don't like about it, please let me know.

Júlio Hoffimann Mendes <juliohm>
Tue 15 Jan 2013 12:35:40 AM UTC, comment #1: 

I've just realized the year in the copyright notice, be free to change it to 2013.

Júlio Hoffimann Mendes <juliohm>
Tue 15 Jan 2013 12:25:44 AM UTC, original submission:  

This patch adds two new functions for querying/setting the locale from within Octave.

It also fixes a test failure with sscanf().

Júlio Hoffimann Mendes <juliohm>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #27265:  locale.patch added by juliohm (5KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by siko1056 (Posted a comment)
  • -email is unavailable- added by juliohm (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-01-25 mtmiller Carbon-CopyRemoved 80942 => -
    2020-01-18 siko1056 Priority5 - Normal => 3 - Low
        StatusNone => Wont Do
        Open/ClosedOpen => Closed
    2018-04-10 mtmiller CategoryNone => Core : new function
    2013-01-15 juliohm Attached File- => Added locale.patch, #27265

    Back to the top


    Powered by Savane 3.5