Skip to content
Snippets Groups Projects
Commit 3ad05a07 authored by Anthony Léonard's avatar Anthony Léonard Committed by Philippe Gorley
Browse files

contrib: add restbed patch fixing locale issues


On MacOS, if the language is set to one not using dots to separate
integer and fractional part of a number (like french using a comma),
a bad HTTP version is sent when dealing with the name server. It
prevents registering a username and using one to add a friend in the
contact list.

This patch resets the locale to "C" before attempting to convert HTTP
version from a double to a char* thus enforcing the use of a dot in
the request. The locale is then restored to its old value then
preserving any modification done elsewhere.

Change-Id: I5b116294c428f626e03885b54950c868211e587e
Reviewed-by: default avatarPhilippe Gorley <philippe.gorley@savoirfairelinux.com>
parent a5a91a2a
No related branches found
No related tags found
No related merge requests found
...@@ -45,6 +45,7 @@ restbed: restbed-$(RESTBED_VERSION).tar.gz ...@@ -45,6 +45,7 @@ restbed: restbed-$(RESTBED_VERSION).tar.gz
$(APPLY) $(SRC)/restbed/strand.patch $(APPLY) $(SRC)/restbed/strand.patch
$(APPLY) $(SRC)/restbed/uri_cpp.patch $(APPLY) $(SRC)/restbed/uri_cpp.patch
$(APPLY) $(SRC)/restbed/dns-resolution-error.patch $(APPLY) $(SRC)/restbed/dns-resolution-error.patch
$(APPLY) $(SRC)/restbed/string.patch
$(MOVE) $(MOVE)
.restbed: restbed toolchain.cmake .restbed: restbed toolchain.cmake
......
--- a/source/corvusoft/restbed/string.cpp 2016-09-14 20:58:54.000000000 -0400
+++ b/source/corvusoft/restbed/string.cpp 2017-06-27 10:17:55.000000000 -0400
@@ -7,6 +7,7 @@
#include <memory>
#include <ciso646>
#include <algorithm>
+#include <cstdlib>
//Project Includes
#include "corvusoft/restbed/string.hpp"
@@ -161,8 +162,14 @@
string::size_type String::format( string& output, const string::size_type length, const char* format, va_list arguments )
{
unique_ptr< char[ ] > formatted( new char[ length + 1 ] );
+
+ char* saved_locale = strdup(setlocale(LC_NUMERIC, NULL));
+ setlocale(LC_NUMERIC, "C");
int required_length = vsnprintf( formatted.get( ), length + 1, format, arguments );
+
+ setlocale(LC_NUMERIC, saved_locale);
+ free(saved_locale);
if ( required_length == -1 )
{
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment