#include "config.h"
+#define __G_STRFUNCS_C__
#define _GNU_SOURCE /* For stpcpy */
#include <stdarg.h>
else
new_str = NULL;
+ g_mem_mark_type (new_str, G_MEM_TYPE_STRING, 0);
return new_str;
}
else
new_str = NULL;
+ g_mem_mark_type (new_str, G_MEM_TYPE_STRING, 0);
return new_str;
}
g_vasprintf (&string, format, args);
+ g_mem_mark_type (string, G_MEM_TYPE_STRING, 0);
return string;
}
decimal_point[1] != 0)
{
p = nptr;
+
/* Skip leading space */
while (g_ascii_isspace (*p))
p++;
{
p = buffer;
+ while (g_ascii_isspace (*p))
+ p++;
+
if (*p == '+' || *p == '-')
p++;
result = g_strndup (str, len);
for (s = result; *s; s++)
*s = g_ascii_tolower (*s);
-
+
+ g_mem_mark_type (result, G_MEM_TYPE_STRING, 0);
return result;
}
for (s = result; *s; s++)
*s = g_ascii_toupper (*s);
+ g_mem_mark_type (result, G_MEM_TYPE_STRING, 0);
return result;
}
#include <stdlib.h>
#include <math.h>
+static char *locales[] = {"sv_SE", "en_US", "fa_IR", "C", "ru_RU"};
+
void
test_string (char *number, double res, gboolean check_end, int correct_len)
{
double d;
- char *locales[] = {"sv_SE", "en_US", "fa_IR", "C", "ru_RU"};
int l;
char *dummy;
}
+static void
+test_number (gdouble num, gchar *fmt, gchar *str)
+{
+ int l;
+ gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
+
+ for (l = 0; l < G_N_ELEMENTS (locales); l++)
+ {
+ g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, fmt, num);
+ g_assert (strcmp (buf, str) == 0);
+ }
+}
+
int
main ()
{
d = -pow (2.0, -1024.1);
g_assert (d == g_ascii_strtod (g_ascii_dtostr (buffer, sizeof (buffer), d), NULL));
-
+ /* for #343899 */
+ test_string (" 0.75", 0.75, FALSE, 0);
+ test_string (" +0.75", 0.75, FALSE, 0);
+ test_string (" -0.75", -0.75, FALSE, 0);
+ test_string ("\f0.75", 0.75, FALSE, 0);
+ test_string ("\n0.75", 0.75, FALSE, 0);
+ test_string ("\r0.75", 0.75, FALSE, 0);
+ test_string ("\t0.75", 0.75, FALSE, 0);
+#if 0
+ /* g_ascii_isspace() returns FALSE for vertical tab, see #59388 */
+ test_string ("\v0.75", 0.75, FALSE, 0);
+#endif
+
+ /* for #343899 */
+ test_number (0.75, "%0.2f", "0.75");
+ test_number (0.75, "%5.2f", " 0.75");
+ test_number (-0.75, "%0.2f", "-0.75");
+ test_number (-0.75, "%5.2f", "-0.75");
+ test_number (1e99, "%.0e", "1e+99");
return 0;
}