On Wed, June 29, 2022 11:12, Omar Polo wrote:
> +cc kirby@ (maintainer)
>
> Stefan Hagen <[email protected]> wrote:
>> Abel Abraham Camarillo Ojeda wrote (2022-06-20 08:24 CEST):
>> > [...]
>> >
>> > I now applied the patch correctly, I can no longer reproduce the issue.
>> >
>> > upstream seems unresponsive about this, any chance of getting it on ports?
>>
>> The one that rips out all setlocale calls? No.
>>
>> Here is a better diff, which replaces the setlocale(3) calls with thread
>> local (and therefore thread-safe) uselocale(3) calls.
>>
>> I'm still testing this, because it is not exactly the same as the original.
>>
>> If it improves the situation on OpenBSD, I'm not opposed to commit these
>> patches. Please test and report back.
>
> I don't use rawtherapee, and my understanding of the locale api is
> (voluntarely) scarse, but I'm not sure the patch is right.
>
> On OpenBSD there shouldn't be issue, because freelocale (AFAIU) is a
> no-op, but on other OSes you need to free the locale returned by
> newlocale or duplocale.
>
> See (but not too closely!) the example from the GNU man page for
> newlocale:
>
> https://man.voidlinux.org/newlocale
>
> so the patch may be OK for us, but not to fed it to upstream.
Hi,
If this patch is OK for OpenBSD, we could use it as a temporary
solution until cross-platform solution is found.
>
>> Best Regards,
>> Stefan
>>
>> Index: graphics/rawtherapee/Makefile
>> ===================================================================
>> RCS file: /home/cvs/ports/graphics/rawtherapee/Makefile,v
>> retrieving revision 1.38
>> diff -u -p -u -p -r1.38 Makefile
>> --- graphics/rawtherapee/Makefile 28 May 2022 06:20:01 -0000 1.38
>> +++ graphics/rawtherapee/Makefile 28 Jun 2022 14:49:21 -0000
>> @@ -4,7 +4,7 @@ ONLY_FOR_ARCHS = amd64
>> COMMENT = RAW image processing application
>>
>> DISTNAME = rawtherapee-5.8
>> -REVISION = 1
>> +REVISION = 2
>>
>> CATEGORIES = graphics
>>
>> Index: graphics/rawtherapee/patches/patch-rtengine_dcraw_c
>> ===================================================================
>> RCS file: graphics/rawtherapee/patches/patch-rtengine_dcraw_c
>> diff -N graphics/rawtherapee/patches/patch-rtengine_dcraw_c
>> --- /dev/null 1 Jan 1970 00:00:00 -0000
>> +++ graphics/rawtherapee/patches/patch-rtengine_dcraw_c 28 Jun 2022
>> 15:45:04
>> -0000
>> @@ -0,0 +1,13 @@
>> +Index: rtengine/dcraw.c
>> +--- rtengine/dcraw.c.orig
>> ++++ rtengine/dcraw.c
>> +@@ -9853,8 +9853,7 @@ int CLASS main (int argc, const char **argv)
>> + putenv ((char *) "TZ=UTC");
>> + #endif
>> + #ifdef LOCALEDIR
>> +- setlocale (LC_CTYPE, "");
>> +- setlocale (LC_MESSAGES, "");
>> ++ uselocale (newlocale(LC_CTYPE_MASK | LC_MESSAGES, "",
>> duplocale(LC_GLOBAL_LOCALE)));
>> + bindtextdomain ("dcraw", LOCALEDIR);
>> + textdomain ("dcraw");
>> + #endif
>> Index: graphics/rawtherapee/patches/patch-rtengine_procparams_cc
>> ===================================================================
>> RCS file: graphics/rawtherapee/patches/patch-rtengine_procparams_cc
>> diff -N graphics/rawtherapee/patches/patch-rtengine_procparams_cc
>> --- /dev/null 1 Jan 1970 00:00:00 -0000
>> +++ graphics/rawtherapee/patches/patch-rtengine_procparams_cc 28 Jun
>> 2022
>> 14:38:58 -0000
>> @@ -0,0 +1,13 @@
>> +Index: rtengine/procparams.cc
>> +--- rtengine/procparams.cc.orig
>> ++++ rtengine/procparams.cc
>> +@@ -3729,7 +3729,8 @@ int ProcParams::save(const Glib::ustring& fname,
>> const
>> +
>> + int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited)
>> + {
>> +- setlocale(LC_NUMERIC, "C"); // to set decimal point to "."
>> ++ // to set decimal point to "."
>> ++ uselocale(newlocale(LC_NUMERIC_MASK, "C",
>> duplocale(LC_GLOBAL_LOCALE)));
>> +
>> + if (fname.empty()) {
>> + return 1;
>> Index: graphics/rawtherapee/patches/patch-rtengine_rtthumbnail_cc
>> ===================================================================
>> RCS file: graphics/rawtherapee/patches/patch-rtengine_rtthumbnail_cc
>> diff -N graphics/rawtherapee/patches/patch-rtengine_rtthumbnail_cc
>> --- /dev/null 1 Jan 1970 00:00:00 -0000
>> +++ graphics/rawtherapee/patches/patch-rtengine_rtthumbnail_cc 28 Jun
>> 2022
>> 15:45:47 -0000
>> @@ -0,0 +1,12 @@
>> +Index: rtengine/rtthumbnail.cc
>> +--- rtengine/rtthumbnail.cc.orig
>> ++++ rtengine/rtthumbnail.cc
>> +@@ -2013,7 +2013,7 @@ bool Thumbnail::readImage (const Glib::ustring&
>> fname)
>> +
>> + bool Thumbnail::readData (const Glib::ustring& fname)
>> + {
>> +- setlocale (LC_NUMERIC, "C"); // to set decimal point to "."
>> ++ uselocale (newlocale(LC_NUMERIC_MASK, "C",
>> duplocale(LC_GLOBAL_LOCALE)));
>> + Glib::KeyFile keyFile;
>> +
>> + try {
>> Index: graphics/rawtherapee/patches/patch-rtexif_rtexif_cc
>> ===================================================================
>> RCS file: graphics/rawtherapee/patches/patch-rtexif_rtexif_cc
>> diff -N graphics/rawtherapee/patches/patch-rtexif_rtexif_cc
>> --- /dev/null 1 Jan 1970 00:00:00 -0000
>> +++ graphics/rawtherapee/patches/patch-rtexif_rtexif_cc 28 Jun 2022
>> 15:37:26
>> -0000
>> @@ -0,0 +1,13 @@
>> +Index: rtexif/rtexif.cc
>> +--- rtexif/rtexif.cc.orig
>> ++++ rtexif/rtexif.cc
>> +@@ -2788,7 +2788,8 @@ void ExifManager::parse (bool isRaw, bool
>> skipIgnored,
>> + #endif
>> + return;
>> + }
>> +- setlocale (LC_NUMERIC, "C"); // to set decimal point in sscanf
>> ++ // to set decimal point in sscanf
>> ++ uselocale (newlocale(LC_NUMERIC_MASK, "C",
>> duplocale(LC_GLOBAL_LOCALE)));
>> +
>> + if (order == ByteOrder::UNKNOWN) {
>> + // read tiff header
>> Index: graphics/rawtherapee/patches/patch-rtgui_cacheimagedata_cc
>> ===================================================================
>> RCS file: graphics/rawtherapee/patches/patch-rtgui_cacheimagedata_cc
>> diff -N graphics/rawtherapee/patches/patch-rtgui_cacheimagedata_cc
>> --- /dev/null 1 Jan 1970 00:00:00 -0000
>> +++ graphics/rawtherapee/patches/patch-rtgui_cacheimagedata_cc 28 Jun
>> 2022
>> 14:37:57 -0000
>> @@ -0,0 +1,13 @@
>> +Index: rtgui/cacheimagedata.cc
>> +--- rtgui/cacheimagedata.cc.orig
>> ++++ rtgui/cacheimagedata.cc
>> +@@ -65,7 +65,8 @@ CacheImageData::CacheImageData() :
>> + */
>> + int CacheImageData::load (const Glib::ustring& fname)
>> + {
>> +- setlocale(LC_NUMERIC, "C"); // to set decimal point to "."
>> ++ // to set decimal point to "."
>> ++ uselocale(newlocale(LC_NUMERIC_MASK, "C",
>> duplocale(LC_GLOBAL_LOCALE)));
>> +
>> + Glib::KeyFile keyFile;
>> +
>> Index: graphics/rawtherapee/patches/patch-rtgui_main-cli_cc
>> ===================================================================
>> RCS file: graphics/rawtherapee/patches/patch-rtgui_main-cli_cc
>> diff -N graphics/rawtherapee/patches/patch-rtgui_main-cli_cc
>> --- /dev/null 1 Jan 1970 00:00:00 -0000
>> +++ graphics/rawtherapee/patches/patch-rtgui_main-cli_cc 28 Jun 2022
>> 14:52:43 -0000
>> @@ -0,0 +1,13 @@
>> +Index: rtgui/main-cli.cc
>> +--- rtgui/main-cli.cc.orig
>> ++++ rtgui/main-cli.cc
>> +@@ -104,8 +104,7 @@ bool dontLoadCache ( int argc, char **argv );
>> +
>> + int main (int argc, char **argv)
>> + {
>> +- setlocale (LC_ALL, "");
>> +- setlocale (LC_NUMERIC, "C"); // to set decimal point to "."
>> ++ uselocale(newlocale(LC_NUMERIC_MASK, "C", (locale_t)0));
>> +
>> + Gio::init ();
>> +
>> Index: graphics/rawtherapee/patches/patch-rtgui_main_cc
>> ===================================================================
>> RCS file: graphics/rawtherapee/patches/patch-rtgui_main_cc
>> diff -N graphics/rawtherapee/patches/patch-rtgui_main_cc
>> --- /dev/null 1 Jan 1970 00:00:00 -0000
>> +++ graphics/rawtherapee/patches/patch-rtgui_main_cc 28 Jun 2022 14:16:15
>> -0000
>> @@ -0,0 +1,15 @@
>> +Switch to thread safe uselocale(3)
>> +
>> +Index: rtgui/main.cc
>> +--- rtgui/main.cc.orig
>> ++++ rtgui/main.cc
>> +@@ -366,8 +366,7 @@ void show_gimp_plugin_info_dialog(Gtk::Window *parent)
>> +
>> + int main (int argc, char **argv)
>> + {
>> +- setlocale (LC_ALL, "");
>> +- setlocale (LC_NUMERIC, "C"); // to set decimal point to "."
>> ++ uselocale (newlocale(LC_NUMERIC_MASK, "C", (locale_t) 0));
>> +
>> + simpleEditor = false;
>> + gimpPlugin = false;
>> Index: graphics/rawtherapee/patches/patch-rtgui_options_cc
>> ===================================================================
>> RCS file: graphics/rawtherapee/patches/patch-rtgui_options_cc
>> diff -N graphics/rawtherapee/patches/patch-rtgui_options_cc
>> --- /dev/null 1 Jan 1970 00:00:00 -0000
>> +++ graphics/rawtherapee/patches/patch-rtgui_options_cc 28 Jun 2022
>> 14:38:39
>> -0000
>> @@ -0,0 +1,12 @@
>> +Index: rtgui/options.cc
>> +--- rtgui/options.cc.orig
>> ++++ rtgui/options.cc
>> +@@ -666,7 +666,7 @@ void Options::filterOutParsedExtensions()
>> +
>> + void Options::readFromFile(Glib::ustring fname)
>> + {
>> +- setlocale(LC_NUMERIC, "C"); // to set decimal point to "."
>> ++ uselocale(newlocale(LC_NUMERIC_MASK, "C",
>> duplocale(LC_GLOBAL_LOCALE)));
>> +
>> + Glib::KeyFile keyFile;
>> +
>
>
>