Revert "Bug 28460 - Refactored dbus configuration access."
[platform/upstream/dbus.git] / dbus / dbus-sysdeps.c
index c27f999..bab516d 100644 (file)
@@ -22,6 +22,7 @@
  *
  */
 
+#include <config.h>
 #include "dbus-internals.h"
 #include "dbus-sysdeps.h"
 #include "dbus-threads.h"
@@ -34,7 +35,9 @@
  *
  * These are the standard ANSI C headers...
  */
+#if HAVE_LOCALE_H
 #include <locale.h>
+#endif
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
@@ -515,7 +518,7 @@ _dbus_string_parse_int (const DBusString *str,
                                        _dbus_string_get_length (str) - start);
 
   end = NULL;
-  errno = 0;
+  _dbus_set_errno_to_zero ();
   v = strtol (p, &end, 0);
   if (end == NULL || end == p || errno != 0)
     return FALSE;
@@ -554,7 +557,7 @@ _dbus_string_parse_uint (const DBusString *str,
                                        _dbus_string_get_length (str) - start);
 
   end = NULL;
-  errno = 0;
+  _dbus_set_errno_to_zero ();
   v = strtoul (p, &end, 0);
   if (end == NULL || end == p || errno != 0)
     return FALSE;
@@ -622,10 +625,14 @@ ascii_strtod (const char *nptr,
 
   fail_pos = NULL;
 
+#if HAVE_LOCALECONV
   locale_data = localeconv ();
   decimal_point = locale_data->decimal_point;
-  decimal_point_len = strlen (decimal_point);
+#else
+  decimal_point = ".";
+#endif
 
+  decimal_point_len = strlen (decimal_point);
   _dbus_assert (decimal_point_len != 0);
   
   decimal_point_pos = NULL;
@@ -692,7 +699,7 @@ ascii_strtod (const char *nptr,
 
   /* Set errno to zero, so that we can distinguish zero results
      and underflows */
-  errno = 0;
+  _dbus_set_errno_to_zero ();
   
   if (decimal_point_pos)
     {
@@ -766,7 +773,7 @@ _dbus_string_parse_double (const DBusString *str,
     return FALSE;
   
   end = NULL;
-  errno = 0;
+  _dbus_set_errno_to_zero ();
   v = ascii_strtod (p, &end);
   if (end == NULL || end == p || errno != 0)
     return FALSE;
@@ -987,12 +994,27 @@ _dbus_error_from_errno (int error_number)
 }
 
 /**
+ * Converts the current system errno value into a #DBusError name.
+ *
+ * @returns an error name
+ */
+const char*
+_dbus_error_from_system_errno (void)
+{
+  return _dbus_error_from_errno (errno);
+}
+
+/**
  * Assign 0 to the global errno variable
  */
 void
 _dbus_set_errno_to_zero (void)
 {
+#ifdef DBUS_WINCE
+  SetLastError (0);
+#else
   errno = 0;
+#endif
 }
 
 /**