Change parameter names *offset to *_offset Do not crash if NULL pointers
authorPadraig O'Briain <padraigo@src.gnome.org>
Fri, 17 Aug 2001 14:34:21 +0000 (14:34 +0000)
committerPadraig O'Briain <padraigo@src.gnome.org>
Fri, 17 Aug 2001 14:34:21 +0000 (14:34 +0000)
* docs/tmpl/atktext.sgml atk/atktext.h:
Change parameter names *offset to *_offset
* atk/atkcomponent.c:
Do not crash if NULL pointers are passed for return values
* atk/atktext.c:
Change parameter names *offset to *_offset
Do not crash if NULL pointers are passed for return values

ChangeLog
atk/atkcomponent.c
atk/atktext.c
atk/atktext.h
docs/tmpl/atktext.sgml

index 91de638..2c5fc73 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2001-08-17  Padraig O'Briain  <padraig.obriain@sun.com>
+
+       * docs/tmpl/atktext.sgml atk/atktext.h:
+       Change parameter names *offset to *_offset
+       * atk/atkcomponent.c:
+       Do not crash if NULL pointers are passed for return values
+       * atk/atktext.c:
+       Change parameter names *offset to *_offset
+       Do not crash if NULL pointers are passed for return values
+       
 2001-08-16  Bill Haneman  <bill.haneman@sun.com>
 
         * atk/atkutil.c :
index 961a68e..dd568b8 100755 (executable)
@@ -199,12 +199,32 @@ atk_component_get_extents    (AtkComponent    *component,
                               AtkCoordType    coord_type)
 {
   AtkComponentIface *iface = NULL;
+  gint local_x, local_y, local_width, local_height;
+  gint *real_x, *real_y, *real_width, *real_height;
+
   g_return_if_fail (ATK_IS_COMPONENT (component));
 
+  if (x)
+    real_x = x;
+  else
+    real_x = &local_x;
+  if (y)
+    real_y = y;
+  else
+    real_y = &local_y;
+  if (width)
+    real_width = width;
+  else
+    real_width = &local_width;
+  if (height)
+    real_height = height;
+  else
+    real_height = &local_height;
+
   iface = ATK_COMPONENT_GET_IFACE (component);
 
   if (iface->get_extents)
-    (iface->get_extents) (component, x, y, width, height, coord_type);
+    (iface->get_extents) (component, real_x, real_y, real_width, real_height, coord_type);
 }
 
 /**
@@ -225,18 +245,30 @@ atk_component_get_position   (AtkComponent    *component,
                               AtkCoordType    coord_type)
 {
   AtkComponentIface *iface = NULL;
+  gint local_x, local_y;
+  gint *real_x, *real_y;
+
   g_return_if_fail (ATK_IS_COMPONENT (component));
 
+  if (x)
+    real_x = x;
+  else
+    real_x = &local_x;
+  if (y)
+    real_y = y;
+  else
+    real_y = &local_y;
+
   iface = ATK_COMPONENT_GET_IFACE (component);
 
   if (iface->get_position)
-    (iface->get_position) (component, x, y, coord_type);
+    (iface->get_position) (component, real_x, real_y, coord_type);
   else
   {
     /*
      * if this method is not overridden use the default implementation.
      */
-    atk_component_real_get_position (component, x, y, coord_type);
+    atk_component_real_get_position (component, real_x, real_y, coord_type);
   }
 }
 
@@ -254,18 +286,33 @@ atk_component_get_size       (AtkComponent    *component,
                               gint            *height)
 {
   AtkComponentIface *iface = NULL;
+  gint local_width, local_height;
+  gint *real_width, *real_height;
+
+  g_return_if_fail (ATK_IS_COMPONENT (component));
+
+  if (width)
+    real_width = width;
+  else
+    real_width = &local_width;
+  if (height)
+    real_height = height;
+  else
+    real_height = &local_height;
+
+  iface = ATK_COMPONENT_GET_IFACE (component);
   g_return_if_fail (ATK_IS_COMPONENT (component));
 
   iface = ATK_COMPONENT_GET_IFACE (component);
 
   if (iface->get_size)
-    (iface->get_size) (component, width, height);
+    (iface->get_size) (component, real_width, real_height);
   else
   {
     /*
      * if this method is not overridden use the default implementation.
      */
-    atk_component_real_get_size (component, width, height);
+    atk_component_real_get_size (component, real_width, real_height);
   }
 }
 
