[dia] general: logging patch from debian



commit a67db4890f859a660d88263102bd1f47d2c8cdba
Author: Zander Brown <zbrown gnome org>
Date:   Wed Oct 2 19:12:10 2019 +0100

    general: logging patch from debian
    
    
https://salsa.debian.org/debian/dia/blob/203ff6b37dfe29761069d0a83957db18d3f50ccc/debian/patches/errors-to-stderr.patch
    
    Close https://gitlab.gnome.org/GNOME/dia/merge_requests/11

 app/app_procs.c                  | 10 +++---
 app/display.c                    |  4 +--
 app/layer-editor/layer_dialog.c  |  4 +--
 app/load_save.c                  |  5 +--
 app/modify_tool.c                |  2 +-
 app/undo.c                       | 74 +++++++++++++++-------------------------
 lib/arrows.c                     |  4 +--
 lib/debug.c                      |  2 +-
 lib/dia_svg.c                    |  2 +-
 lib/dialib.c                     |  6 ++--
 lib/geometry.c                   |  4 +--
 lib/textline.c                   | 11 +++---
 objects/custom/shape_typeinfo.c  | 56 +++++++++++++++---------------
 objects/standard/arc.c           | 34 +++++++++---------
 plug-ins/dxf/dxf-import.c        |  9 +++--
 plug-ins/postscript/win32print.c | 18 +++++-----
 plug-ins/python/pydia-error.c    | 10 +++---
 plug-ins/xfig/xfig-import.c      | 35 +++++++++++--------
 tests/test-objects.c             | 16 +++++----
 19 files changed, 147 insertions(+), 159 deletions(-)
---
diff --git a/app/app_procs.c b/app/app_procs.c
index a53e4af4..434a092f 100644
--- a/app/app_procs.c
+++ b/app/app_procs.c
@@ -352,7 +352,7 @@ do_convert (const char      *infname,
     ef->export_func (diagdata, ctx, outfname, infname, ef->user_data);
   }
   /* if (!quiet) */
-  fprintf (stdout, _("%s --> %s\n"), infname, outfname);
+  g_printerr (_("%s --> %s\n"), infname, outfname);
   g_object_unref (diagdata);
   dia_context_release (ctx);
   return TRUE;
@@ -647,10 +647,10 @@ app_init (int argc, char **argv)
 
     if (!g_option_context_parse (context, &argc, &argv, &error)) {
       if (error) { /* IMO !error here is a bug upstream, triggered e.g. with --gdk-debug=updates */
-        g_print ("%s", error->message);
+        g_printerr ("%s", error->message);
         g_error_free (error);
       } else {
-        g_print (_("Invalid option?"));
+        g_printerr (_("Invalid option?"));
       }
 
       g_option_context_free(context);
@@ -674,7 +674,7 @@ app_init (int argc, char **argv)
         }
 
         if (!filename) {
-          g_print (_("Filename conversion failed: %s\n"), filenames[i]);
+          g_printerr (_("Filename conversion failed: %s\n"), filenames[i]);
           continue;
         }
 
