diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c index 06ab4107ee..7ed026c0a7 100644 --- a/gtk/gtkbuilder.c +++ b/gtk/gtkbuilder.c @@ -239,7 +239,7 @@ #include "config.h" #include /* errno */ -#include /* strtol, strtoul */ +#include #include /* strlen */ #include "gtkbuilder.h" @@ -1451,9 +1451,9 @@ gtk_builder_value_from_string_type (GtkBuilder *builder, case G_TYPE_LONG: { long l; - gchar *endptr; + gchar *endptr = NULL; errno = 0; - l = strtol (string, &endptr, 0); + l = g_ascii_strtoll (string, &endptr, 0); if (errno || endptr == string) { g_set_error (error, @@ -1474,9 +1474,9 @@ gtk_builder_value_from_string_type (GtkBuilder *builder, case G_TYPE_ULONG: { gulong ul; - gchar *endptr; + gchar *endptr = NULL; errno = 0; - ul = strtoul (string, &endptr, 0); + ul = g_ascii_strtoull (string, &endptr, 0); if (errno || endptr == string) { g_set_error (error, @@ -1520,7 +1520,7 @@ gtk_builder_value_from_string_type (GtkBuilder *builder, case G_TYPE_DOUBLE: { gdouble d; - gchar *endptr; + gchar *endptr = NULL; errno = 0; d = g_ascii_strtod (string, &endptr); if (errno || endptr == string) @@ -1676,8 +1676,10 @@ _gtk_builder_enum_from_string (GType type, ret = TRUE; - value = strtoul (string, &endptr, 0); - if (endptr != string) /* parsed a number */ + endptr = NULL; + errno = 0; + value = g_ascii_strtoull (string, &endptr, 0); + if (errno == 0 && endptr != string) /* parsed a number */ *enum_value = value; else { @@ -1723,9 +1725,11 @@ _gtk_builder_flags_from_string (GType type, g_return_val_if_fail (string != 0, FALSE); ret = TRUE; - - value = strtoul (string, &endptr, 0); - if (endptr != string) /* parsed a number */ + + endptr = NULL; + errno = 0; + value = g_ascii_strtoull (string, &endptr, 0); + if (errno == 0 && endptr != string) /* parsed a number */ *flags_value = value; else { diff --git a/gtk/gtkcelllayout.c b/gtk/gtkcelllayout.c index 86e8e39644..8388b5f7d5 100644 --- a/gtk/gtkcelllayout.c +++ b/gtk/gtkcelllayout.c @@ -335,9 +335,9 @@ attributes_text_element (GMarkupParseContext *context, if (!parser_data->attr_name) return; - errno = 0; string = g_strndup (text, text_len); - l = strtol (string, &endptr, 0); + errno = 0; + l = g_ascii_strtoll (string, &endptr, 0); if (errno || endptr == string) { g_set_error (error, diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c index 86e28e320d..cf9592710a 100644 --- a/gtk/gtkdialog.c +++ b/gtk/gtkdialog.c @@ -1357,7 +1357,7 @@ gtk_dialog_buildable_custom_finished (GtkBuildable *buildable, } ad = get_response_data (GTK_WIDGET (object), TRUE); - ad->response_id = atoi (item->response_id); + ad->response_id = g_ascii_strtoll (item->response_id, NULL, 10); if (GTK_IS_BUTTON (object)) signal_id = g_signal_lookup ("clicked", GTK_TYPE_BUTTON); diff --git a/gtk/gtktextbufferserialize.c b/gtk/gtktextbufferserialize.c index 04f684bd4f..16a36d3994 100644 --- a/gtk/gtktextbufferserialize.c +++ b/gtk/gtktextbufferserialize.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "gdk-pixbuf/gdk-pixdata.h" #include "gtktextbufferserialize.h" @@ -113,9 +114,10 @@ deserialize_value (const gchar *str, gchar *tmp; int v; - v = strtol (str, &tmp, 10); + errno = 0; + v = g_ascii_strtoll (str, &tmp, 10); - if (tmp == NULL || tmp == str) + if (errno || tmp == NULL || tmp == str) return FALSE; g_value_set_int (value, v); @@ -143,26 +145,32 @@ deserialize_value (const gchar *str, gchar *tmp; old = str; - color.red = strtol (old, &tmp, 16); + tmp = NULL; + errno = 0; + color.red = g_ascii_strtoll (old, &tmp, 16); - if (tmp == NULL || tmp == old) + if (errno || tmp == old) return FALSE; old = tmp; if (*old++ != ':') return FALSE; - color.green = strtol (old, &tmp, 16); - if (tmp == NULL || tmp == old) + tmp = NULL; + errno = 0; + color.green = g_ascii_strtoll (old, &tmp, 16); + if (errno || tmp == old) return FALSE; old = tmp; if (*old++ != ':') return FALSE; - color.blue = strtol (old, &tmp, 16); + tmp = NULL; + errno = 0; + color.blue = g_ascii_strtoll (old, &tmp, 16); - if (tmp == NULL || tmp == old || *tmp != '\0') + if (errno || tmp == old || *tmp != '\0') return FALSE; g_value_set_boxed (value, &color); @@ -836,9 +844,11 @@ check_id_or_name (GMarkupParseContext *context, has_id = TRUE; /* Try parsing the integer */ - *id = strtol (attribute_values[i], &tmp, 10); + tmp = NULL; + errno = 0; + *id = g_ascii_strtoll (attribute_values[i], &tmp, 10); - if (tmp == NULL || tmp == attribute_values[i]) + if (errno || tmp == attribute_values[i]) { set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, @@ -1291,9 +1301,11 @@ parse_tag_element (GMarkupParseContext *context, } } - prio = strtol (priority, &tmp, 10); + tmp = NULL; + errno = 0; + prio = g_ascii_strtoll (priority, &tmp, 10); - if (tmp == NULL || tmp == priority) + if (errno || tmp == priority) { set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index fb63d1c4d2..216054cbcd 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -531,9 +531,10 @@ extract_time_from_startup_id (const gchar* startup_id) /* Skip past the "_TIME" part */ timestr += 5; + end = NULL; errno = 0; - timestamp = strtoul (timestr, &end, 0); - if (end != timestr && errno == 0) + timestamp = g_ascii_strtoull (timestr, &end, 0); + if (errno == 0 && end != timestr) retval = timestamp; }