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


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

Submitter:  Júlio Hoffimann Mendes <juliohm>
Submitted:  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
* Mandatory Fields

Add a New Comment (Rich Markup)

Comment Type & Canned Response:


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 ();
      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


>> system("locale")

On MS Windows (Octave 5.1.0) your patch results in

>> mkoctfile
>> locale
ans = C

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


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:

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)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    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.9