remove unused return value
[pspp-builds.git] / lib / gtk-contrib / psppire-sheet.c
index dc0f4080ec36d5629a19327312f3168b5f1a55d7..6703f0b67e0806e101d3a751b2c2f1bfd758f8ab 100644 (file)
@@ -54,8 +54,6 @@
 #include <config.h>
 
 #include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
 #include <glib.h>
 #include <gdk/gdk.h>
 #include <gdk/gdkkeysyms.h>
@@ -72,8 +70,6 @@
 #include <ui/gui/sheet/psppire-axis.h>
 #include <libpspp/misc.h>
 
-#include <math.h>
-
 /* sheet flags */
 enum
   {
@@ -391,30 +387,33 @@ POSSIBLE_RESIZE (const PsppireSheet *sheet, gint x, gint y,
 }
 
 
-static gboolean
-rectangle_from_range (PsppireSheet *sheet, const PsppireSheetRange *input,
+static void
+rectangle_from_range (PsppireSheet *sheet, const PsppireSheetRange *range,
                      GdkRectangle *r)
 {
-  PsppireSheetRange range = *input;
+  gint col0 = MIN (range->col0, range->coli);
+  gint coli = MAX (range->col0, range->coli);
+  gint row0 = MIN (range->row0, range->rowi);
+  gint rowi = MAX (range->row0, range->rowi);
 
-  if ( range.row0 == -1 ) range.row0 = min_visible_row (sheet);
-  if ( range.rowi == -1 ) range.rowi = max_visible_row (sheet);
-  if ( range.col0 == -1 ) range.col0 = min_visible_column (sheet);
-  if ( range.coli == -1 ) range.coli = max_visible_column (sheet);
+  if ( row0 == -1 ) row0 = min_visible_row (sheet);
+  if ( rowi == -1 ) rowi = max_visible_row (sheet);
+  if ( col0 == -1 ) col0 = min_visible_column (sheet);
+  if ( coli == -1 ) coli = max_visible_column (sheet);
 
-  r->x = psppire_axis_start_pixel (sheet->haxis, range.col0);
+  r->x = psppire_axis_start_pixel (sheet->haxis, col0);
   r->x -= round (sheet->hadjustment->value);
 
-  r->y = psppire_axis_start_pixel (sheet->vaxis, range.row0);
+  r->y = psppire_axis_start_pixel (sheet->vaxis, row0);
   r->y -= round (sheet->vadjustment->value);
 
-  r->width = psppire_axis_start_pixel (sheet->haxis, range.coli) -
-    psppire_axis_start_pixel (sheet->haxis, range.col0) +
-    psppire_axis_unit_size (sheet->haxis, range.coli);
+  r->width = psppire_axis_start_pixel (sheet->haxis, coli) -
+    psppire_axis_start_pixel (sheet->haxis, col0) +
+    psppire_axis_unit_size (sheet->haxis, coli);
 
-  r->height = psppire_axis_start_pixel (sheet->vaxis, range.rowi) -
-    psppire_axis_start_pixel (sheet->vaxis, range.row0) +
-    psppire_axis_unit_size (sheet->vaxis, range.rowi);
+  r->height = psppire_axis_start_pixel (sheet->vaxis, rowi) -
+    psppire_axis_start_pixel (sheet->vaxis, row0) +
+    psppire_axis_unit_size (sheet->vaxis, rowi);
 
   if ( sheet->column_titles_visible)
     {
@@ -425,22 +424,20 @@ rectangle_from_range (PsppireSheet *sheet, const PsppireSheetRange *input,
     {
       r->x += sheet->row_title_area.width;
     }
-
-  return TRUE;
 }
 
-static gboolean
+static void
 rectangle_from_cell (PsppireSheet *sheet, gint row, gint col,
                     GdkRectangle *r)
 {
   PsppireSheetRange range;
-  g_return_val_if_fail (row >= 0, FALSE);
-  g_return_val_if_fail (col >= 0, FALSE);
+  g_return_if_fail (row >= 0);
+  g_return_if_fail (col >= 0);
 
   range.row0 = range.rowi = row;
   range.col0 = range.coli = col;
 
-  return rectangle_from_range (sheet, &range, r);
+  rectangle_from_range (sheet, &range, r);
 }
 
 
@@ -2257,17 +2254,6 @@ draw_sheet_region (PsppireSheet *sheet, GdkRegion *region)
     psppire_sheet_show_entry_widget (sheet);
 }
 
-
-
-static inline gint
-safe_strcmp (const gchar *s1, const gchar *s2)
-{
-  if ( !s1 && !s2) return 0;
-  if ( !s1) return -1;
-  if ( !s2) return +1;
-  return strcmp (s1, s2);
-}
-
 static void
 psppire_sheet_set_cell (PsppireSheet *sheet, gint row, gint col,
                        GtkJustification justification,
@@ -2289,7 +2275,7 @@ psppire_sheet_set_cell (PsppireSheet *sheet, gint row, gint col,
 
   old_text = psppire_sheet_model_get_string (model, row, col);
 
-  if (0 != safe_strcmp (old_text, text))
+  if (0 != g_strcmp0 (old_text, text))
     {
       g_signal_handler_block    (sheet->model, sheet->update_handler_id);
       psppire_sheet_model_set_string (model, text, row, col);