@@ -688,7 +688,7 @@ app_init (int argc, char **argv)
         if (g_file_test (testpath, G_FILE_TEST_IS_REGULAR)) {
           files = g_slist_append (files, filename);
         } else {
-          g_print (_("Missing input: %s\n"), filename);
+          g_printerr (_("Missing input: %s\n"), filename);
           g_free (filename);
         }
         if (filename != testpath) {
diff --git a/app/display.c b/app/display.c
index add265e9..081382c3 100644
--- a/app/display.c
+++ b/app/display.c
@@ -478,7 +478,7 @@ ddisplay_render_pixmap (DDisplay     *ddisp,
 #endif
 
   if (ddisp->renderer==NULL) {
-    printf("ERROR! Renderer was NULL!!\n");
+    g_critical ("ERROR! Renderer was NULL!!");
     return;
   }
 
@@ -516,7 +516,7 @@ ddisplay_render_pixmap (DDisplay     *ddisp,
                ddisplay_obj_render,
                (gpointer) ddisp);
 #ifdef TRACES
-  g_print ("data_render(%g%%) took %g seconds\n", ddisp->zoom_factor * 5.0, g_timer_elapsed (timer, NULL));
+  g_printerr ("data_render(%g%%) took %g seconds\n", ddisp->zoom_factor * 5.0, g_timer_elapsed (timer, 
NULL));
   g_timer_destroy (timer);
 #endif
   /* Draw handles for all selected objects */
diff --git a/app/layer-editor/layer_dialog.c b/app/layer-editor/layer_dialog.c
index 9ad0af7e..68d7d853 100644
--- a/app/layer-editor/layer_dialog.c
+++ b/app/layer-editor/layer_dialog.c
@@ -309,8 +309,8 @@ dia_layer_visibility_change_revert (DiaChange *self,
   }
 
   if (vis != NULL || i < layers->len) {
-    printf("Internal error: visibility undo has %d visibilities, but %d layers\n",
-          g_list_length(change->original_visibility), layers->len);
+    g_printerr ("Internal error: visibility undo has %d visibilities, but %d layers\n",
+                g_list_length(change->original_visibility), layers->len);
   }
 
   diagram_add_update_all(dia);
diff --git a/app/load_save.c b/app/load_save.c
index a5d7a29c..e5315b34 100644
--- a/app/load_save.c
+++ b/app/load_save.c
@@ -1201,8 +1201,9 @@ diagram_cleanup_autosave(Diagram *dia)
   savefile = dia->autosavefilename;
   if (savefile == NULL) return;
 #ifdef TRACES
-  g_print("Cleaning up autosave %s for %s\n",
-          savefile, dia->filename ? dia->filename : "<no name>");
+  g_printerr ("Cleaning up autosave %s for %s\n",
+              savefile,
+              dia->filename ? dia->filename : "<no name>");
 #endif
   if (g_stat(savefile, &statbuf) == 0) { /* Success */
     g_unlink(savefile);
diff --git a/app/modify_tool.c b/app/modify_tool.c
index bdadf74d..0862bc31 100644
--- a/app/modify_tool.c
+++ b/app/modify_tool.c
@@ -113,7 +113,7 @@ gdk_event_to_dia_ModifierKeys(guint event_state)
 
   if (last_state != event_state) {
     last_state = event_state;
-    g_print ("%s%s%s,M%s%s%s%s%s,B%s%s%s%s%s,%s%s%s\n",
+    g_printerr ("%s%s%s,M%s%s%s%s%s,B%s%s%s%s%s,%s%s%s\n",
             event_state & GDK_SHIFT_MASK ? "Sh" : "  ",
             event_state & GDK_LOCK_MASK ? "Lo" : "  ",
             event_state & GDK_CONTROL_MASK ? "Co" : "  ",
diff --git a/app/undo.c b/app/undo.c
index bdc01958..0e035025 100644
--- a/app/undo.c
+++ b/app/undo.c
@@ -16,6 +16,8 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#define G_LOG_DOMAIN "DiaUndo"
+
 #include <config.h>
 
 #include "undo.h"
@@ -29,12 +31,6 @@
 #include "parent.h"
 #include "dia-layer.h"
 
-#if 0
-#define DEBUG_PRINTF(args) printf args
-#else
-#define DEBUG_PRINTF(args)
-#endif
-
 void undo_update_menus(UndoStack *stack);
 
 /**
@@ -107,7 +103,7 @@ undo_remove_redo_info(UndoStack *stack)
   DiaChange *change;
   DiaChange *next_change;
 
-  DEBUG_PRINTF(("UNDO: Removing redo info\n"));
+  g_debug ("Removing redo info");
 
   change = stack->current_change->next;
   stack->current_change->next = NULL;
@@ -127,7 +123,7 @@ undo_push_change(UndoStack *stack, DiaChange *change)
   if (stack->current_change != stack->last_change)
     undo_remove_redo_info(stack);
 
-  DEBUG_PRINTF(("UNDO: Push new change at %d\n", stack->depth));
+  g_debug ("Push %s at %d", DIA_CHANGE_TYPE_NAME (change), stack->depth);
 
   change->prev = stack->last_change;
   change->next = NULL;
@@ -158,14 +154,14 @@ undo_delete_lowest_transaction(UndoStack *stack)
       break;
 
     next_change = change->next;
-    DEBUG_PRINTF(("freeing one change from the bottom.\n"));
+    g_debug ("freeing one change from the bottom.");
     dia_change_unref (change);
     change = next_change;
   } while (!DIA_IS_TRANSACTION_POINT_CHANGE (change));
 
   if (DIA_IS_TRANSACTION_POINT_CHANGE (change)) {
     stack->depth--;
-    DEBUG_PRINTF(("Decreasing stack depth to: %d\n", stack->depth));
+    g_debug ("Decreasing stack depth to: %d", stack->depth);
   }
   if (change) /* play safe */
     change->prev = NULL;
@@ -179,13 +175,11 @@ undo_set_transactionpoint(UndoStack *stack)
   if (DIA_IS_TRANSACTION_POINT_CHANGE(stack->current_change))
     return;
 
-  DEBUG_PRINTF(("UNDO: Push new transactionpoint at %d\n", stack->depth));
-
   transaction = dia_transaction_point_change_new ();
 
   undo_push_change(stack, transaction);
   stack->depth++;
-  DEBUG_PRINTF(("Increasing stack depth to: %d\n", stack->depth));
+  g_debug ("Increasing stack depth to: %d", stack->depth);
 
   if (prefs.undo_depth > 0) {
     while (stack->depth > prefs.undo_depth){
@@ -212,7 +206,7 @@ undo_revert_to_last_tp(UndoStack *stack)
   stack->current_change  = change;
   stack->depth--;
   undo_update_menus(stack);
-  DEBUG_PRINTF(("Decreasing stack depth to: %d\n", stack->depth));
+  g_debug ("Decreasing stack depth to: %d", stack->depth);
 }
 
 void
@@ -237,7 +231,7 @@ undo_apply_to_next_tp(UndoStack *stack)
   stack->current_change = change;
   stack->depth++;
   undo_update_menus(stack);
-  DEBUG_PRINTF(("Increasing stack depth to: %d\n", stack->depth));
+  g_debug ("Increasing stack depth to: %d", stack->depth);
 }
 
 
@@ -246,7 +240,7 @@ undo_clear(UndoStack *stack)
 {
   DiaChange *change;
 
-  DEBUG_PRINTF(("undo_clear()\n"));
+  g_debug ("undo_clear()");
 
   change = stack->current_change;
 
@@ -447,7 +441,6 @@ dia_move_objects_change_new (Diagram *dia,
   change->dest_pos = dest_pos;
   change->obj_list = obj_list;
 
-  DEBUG_PRINTF(("UNDO: Push new move objects at %d\n", dia->undo->depth));
   undo_push_change (dia->undo, DIA_CHANGE (change));
 
   return DIA_CHANGE (change);
@@ -522,8 +515,6 @@ dia_move_handle_change_new (Diagram   *dia,
 
   change->modifiers = modifiers;
 
-  DEBUG_PRINTF(("UNDO: Push new move handle at %d\n", depth(dia->undo)));
-
   undo_push_change (dia->undo, DIA_CHANGE (change));
 
   return DIA_CHANGE (change);
@@ -597,7 +588,6 @@ dia_connect_change_new (Diagram         *dia,
   change->handle_pos = handle->pos;
   change->connectionpoint = connectionpoint;
 
-  DEBUG_PRINTF(("UNDO: Push new connect at %d\n", dia->undo->depth));
   undo_push_change (dia->undo, DIA_CHANGE (change));
 
   return DIA_CHANGE (change);
@@ -655,7 +645,6 @@ dia_unconnect_change_new (Diagram *dia, DiaObject *obj, Handle *handle)
   change->handle = handle;
   change->connectionpoint = handle->connected_to;
 
-  DEBUG_PRINTF(("UNDO: Push new unconnect at %d\n", dia->undo->depth));
   undo_push_change (dia->undo, DIA_CHANGE (change));
 
   return DIA_CHANGE (change);
@@ -683,7 +672,7 @@ dia_delete_objects_change_apply (DiaChange *self, Diagram *dia)
   DiaDeleteObjectsChange *change = DIA_DELETE_OBJECTS_CHANGE (self);
   GList *list;
 
-  DEBUG_PRINTF(("delete_objects_apply()\n"));
+  g_debug ("delete_objects_apply()");
   change->applied = 1;
   diagram_unselect_objects (dia, change->obj_list);
   dia_layer_remove_objects (change->layer, change->obj_list);
@@ -710,7 +699,7 @@ dia_delete_objects_change_revert (DiaChange *self, Diagram *dia)
   DiaDeleteObjectsChange *change = DIA_DELETE_OBJECTS_CHANGE (self);
   GList *list;
 
-  DEBUG_PRINTF(("delete_objects_revert()\n"));
+  g_debug ("delete_objects_revert()");
   change->applied = 0;
   dia_layer_set_object_list (change->layer,
                              g_list_copy (change->original_objects));
@@ -732,7 +721,7 @@ dia_delete_objects_change_free (DiaChange *self)
 {
   DiaDeleteObjectsChange *change = DIA_DELETE_OBJECTS_CHANGE (self);
 
-  DEBUG_PRINTF(("delete_objects_free()\n"));
+  g_debug ("delete_objects_free()");
   if (change->applied)
     destroy_object_list(change->obj_list);
   else
@@ -763,7 +752,6 @@ dia_delete_objects_change_new (Diagram *dia, GList *obj_list)
   change->original_objects = g_list_copy (dia_layer_get_object_list (dia->data->active_layer));
   change->applied = 0;
 
-  DEBUG_PRINTF(("UNDO: Push new delete objects at %d\n", dia->undo->depth));
   undo_push_change (dia->undo, DIA_CHANGE (change));
 
   return DIA_CHANGE (change);
@@ -789,7 +777,7 @@ dia_insert_objects_change_apply (DiaChange *self, Diagram *dia)
 {
   DiaInsertObjectsChange *change = DIA_INSERT_OBJECTS_CHANGE (self);
 
-  DEBUG_PRINTF (("insert_objects_apply()\n"));
+  g_debug ("insert_objects_apply()");
   change->applied = 1;
   dia_layer_add_objects (change->layer, g_list_copy (change->obj_list));
   object_add_updates_list (change->obj_list, dia);
@@ -801,7 +789,7 @@ dia_insert_objects_change_revert (DiaChange *self, Diagram *dia)
   DiaInsertObjectsChange *change = DIA_INSERT_OBJECTS_CHANGE (self);
   GList *list;
 
-  DEBUG_PRINTF(("insert_objects_revert()\n"));
+  g_debug ("insert_objects_revert()");
   change->applied = 0;
   diagram_unselect_objects (dia, change->obj_list);
   dia_layer_remove_objects (change->layer, change->obj_list);
@@ -824,7 +812,7 @@ dia_insert_objects_change_free (DiaChange *self)
 {
   DiaInsertObjectsChange *change = DIA_INSERT_OBJECTS_CHANGE (self);
 
-  DEBUG_PRINTF(("insert_objects_free()\n"));
+  g_debug ("insert_objects_free()");
   if (!change->applied)
     destroy_object_list(change->obj_list);
   else
@@ -841,7 +829,6 @@ dia_insert_objects_change_new (Diagram *dia, GList *obj_list, int applied)
   change->obj_list = obj_list;
   change->applied = applied;
 
-  DEBUG_PRINTF(("UNDO: Push new insert objects at %d\n", dia->undo->depth));
   undo_push_change (dia->undo, DIA_CHANGE (change));
 
   return DIA_CHANGE (change);
@@ -868,7 +855,7 @@ dia_reorder_objects_change_apply (DiaChange *self, Diagram *dia)
 {
   DiaReorderObjectsChange *change = DIA_REORDER_OBJECTS_CHANGE (self);
 
-  DEBUG_PRINTF (("reorder_objects_apply()\n"));
+  g_debug ("reorder_objects_apply()");
   dia_layer_set_object_list (change->layer,
                              g_list_copy (change->reordered_objects));
   object_add_updates_list (change->changed_list, dia);
@@ -880,7 +867,7 @@ dia_reorder_objects_change_revert (DiaChange *self, Diagram *dia)
 {
   DiaReorderObjectsChange *change = DIA_REORDER_OBJECTS_CHANGE (self);
 
-  DEBUG_PRINTF (("reorder_objects_revert()\n"));
+  g_debug ("reorder_objects_revert()");
   dia_layer_set_object_list (change->layer,
                              g_list_copy(change->original_objects));
   object_add_updates_list (change->changed_list, dia);
@@ -892,7 +879,7 @@ dia_reorder_objects_change_free (DiaChange *self)
 {
   DiaReorderObjectsChange *change = DIA_REORDER_OBJECTS_CHANGE (self);
 
-  DEBUG_PRINTF(("reorder_objects_free()\n"));
+  g_debug ("reorder_objects_free()");
   g_list_free(change->changed_list);
   g_list_free(change->original_objects);
   g_list_free(change->reordered_objects);
@@ -909,7 +896,6 @@ dia_reorder_objects_change_new (Diagram *dia, GList *changed_list, GList *orig_l
   change->original_objects = orig_list;
   change->reordered_objects = g_list_copy (dia_layer_get_object_list (DIA_DIAGRAM_DATA (dia)->active_layer));
 
-  DEBUG_PRINTF(("UNDO: Push new reorder objects at %d\n", dia->undo->depth));
   undo_push_change (dia->undo, DIA_CHANGE (change));
 
   return DIA_CHANGE (change);
@@ -997,7 +983,7 @@ dia_object_change_change_free (DiaChange *self)
 {
   DiaObjectChangeChange *change = DIA_OBJECT_CHANGE_CHANGE (self);
 
-  DEBUG_PRINTF(("state_change_free()\n"));
+  g_debug ("state_change_free()");
   if (change->obj_change->free)
     (*change->obj_change->free)(change->obj_change);
   g_free(change->obj_change);
@@ -1014,7 +1000,6 @@ dia_object_change_change_new (Diagram      *dia,
   change->obj = obj;
   change->obj_change = obj_change;
 
-  DEBUG_PRINTF(("UNDO: Push new obj_change at %d\n", dia->undo->depth));
   undo_push_change (dia->undo, DIA_CHANGE (change));
 
   return DIA_CHANGE (change);
@@ -1051,7 +1036,7 @@ dia_group_objects_change_apply (DiaChange *self, Diagram *dia)
 
   GList *list;
 
-  DEBUG_PRINTF(("group_objects_apply()\n"));
+  g_debug ("group_objects_apply()");
 
   change->applied = 1;
 
@@ -1080,7 +1065,7 @@ dia_group_objects_change_revert (DiaChange *self, Diagram *dia)
 {
   DiaGroupObjectsChange *change = DIA_GROUP_OBJECTS_CHANGE (self);
 
-  DEBUG_PRINTF (("group_objects_revert()\n"));
+  g_debug ("group_objects_revert()");
   change->applied = 0;
 
   diagram_unselect_object (dia, change->group);
@@ -1099,7 +1084,7 @@ dia_group_objects_change_free (DiaChange *self)
 {
   DiaGroupObjectsChange *change = DIA_GROUP_OBJECTS_CHANGE (self);
 
-  DEBUG_PRINTF(("group_objects_free()\n"));
+  g_debug ("group_objects_free()");
   if (!change->applied) {
     group_destroy_shallow(change->group);
     change->group = NULL;
@@ -1124,8 +1109,6 @@ dia_group_objects_change_new (Diagram   *dia,
   change->orig_list = orig_list;
   change->applied = 1;
 
-  DEBUG_PRINTF(("UNDO: Push new group objects at %d\n", dia->undo->depth));
-
   undo_push_change (dia->undo, DIA_CHANGE (change));
 
   return DIA_CHANGE (change);
@@ -1152,7 +1135,7 @@ dia_ungroup_objects_change_apply (DiaChange *self, Diagram *dia)
 {
   DiaUngroupObjectsChange *change = DIA_UNGROUP_OBJECTS_CHANGE (self);
 
-  DEBUG_PRINTF(("ungroup_objects_apply()\n"));
+  g_debug ("ungroup_objects_apply()");
 
   change->applied = 1;
 
@@ -1173,7 +1156,7 @@ dia_ungroup_objects_change_revert (DiaChange *self, Diagram *dia)
   DiaUngroupObjectsChange *change = DIA_UNGROUP_OBJECTS_CHANGE (self);
   GList *list;
 
-  DEBUG_PRINTF(("ungroup_objects_revert()\n"));
+  g_debug ("ungroup_objects_revert()");
   change->applied = 0;
 
 
@@ -1200,7 +1183,7 @@ dia_ungroup_objects_change_free (DiaChange *self)
 {
   DiaUngroupObjectsChange *change = DIA_UNGROUP_OBJECTS_CHANGE (self);
 
-  DEBUG_PRINTF(("ungroup_objects_free()\n"));
+  g_debug ("ungroup_objects_free()");
 
   if (change->applied) {
     group_destroy_shallow(change->group);
@@ -1224,8 +1207,8 @@ dia_ungroup_objects_change_new (Diagram   *dia,
   change->group_index = group_index;
   change->applied = 1;
 
-  DEBUG_PRINTF(("UNDO: Push new ungroup objects at %d\n", dia->undo->depth));
   undo_push_change (dia->undo, DIA_CHANGE (change));
+
   return DIA_CHANGE (change);
 }
 
@@ -1320,7 +1303,6 @@ dia_parenting_change_new (Diagram   *dia,
   parentchange->childobj = childobj;
   parentchange->parent = parent;
 
-  DEBUG_PRINTF (("UNDO: Push new obj_change at %d\n", dia->undo->depth));
   undo_push_change (dia->undo, DIA_CHANGE (parentchange));
 
   return DIA_CHANGE (parentchange);
@@ -1430,7 +1412,6 @@ dia_move_object_to_layer_change_new (Diagram  *dia,
   movetolayerchange->objects = g_list_copy (selected_list);
   movetolayerchange->moving_up = moving_up;
 
-  DEBUG_PRINTF (("UNDO: Push new obj_layer_change at %d\n", dia->undo->depth));
   undo_push_change (dia->undo, DIA_CHANGE (movetolayerchange));
 
   return DIA_CHANGE (movetolayerchange);
@@ -1657,7 +1638,6 @@ dia_mem_swap_change_new (Diagram *dia, gpointer dest, gsize size)
   for (i = 0; i < size; ++i)
     change->mem[i] = change->dest[i];
 
-  DEBUG_PRINTF(("UNDO: Push new memswap_change(%zd) at %d\n", size, dia->undo->depth));
   undo_push_change (dia->undo, DIA_CHANGE (change));
 
   return DIA_CHANGE (change);
diff --git a/lib/arrows.c b/lib/arrows.c
index 621fabc6..80889ddb 100644
--- a/lib/arrows.c
+++ b/lib/arrows.c
@@ -2510,7 +2510,7 @@ arrow_type_from_name(const gchar *name)
       return arrow_types[i].enum_value;
     }
   }
-  printf ("Unknown arrow type %s\n", name);
+  g_printerr ("Unknown arrow type %s\n", name);
   return 0;
 }
 
@@ -2533,7 +2533,7 @@ arrow_index_from_type (ArrowType atype)
       return i;
     }
   }
-  printf ("Can't find arrow index for type %d\n", atype);
+  g_printerr ("Can't find arrow index for type %d\n", atype);
   return 0;
 }
 
diff --git a/lib/debug.c b/lib/debug.c
index 6c1e739b..c3b8778a 100644
--- a/lib/debug.c
+++ b/lib/debug.c
@@ -41,7 +41,7 @@ dia_assert_true (gboolean val, const gchar *format, ...)
   va_list args;
   if (!val) {
     va_start (args, format);
-    g_vprintf (format, args);
+    g_vfprintf (stderr, format, args);
     va_end (args);
   }
   return val;
diff --git a/lib/dia_svg.c b/lib/dia_svg.c
index 90412357..7dbd5168 100644
--- a/lib/dia_svg.c
+++ b/lib/dia_svg.c
@@ -1087,7 +1087,7 @@ dia_svg_parse_path(GArray *points, const gchar *path_str, gchar **unparsed,
   path_chomp(path);
   while (path[0] != '\0') {
 #ifdef DEBUG_CUSTOM
-    g_print("Path: %s\n", path);
+    g_printerr ("Path: %s\n", path);
 #endif
     /* check for a new command */
     switch (path[0]) {
diff --git a/lib/dialib.c b/lib/dialib.c
index 3e413bbc..b61ede27 100644
--- a/lib/dialib.c
+++ b/lib/dialib.c
@@ -60,9 +60,7 @@ stderr_message_internal(const char *title, enum ShowAgainStyle showAgain,
 
   vsprintf (buf, fmt, args2);
 
-  fprintf(stderr,
-          "%s: %s\n",
-          title,buf);
+  g_printerr ("%s: %s\n", title, buf);
 }
 
 #ifdef G_OS_WIN32
@@ -74,7 +72,7 @@ myXmlErrorReporting (void *ctx, const char* msg, ...)
 
   va_start(args, msg);
   string = g_strdup_vprintf (msg, args);
-  g_print ("%s", string ? string : "xml error (null)?");
+  g_printerr ("%s", string ? string : "xml error (null)?");
   va_end(args);
 
   g_free(string);
diff --git a/lib/geometry.c b/lib/geometry.c
index 901217d9..4f636d36 100644
--- a/lib/geometry.c
+++ b/lib/geometry.c
@@ -699,9 +699,9 @@ calculate_object_edge(Point *objmid, Point *end, DiaObject *obj)
 #ifdef TRACE_DIST
   if (i == MAXITER) {
     for (i = 0; i < MAXITER; i++) {
-      printf("%d: %f, %f: %f\n", i, trace[i].x, trace[i].y, disttrace[i]);
+      g_printerr ("%d: %f, %f: %f\n", i, trace[i].x, trace[i].y, disttrace[i]);
     }
-    printf("i = %d, dist = %f\n", i, dist);
+    g_printerr ("i = %d, dist = %f\n", i, dist);
   }
 #endif
 
diff --git a/lib/textline.c b/lib/textline.c
index 2b8e9d0c..5273daea 100644
--- a/lib/textline.c
+++ b/lib/textline.c
@@ -332,9 +332,9 @@ text_line_adjust_layout_line(TextLine *line, PangoLayoutLine *layoutline,
   runs = line->layout_offsets->runs;
 
   if (g_slist_length(runs) != g_slist_length(layoutruns)) {
-    printf("Runs length error: %d != %d\n",
-          g_slist_length(line->layout_offsets->runs),
-          g_slist_length(layoutline->runs));
+    g_printerr ("Runs length error: %d != %d\n",
+                g_slist_length (line->layout_offsets->runs),
+                g_slist_length (layoutline->runs));
   }
   for (; runs != NULL && layoutruns != NULL; runs = g_slist_next(runs),
         layoutruns = g_slist_next(layoutruns)) {
@@ -352,8 +352,9 @@ text_line_adjust_layout_line(TextLine *line, PangoLayoutLine *layoutline,
        (int)(glyphs->glyphs[i].geometry.y_offset * scale / 20.0);
     }
     if (glyphs->num_glyphs != layoutglyphs->num_glyphs) {
-      printf("Glyph length error: %d != %d\n",
-            glyphs->num_glyphs, layoutglyphs->num_glyphs);
+      g_printerr ("Glyph length error: %d != %d\n",
+                  glyphs->num_glyphs,
+                  layoutglyphs->num_glyphs);
     }
   }
 }
diff --git a/objects/custom/shape_typeinfo.c b/objects/custom/shape_typeinfo.c
index bbcd6974..1a8903ee 100644
--- a/objects/custom/shape_typeinfo.c
+++ b/objects/custom/shape_typeinfo.c
@@ -6,7 +6,7 @@
  *
  * Custom shape loading on demand.
  * Copyright (C) 2007 Hans Breuer.
- * 
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
@@ -65,19 +65,19 @@ struct _Context {
   eState  state;
 };
 
-static void 
-startElementNs (void *ctx, 
-                const xmlChar *localname, 
-                const xmlChar *prefix, 
-                const xmlChar *URI, 
-                int nb_namespaces, 
-                const xmlChar **namespaces, 
-                int nb_attributes, 
-                int nb_defaulted, 
+static void
+startElementNs (void *ctx,
+                const xmlChar *localname,
+                const xmlChar *prefix,
+                const xmlChar *URI,
+                int nb_namespaces,
+                const xmlChar **namespaces,
+                int nb_attributes,
+                int nb_defaulted,
                 const xmlChar **attributes)
 {
   Context* context = (Context*)ctx;
-  
+
   if (READ_DONE == context->state)
     /* no more to do */;
   else if (strncmp ((const char*)localname, "name", 4) == 0)
@@ -111,7 +111,7 @@ _characters (void *ctx,
     }
   } else if (READ_ICON == context->state) {
     gchar *prev = context->si->icon;
-    if (!prev) 
+    if (!prev)
       context->si->icon = g_strndup ((const char*)ch, len);
     else {
       gchar *now = g_strndup ((const char*)ch, len);
@@ -121,15 +121,15 @@ _characters (void *ctx,
     }
   }
 }
-                               
-static void 
+
+static void
 endElementNs (void *ctx,
              const xmlChar *localname,
              const xmlChar *prefix,
              const xmlChar *URI)
 {
   Context* context = (Context*)ctx;
-  
+
   if (READ_DONE == context->state)
     return;
 
@@ -150,7 +150,7 @@ static void _error (void *ctx, const char * msg, ...) G_GNUC_PRINTF(2, 3);
 
 static void
 _error (void *ctx,
-        const char * msg, 
+        const char * msg,
         ...)
 {
   Context* context = (Context*)ctx;
@@ -159,9 +159,9 @@ _error (void *ctx,
   if (READ_DONE == context->state)
     return; /* we are ready, not interested in further complains */
   va_start(args, msg);
-  g_print ("Error: %s\n", context->si->filename);
-  g_vprintf (msg, args);
-  g_print ("\n");
+  g_printerr ("Error: %s\n", context->si->filename);
+  g_vfprintf (stderr, msg, args);
+  g_printerr ("\n");
   va_end(args);
 }
 
@@ -169,7 +169,7 @@ static void _warning (void *ctx, const char * msg, ...) G_GNUC_PRINTF(2, 3);
 
 static void
 _warning (void *ctx,
-          const char * msg, 
+          const char * msg,
           ...)
 {
   Context* context = (Context*)ctx;
@@ -178,9 +178,9 @@ _warning (void *ctx,
   if (READ_DONE == context->state)
     return; /* we are ready, not interested in further complains */
   va_start(args, msg);
-  g_print ("Warning: %s\n", context->si->filename);
-  g_vprintf (msg, args);
-  g_print ("\n");
+  g_printerr ("Warning: %s\n", context->si->filename);
+  g_vfprintf (stderr, msg, args);
+  g_printerr ("\n");
   va_end(args);
 }
 
@@ -201,9 +201,9 @@ shape_typeinfo_load (ShapeInfo* info)
   FILE *f;
   int n;
   Context ctx = { info, READ_ON };
-  
+
   g_assert (info->filename != NULL);
-  
+
   if (!once) {
     LIBXML_TEST_VERSION
 
@@ -235,9 +235,9 @@ shape_typeinfo_load (ShapeInfo* info)
     }
     return TRUE;
   } else {
-    g_print ("Preloading shape file '%s' failed.\n"
-             "Please ensure that <name/> and <icon/> are early in the file.\n",
-             info->filename);
+    g_printerr ("Preloading shape file '%s' failed.\n"
+                "Please ensure that <name/> and <icon/> are early in the file.\n",
+                info->filename);
   }
   return FALSE;
 }
diff --git a/objects/standard/arc.c b/objects/standard/arc.c
index 29b54a5c..15540534 100644
--- a/objects/standard/arc.c
+++ b/objects/standard/arc.c
@@ -364,9 +364,9 @@ arc_move_handle(Arc *arc, Handle *handle,
   }
 
   if (handle->id == HANDLE_MIDDLE) {
-          TRACE(printf("curve_dist: %.2f \n",arc->curve_distance));
+          TRACE(g_printerr ("curve_dist: %.2f \n",arc->curve_distance));
           arc->curve_distance = arc_compute_curve_distance(arc, &arc->connection.endpoints[0], 
&arc->connection.endpoints[1], to);
-          TRACE(printf("curve_dist: %.2f \n",arc->curve_distance));
+          TRACE(g_printerr ("curve_dist: %.2f \n",arc->curve_distance));
   } else if (handle->id == HANDLE_CENTER) {
           /* We can move the handle only on the line through center and middle
           * Intersecting chord theorem says a*a=b*c
@@ -392,11 +392,11 @@ arc_move_handle(Arc *arc, Handle *handle,
          arc->curve_distance = (arc->curve_distance > 0) ? cd : -cd;
   } else {
         Point best;
-        TRACE(printf("Modifiers: %d \n",modifiers));
+        TRACE(g_printerr ("Modifiers: %d \n",modifiers));
         if (modifiers & MODIFIER_SHIFT)
         /* if(arc->end_arrow.type == ARROW_NONE)*/
         {
-          TRACE(printf("SHIFT USED, to at %.2f %.2f  ",to->x,to->y));
+          TRACE(g_printerr ("SHIFT USED, to at %.2f %.2f  ",to->x,to->y));
           if (arc_find_radial(arc, to, &best)){
             /* needs to move two handles at the same time
              * compute pos of middle handle */
@@ -412,10 +412,10 @@ arc_move_handle(Arc *arc, Handle *handle,
             connection_adjust_for_autogap(&arc->connection);
             /* recompute curve distance equiv. move middle handle */
             arc->curve_distance = arc_compute_curve_distance(arc, &arc->connection.endpoints[0], 
&arc->connection.endpoints[1], &midpoint);
-            TRACE(printf("curve_dist: %.2f \n",arc->curve_distance));
+            TRACE(g_printerr ("curve_dist: %.2f \n",arc->curve_distance));
           }
           else {
-            TRACE(printf("NO best\n"));
+            TRACE(g_printerr ("NO best\n"));
           }
        } else {
           connection_move_handle(&arc->connection, handle->id, to, cp, reason, modifiers);
@@ -464,21 +464,21 @@ arc_compute_midpoint(Arc *arc, const Point * ep0, const Point * ep1 , Point * mi
                     return 0;
             }
             if (angle < -1 * M_PI){
-                    TRACE(printf("angle: %.2f ",angle));
+                    TRACE(g_printerr ("angle: %.2f ",angle));
                     angle += 2*M_PI;
-                    TRACE(printf("angle: %.2f ",angle));
+                    TRACE(g_printerr ("angle: %.2f ",angle));
             }
             if (angle > 1 * M_PI){
-                    TRACE(printf("angle: %.2f ",angle));
+                    TRACE(g_printerr ("angle: %.2f ",angle));
                     angle -= 2*M_PI;
-                    TRACE(printf("angle: %.2f ",angle));
+                    TRACE(g_printerr ("angle: %.2f ",angle));
             }
 
             midpos = arc->middle_handle.pos;
             /*rotate middle handle by half the angle */
-            TRACE(printf("\nmidpos before: %.2f %.2f \n",midpos.x, midpos.y));
+            TRACE(g_printerr ("\nmidpos before: %.2f %.2f \n",midpos.x, midpos.y));
             rotate_point_around_point(&midpos, &arc->center, angle/2);
-            TRACE(printf("\nmidpos after : %.2f %.2f \n",midpos.x, midpos.y));
+            TRACE(g_printerr ("\nmidpos after : %.2f %.2f \n",midpos.x, midpos.y));
             *midpoint = midpos;
             return 1;
 }
@@ -534,12 +534,12 @@ calculate_arc_object_edge(Arc *arc, real ang_start, real ang_end, DiaObject *obj
   mid2 = get_middle_arc_angle(ang_start, ang_end, clockwiseness);
   mid3 = ang_end;
 
-  TRACE(printf("Find middle angle between %f° and  %f°\n",ang_start,ang_end));
+  TRACE(g_printerr ("Find middle angle between %f° and  %f°\n",ang_start,ang_end));
   /* If the other end is inside the object */
   arc_get_point_at_angle(arc,target,mid1);
   dist = obj->ops->distance_from(obj, target );
   if (dist < 0.001){
-          TRACE(printf("Point at %f°: %f,%f is very close to object: %f, returning it\n",mid1, target->x, 
target->y, dist));
+          TRACE(g_printerr ("Point at %f°: %f,%f is very close to object: %f, returning it\n",mid1, 
target->x, target->y, dist));
           return ;
   }
   do {
@@ -563,7 +563,7 @@ calculate_arc_object_edge(Arc *arc, real ang_start, real ang_end, DiaObject *obj
 #ifdef TRACE_DIST
     for (j = 0; j < i; j++) {
       arc_get_point_at_angle(arc,target,trace[j]);
-      printf("%d: %f° : %f,%f :%f\n", j, trace[j],target->x,target->y, disttrace[j]);
+      g_printerr ("%d: %f° : %f,%f :%f\n", j, trace[j],target->x,target->y, disttrace[j]);
     }
 #endif
   arc_get_point_at_angle(arc,target,mid2);
@@ -587,7 +587,7 @@ arc_draw (Arc *arc, DiaRenderer *renderer)
   start_cp = arc->connection.endpoint_handles[0].connected_to;
   end_cp = arc->connection.endpoint_handles[1].connected_to;
 
-  TRACE(printf("drawing arc:\n start:%f°:%f,%f \tend:%f°:%f,%f\n",arc->angle1,endpoints[0].x,endpoints[0].y, 
arc->angle2,endpoints[1].x,endpoints[1].y));
+  TRACE(g_printerr ("drawing arc:\n start:%f°:%f,%f 
\tend:%f°:%f,%f\n",arc->angle1,endpoints[0].x,endpoints[0].y, arc->angle2,endpoints[1].x,endpoints[1].y));
 
   if (connpoint_is_autogap (start_cp)) {
      TRACE (printf ("computing start intersection\ncurve_distance: %f\n", arc->curve_distance));
@@ -597,7 +597,7 @@ arc_draw (Arc *arc, DiaRenderer *renderer)
         calculate_arc_object_edge (arc, arc->angle2, arc->angle1, start_cp->object, &gaptmp[0], TRUE);
   }
   if (connpoint_is_autogap (end_cp)) {
-    TRACE(printf("computing end intersection\ncurve_distance: %f\n",arc->curve_distance));
+    TRACE(g_printerr ("computing end intersection\ncurve_distance: %f\n",arc->curve_distance));
     if (arc->curve_distance < 0)
       calculate_arc_object_edge (arc, arc->angle2, arc->angle1, end_cp->object, &gaptmp[1], TRUE);
     else
diff --git a/plug-ins/dxf/dxf-import.c b/plug-ins/dxf/dxf-import.c
index 741a91bf..94691883 100644
--- a/plug-ins/dxf/dxf-import.c
+++ b/plug-ins/dxf/dxf-import.c
@@ -543,10 +543,9 @@ read_entity_polyline_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
        }
     } while( strcmp( data->value, "SEQEND" ));
 
-    if( points == 0 )
-    {
-        printf( "No vertexes defined\n" );
-        return( NULL );
+    if (points == 0) {
+      g_printerr ("No vertexes defined\n");
+      return NULL;
     }
 
     pcd = g_new( MultipointCreateData, 1);
@@ -1320,7 +1319,7 @@ import_dxf(const gchar *filename, DiagramData *dia, DiaContext *ctx, void* user_
                 } else if(strcmp(data->value, "EOF") == 0) {
                  /* handled below */
                } else {
-                 g_print ("DXF 0:%s not handled\n", data->value);
+                 g_printerr ("DXF 0:%s not handled\n", data->value);
                }
             } else if(data->code == 2) {
                 if(strcmp(data->value, "ENTITIES") == 0) {
diff --git a/plug-ins/postscript/win32print.c b/plug-ins/postscript/win32print.c
index 10f1e2df..58a52b8e 100644
--- a/plug-ins/postscript/win32print.c
+++ b/plug-ins/postscript/win32print.c
@@ -37,7 +37,7 @@
 
 #include "win32print.h"
 
-static void 
+static void
 PrintError (const char* s, DWORD err)
 {
   if (0 != err)
@@ -49,11 +49,11 @@ PrintError (const char* s, DWORD err)
                    | FORMAT_MESSAGE_IGNORE_INSERTS,
                    NULL,
                    err,
-                   MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 
+                   MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                    (char*)&lpBuffer,
                    0,NULL);
-    g_print ("%s : %s", s, lpBuffer);
-               LocalFree (lpBuffer);
+    g_printerr ("%s : %s", s, lpBuffer);
+    LocalFree (lpBuffer);
   }
 }
 
@@ -86,7 +86,7 @@ win32_printer_open (char* sName)
                     &hPrinter,
                     NULL))
   {
-    g_print ("Failed to open printer : %s\n", sName);
+    g_printerr ("Failed to open printer : %s\n", sName);
     return NULL;
   }
 
@@ -97,8 +97,8 @@ win32_printer_open (char* sName)
   else
   {
     pJob = (ADDJOB_INFO_1*)data;
-    hFile = CreateFile (pJob->Path, 
-                        GENERIC_WRITE, 
+    hFile = CreateFile (pJob->Path,
+                        GENERIC_WRITE,
                         0,      /* no share */
                         NULL,   /* default security */
                         OPEN_ALWAYS,
@@ -115,7 +115,7 @@ win32_printer_open (char* sName)
          return _fdopen (hnd, "wb");
        else
          PrintError ("Failed to _open_osfhandle", 0);
-    } 
+    }
   }
 
   return NULL;
@@ -133,7 +133,7 @@ win32_printer_close (FILE* f)
     ret = GetLastError();
   }
 
-  if (f) 
+  if (f)
     fclose (f);
   CloseHandle (hFile);
   ClosePrinter (hPrinter);
diff --git a/plug-ins/python/pydia-error.c b/plug-ins/python/pydia-error.c
index 3d8688ce..118ddcd5 100644
--- a/plug-ins/python/pydia-error.c
+++ b/plug-ins/python/pydia-error.c
@@ -24,10 +24,10 @@
 #include "message.h"
 
 /*
- * A little helper to dump pythons last error info either to file only or 
+ * A little helper to dump pythons last error info either to file only or
  * additional popup a message_error
  */
-void 
+void
 _pyerror_report_last (gboolean popup, const char* fn, const char* file, int line)
 {
   PyObject *exc, *v, *tb, *ef;
@@ -45,7 +45,7 @@ _pyerror_report_last (gboolean popup, const char* fn, const char* file, int line
   PyFile_WriteObject (exc, ef, 0);
   PyFile_WriteObject (v, ef, 0);
   PyTraceBack_Print(tb, ef);
-  if (((PyDiaError*)ef)->str && popup) 
+  if (((PyDiaError*)ef)->str && popup)
     message_error ("%s", ((PyDiaError*)ef)->str->str);
   g_free (sLoc);
   Py_DECREF (ef);
@@ -60,7 +60,7 @@ _pyerror_report_last (gboolean popup, const char* fn, const char* file, int line
 PyObject* PyDiaError_New (const char* s, gboolean unbuffered)
 {
   PyDiaError *self;
-  
+
   self = PyObject_NEW(PyDiaError, &PyDiaError_Type);
   if (!self) return NULL;
   if (unbuffered) {
@@ -127,7 +127,7 @@ PyDiaError_Write(PyDiaError *self, PyObject *args)
   if (self->str)
     g_string_append (self->str, s);
 
-  g_print ("%s", s);
+  g_printerr ("%s", s);
 
   Py_INCREF(Py_None);
   return Py_None;
diff --git a/plug-ins/xfig/xfig-import.c b/plug-ins/xfig/xfig-import.c
index 041aad95..a362606a 100644
--- a/plug-ins/xfig/xfig-import.c
+++ b/plug-ins/xfig/xfig-import.c
@@ -325,20 +325,27 @@ fig_fix_text(gchar *text) {
        text[j-2] = 0;
     }
     if (needs_conversion) {
-       /* Crudely assuming that fig uses Latin-1 */
-       converted = g_convert(text, strlen(text), "UTF-8", "ISO-8859-1",
-                             NULL, NULL, &err);
-       if (err != NULL) {
-           printf("Error converting %s: %s\n", text, err->message);
-           return text;
-       }
-       if (!g_utf8_validate(converted, -1, NULL)) {
-           printf("Fails to validate %s\n", converted);
-           return text;
-       }
-       if (text != converted) g_free(text);
-       return converted;
-    } else return text;
+      /* Crudely assuming that fig uses Latin-1 */
+      converted = g_convert (text,
+                             strlen (text),
+                             "UTF-8",
+                             "ISO-8859-1",
+                             NULL,
+                             NULL,
+                             &err);
+      if (err != NULL) {
+        g_printerr ("Error converting %s: %s\n", text, err->message);
+        return text;
+      }
+      if (!g_utf8_validate (converted, -1, NULL)) {
+        g_printerr ("Fails to validate %s\n", converted);
+        return text;
+      }
+      if (text != converted) g_free(text);
+      return converted;
+    } else {
+      return text;
+    }
 }
 
 static char *
diff --git a/tests/test-objects.c b/tests/test-objects.c
index f243ad80..7c2254f6 100644
--- a/tests/test-objects.c
+++ b/tests/test-objects.c
@@ -87,8 +87,9 @@ _test_creation (gconstpointer user_data)
        ++num_used; /* ... but not expected to be set */
       else if (strcmp (prop->descr->type, PROP_TYPE_STATIC) == 0)
        ++num_used; /* also not to be set */
-      else
-       g_print ("Not set '%s'\n", prop->descr->name);
+      else {
+        g_printerr ("Not set '%s'\n", prop->descr->name);
+      }
     }
     g_assert_cmpint (num_used, ==, num_described);
 
@@ -315,7 +316,7 @@ _test_change (gconstpointer user_data)
       /* maybe we should do something interesting first? */
       _object_change_free(change);
     } else {
-      g_print ("'%s' - no undo?\n", o->type->name);
+      g_printerr ("'%s' - no undo?\n", o->type->name);
     }
   }
   /* finally */
@@ -468,8 +469,9 @@ _test_connectionpoint_consistency (gconstpointer user_data)
       if (h->id == HANDLE_MOVE_STARTPOINT || h->id == HANDLE_MOVE_ENDPOINT)
         ++start_end;
     }
-    if (start_end < 2 && o->num_connections > 0)
-      g_print ("'%s' with no directions\n", type->name);
+    if (start_end < 2 && o->num_connections > 0) {
+      g_printerr ("'%s' with no directions\n", type->name);
+    }
     return;
   }
 
@@ -509,7 +511,7 @@ _test_connectionpoint_consistency (gconstpointer user_data)
           || strcmp (type->name, "Civil - Final-Settling Basin") == 0
           || strcmp (type->name, "Small Extension Node") == 0 /* MSE */
          )
-        g_print ("'%s' main-cp misplaced!\n", type->name);
+        g_printerr ("'%s' main-cp misplaced!\n", type->name);
       else
         g_assert (o->ops->distance_from (o, &cp->pos) == 0 && "within");
       continue;
@@ -1095,7 +1097,7 @@ main (int argc, char** argv)
   object_registry_foreach (_ot_item, "/Dia/Objects");
 
   ret = g_test_run ();
-  g_print ("%d objects.\n", num_objects);
+  g_printerr ("%d objects.\n", num_objects);
 
   return ret;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]