]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtktextbufferserialize.c
gail: Fix scrollbar index_in_parent() implementation
[~andy/gtk] / gtk / gtktextbufferserialize.c
index 76040f25c34c35ddbb97a64d44d295af7a616484..e4b4f730060ad2c05ad7d6a5f4b065505d2b8d6f 100644 (file)
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <errno.h>
 
 #include "gdk-pixbuf/gdk-pixdata.h"
 #include "gtktextbufferserialize.h"
+#include "gtktexttagprivate.h"
 #include "gtkintl.h"
 
 
@@ -69,10 +71,6 @@ serialize_value (GValue *value)
 
       return g_strdup_printf ("%x:%x:%x", color->red, color->green, color->blue);
     }
-  else if (g_type_is_a (value->g_type, GDK_TYPE_DRAWABLE))
-    {
-      /* Don't do anything */
-    }
   else
     {
       g_warning ("Type %s is not serializable\n", g_type_name (value->g_type));
@@ -113,9 +111,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 +142,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);
@@ -288,9 +293,9 @@ serialize_tag (gpointer key,
   g_string_append (context->tag_table_str, "  <tag ");
 
   /* Handle anonymous tags */
-  if (tag->name)
+  if (tag->priv->name)
     {
-      tag_name = g_markup_escape_text (tag->name, -1);
+      tag_name = g_markup_escape_text (tag->priv->name, -1);
       g_string_append_printf (context->tag_table_str, "name=\"%s\"", tag_name);
       g_free (tag_name);
     }
@@ -301,7 +306,7 @@ serialize_tag (gpointer key,
       g_string_append_printf (context->tag_table_str, "id=\"%d\"", tag_id);
     }
 
-  g_string_append_printf (context->tag_table_str, " priority=\"%d\">\n", tag->priority);
+  g_string_append_printf (context->tag_table_str, " priority=\"%d\">\n", tag->priv->priority);
 
   /* Serialize properties */
   pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (tag), &n_pspecs);
@@ -485,9 +490,9 @@ serialize_text (GtkTextBuffer        *buffer,
          /* Add it to the tag hash table */
          g_hash_table_insert (context->tags, tag, tag);
 
-         if (tag->name)
+         if (tag->priv->name)
            {
-             tag_name = g_markup_escape_text (tag->name, -1);
+             tag_name = g_markup_escape_text (tag->priv->name, -1);
 
              g_string_append_printf (context->text_str, "<apply_tag name=\"%s\">", tag_name);
              g_free (tag_name);
@@ -836,13 +841,15 @@ 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,
-                        _("<%s> element has invalid id \"%s\""), attribute_values[i]);
+                        _("<%s> element has invalid ID \"%s\""), attribute_values[i]);
              return FALSE;
            }
        }
@@ -1291,9 +1298,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,
@@ -1473,10 +1482,10 @@ end_element_handler (GMarkupParseContext  *context,
       pop_state (info);
       g_assert (peek_state (info) == STATE_TAGS);
 
-      if (info->current_tag->name)
+      if (info->current_tag->priv->name)
        {
          /* Add tag to defined tags hash */
-         tmp = g_strdup (info->current_tag->name);
+         tmp = g_strdup (info->current_tag->priv->name);
          g_hash_table_insert (info->defined_tags,
                               tmp, tmp);
        }