index 69f6685..ebe83bb 100755 (executable)
@@ -112,7 +112,7 @@ atk_text_get_text (AtkText      *text,
                    gint         end_offset)
 {
   AtkTextIface *iface;
-
+  
   g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
 
   iface = ATK_TEXT_GET_IFACE (text);
@@ -153,8 +153,8 @@ atk_text_get_character_at_offset (AtkText      *text,
  * @text: an #AtkText
  * @offset: position
  * @boundary_type: An #AtkTextBoundary
- * @startOffset: the start offset of the returned string.
- * @endOffset: the end offset of the returned string.
+ * @start_offset: the start offset of the returned string.
+ * @end_offset: the end offset of the returned string.
  *
  * Gets the specified text.
  * If the boundary type is ATK_TEXT_BOUNDARY_WORD_START or
@@ -171,17 +171,28 @@ gchar*
 atk_text_get_text_after_offset (AtkText          *text,
                                 gint             offset,
                                 AtkTextBoundary  boundary_type,
-                               gint             *startOffset,
-                               gint             *endOffset)
+                               gint             *start_offset,
+                               gint             *end_offset)
 {
   AtkTextIface *iface;
+  gint local_start_offset, local_end_offset;
+  gint *real_start_offset, *real_end_offset;
 
   g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
 
+  if (start_offset)
+    real_start_offset = start_offset;
+  else
+    real_start_offset = &local_start_offset;
+  if (end_offset)
+    real_end_offset = end_offset;
+  else
+    real_end_offset = &local_end_offset;
+
   iface = ATK_TEXT_GET_IFACE (text);
 
   if (iface->get_text_after_offset)
-    return (*(iface->get_text_after_offset)) (text, offset, boundary_type, startOffset, endOffset);
+    return (*(iface->get_text_after_offset)) (text, offset, boundary_type, real_start_offset, real_end_offset);
   else
     return NULL;
 }
@@ -191,8 +202,8 @@ atk_text_get_text_after_offset (AtkText          *text,
  * @text: an #AtkText
  * @offset: position
  * @boundary_type: An #AtkTextBoundary
- * @startOffset: the start offset of the returned string.
- * @endOffset: the end offset of the returned string.
+ * @start_offset: the start offset of the returned string.
+ * @end_offset: the end offset of the returned string.
  *
  * Gets the specified text.
  * If the boundary_type is ATK_TEXT_BOUNDARY_WORD_START or 
@@ -208,17 +219,28 @@ gchar*
 atk_text_get_text_at_offset (AtkText          *text,
                              gint             offset,
                              AtkTextBoundary  boundary_type,
-                            gint             *startOffset,
-                            gint             *endOffset)
+                            gint             *start_offset,
+                            gint             *end_offset)
 {
   AtkTextIface *iface;
+  gint local_start_offset, local_end_offset;
+  gint *real_start_offset, *real_end_offset;
 
   g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
 
+  if (start_offset)
+    real_start_offset = start_offset;
+  else
+    real_start_offset = &local_start_offset;
+  if (end_offset)
+    real_end_offset = end_offset;
+  else
+    real_end_offset = &local_end_offset;
+
   iface = ATK_TEXT_GET_IFACE (text);
 
   if (iface->get_text_at_offset)
-    return (*(iface->get_text_at_offset)) (text, offset, boundary_type, startOffset, endOffset);
+    return (*(iface->get_text_at_offset)) (text, offset, boundary_type, real_start_offset, real_end_offset);
   else
     return NULL;
 }
@@ -228,8 +250,8 @@ atk_text_get_text_at_offset (AtkText          *text,
  * @text: an #AtkText
  * @offset: position
  * @boundary_type: An #AtkTextBoundary
- * @startOffset: the start offset of the returned string.
- * @endOffset: the end offset of the returned string.
+ * @start_offset: the start offset of the returned string.
+ * @end_offset: the end offset of the returned string.
  *
  * Gets the specified text.
  * If the boundary type is ATK_TEXT_BOUNDARY_WORD_START or
@@ -246,17 +268,28 @@ gchar*
 atk_text_get_text_before_offset (AtkText          *text,
                                  gint             offset,
                                  AtkTextBoundary  boundary_type,
-                                gint             *startOffset,
-                                gint             *endOffset)
+                                gint             *start_offset,
+                                gint             *end_offset)
 {
   AtkTextIface *iface;
+  gint local_start_offset, local_end_offset;
+  gint *real_start_offset, *real_end_offset;
 
   g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
 
+  if (start_offset)
+    real_start_offset = start_offset;
+  else
+    real_start_offset = &local_start_offset;
+  if (end_offset)
+    real_end_offset = end_offset;
+  else
+    real_end_offset = &local_end_offset;
+
   iface = ATK_TEXT_GET_IFACE (text);
 
   if (iface->get_text_before_offset)
-    return (*(iface->get_text_before_offset)) (text, offset, boundary_type, startOffset, endOffset);
+    return (*(iface->get_text_before_offset)) (text, offset, boundary_type, real_start_offset, real_end_offset);
   else
     return NULL;
 }
@@ -307,19 +340,38 @@ atk_text_get_character_extents (AtkText *text,
                                AtkCoordType coords)
 {
   AtkTextIface *iface;
+  gint local_x, local_y, local_width, local_height;
+  gint *real_x, *real_y, *real_width, *real_height;
 
   g_return_if_fail (ATK_IS_TEXT (text));
 
+  if (x)
+    real_x = x;
+  else
+    real_x = &local_x;
+  if (y)
+    real_y = y;
+  else
+    real_y = &local_y;
+  if (width)
+    real_width = width;
+  else
+    real_width = &local_width;
+  if (height)
+    real_height = height;
+  else
+    real_height = local_height;
+
   iface = ATK_TEXT_GET_IFACE (text);
 
   if (iface->get_character_extents)
-    (*(iface->get_character_extents)) (text, offset, x, y, width, height, coords);
+    (*(iface->get_character_extents)) (text, offset, real_x, real_y, real_width, real_height, coords);
   else
     {
-      *x = 0;
-      *x = 0;
-      *width = 0;
-      *height = 0;
+      *real_x = 0;
+      *real_y = 0;
+      *real_width = 0;
+      *real_height = 0;
     }
 }
 
@@ -346,13 +398,24 @@ AtkAttributeSet* atk_text_ref_run_attributes              (AtkText          *tex
                                                            gint             *end_offset)
 {
   AtkTextIface *iface;
+  gint local_start_offset, local_end_offset;
+  gint *real_start_offset, *real_end_offset;
 
   g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
 
+  if (start_offset)
+    real_start_offset = start_offset;
+  else
+    real_start_offset = &local_start_offset;
+  if (end_offset)
+    real_end_offset = end_offset;
+  else
+    real_start_offset = &local_end_offset;
+
   iface = ATK_TEXT_GET_IFACE (text);
 
   if (iface->ref_run_attributes)
-    return (*(iface->ref_run_attributes)) (text, offset, start_offset, end_offset);
+    return (*(iface->ref_run_attributes)) (text, offset, real_start_offset, real_end_offset);
   else
     return NULL;
 }
@@ -453,19 +516,32 @@ atk_text_get_n_selections (AtkText *text)
  * Returns: the selected text.
  **/
 gchar*
-atk_text_get_selection (AtkText *text, gint selection_num,
-   gint *start_offset, gint *end_offset)
+atk_text_get_selection (AtkText *text, 
+                        gint    selection_num,
+                        gint    *start_offset,
+                        gint    *end_offset)
 {
   AtkTextIface *iface;
+  gint local_start_offset, local_end_offset;
+  gint *real_start_offset, *real_end_offset;
 
   g_return_val_if_fail (ATK_IS_TEXT (text), NULL);
 
+  if (start_offset)
+    real_start_offset = start_offset;
+  else
+    real_start_offset = &local_start_offset;
+  if (end_offset)
+    real_end_offset = end_offset;
+  else
+    real_start_offset = &local_end_offset;
+
   iface = ATK_TEXT_GET_IFACE (text);
 
   if (iface->get_selection)
   {
     return (*(iface->get_selection)) (text, selection_num,
-       start_offset, end_offset);
+       real_start_offset, real_end_offset);
   }
   else
     return NULL;
@@ -482,8 +558,9 @@ atk_text_get_selection (AtkText *text, gint selection_num,
  * Returns: %TRUE if success, %FALSE otherwise
  **/
 gboolean
-atk_text_add_selection (AtkText *text, gint start_offset,
-   gint end_offset)
+atk_text_add_selection (AtkText *text, 
+                        gint    start_offset,
+                        gint    end_offset)
 {
   AtkTextIface *iface;
 
@@ -511,7 +588,8 @@ atk_text_add_selection (AtkText *text, gint start_offset,
  * Returns: %TRUE if success, %FALSE otherwise
  **/
 gboolean
-atk_text_remove_selection (AtkText *text, gint selection_num)
+atk_text_remove_selection (AtkText *text, 
+                           gint    selection_num)
 {
   AtkTextIface *iface;
 
@@ -541,8 +619,10 @@ atk_text_remove_selection (AtkText *text, gint selection_num)
  * Returns: %TRUE if success, %FALSE otherwise
  **/
 gboolean
-atk_text_set_selection (AtkText *text, gint selection_num,
-   gint start_offset, gint end_offset)
+atk_text_set_selection (AtkText *text, 
+                        gint    selection_num,
+                        gint    start_offset, 
+                        gint    end_offset)
 {
   AtkTextIface *iface;
 
index f01aeb7..ca3ddab 100755 (executable)
@@ -310,20 +310,20 @@ struct _AtkTextIface
   gchar*         (* get_text_after_offset)        (AtkText          *text,
                                                    gint             offset,
                                                    AtkTextBoundary  boundary_type,
-                                                  gint             *startOffset,
-                                                  gint             *endOffset);
+                                                  gint             *start_offset,
+                                                  gint             *end_offset);
   gchar*         (* get_text_at_offset)           (AtkText          *text,
                                                    gint             offset,
                                                    AtkTextBoundary  boundary_type,
-                                                  gint             *startOffset,
-                                                  gint             *endOffset);
+                                                  gint             *start_offset,
+                                                  gint             *end_offset);
   gunichar       (* get_character_at_offset)      (AtkText          *text,
                                                    gint             offset);
   gchar*         (* get_text_before_offset)       (AtkText          *text,
                                                    gint             offset,
                                                    AtkTextBoundary  boundary_type,
-                                                  gint             *startOffset,
-                                                  gint             *endOffset);
+                                                  gint             *start_offset,
+                                                  gint             *end_offset);
   gint           (* get_caret_offset)             (AtkText          *text);
   AtkAttributeSet* (* ref_run_attributes)         (AtkText         *text,
                                                   gint             offset,
@@ -384,18 +384,18 @@ gunichar      atk_text_get_character_at_offset            (AtkText          *tex
 gchar*        atk_text_get_text_after_offset              (AtkText          *text,
                                                            gint             offset,
                                                            AtkTextBoundary  boundary_type,
-                                                          gint             *startOffset,
-                                                          gint             *endOffset);
+                                                          gint             *start_offset,
+                                                          gint             *end_offset);
 gchar*        atk_text_get_text_at_offset                 (AtkText          *text,
                                                            gint             offset,
                                                            AtkTextBoundary  boundary_type,
-                                                          gint             *startOffset,
-                                                          gint             *endOffset);
+                                                          gint             *start_offset,
+                                                          gint             *end_offset);
 gchar*        atk_text_get_text_before_offset             (AtkText          *text,
                                                            gint             offset,
                                                            AtkTextBoundary  boundary_type,
-                                                          gint             *startOffset,
-                                                          gint             *endOffset);
+                                                          gint             *start_offset,
+                                                          gint             *end_offset);
 gint          atk_text_get_caret_offset                   (AtkText          *text);
 void          atk_text_get_character_extents              (AtkText          *text,
                                                            gint             offset,
index 36986a9..34ee666 100644 (file)
@@ -101,9 +101,12 @@ AtkText
 @text: 
 @offset: 
 @boundary_type: 
+@start_offset: 
+@end_offset: 
+@Returns: 
+<!-- # Unused Parameters # -->
 @startOffset: 
 @endOffset: 
-@Returns: 
 
 
 <!-- ##### FUNCTION atk_text_get_text_at_offset ##### -->
@@ -114,9 +117,12 @@ AtkText
 @text: 
 @offset: 
 @boundary_type: 
+@start_offset: 
+@end_offset: 
+@Returns: 
+<!-- # Unused Parameters # -->
 @startOffset: 
 @endOffset: 
-@Returns: 
 
 
 <!-- ##### FUNCTION atk_text_get_text_before_offset ##### -->
@@ -127,9 +133,12 @@ AtkText
 @text: 
 @offset: 
 @boundary_type: 
+@start_offset: 
+@end_offset: 
+@Returns: 
+<!-- # Unused Parameters # -->
 @startOffset: 
 @endOffset: 
-@Returns: 
 
 
 <!-- ##### FUNCTION atk_text_get_caret_offset ##### -->