[gnumeric] xls: redirect all debug output to stderr using g_printerr.



commit 52c51fa5f78b1d419eeebaef06d56f0f4a2641cc
Author: Morten Welinder <terra gnome org>
Date:   Thu Mar 8 20:51:28 2012 -0500

    xls: redirect all debug output to stderr using g_printerr.

 plugins/excel/boot.c              |   12 +++---
 plugins/excel/ms-biff.c           |    6 +-
 plugins/excel/ms-escher.c         |   60 +++++++++++++++---------------
 plugins/excel/ms-excel-read.c     |   18 ++++----
 plugins/excel/ms-excel-write.c    |    6 ++-
 plugins/excel/ms-formula-read.c   |   74 ++++++++++++++++++------------------
 plugins/excel/ms-formula-write.c  |    6 +-
 plugins/excel/xls-read-pivot.c    |   40 ++++++++++----------
 plugins/excel/xlsx-read-drawing.c |    2 +-
 9 files changed, 113 insertions(+), 111 deletions(-)
---
diff --git a/plugins/excel/boot.c b/plugins/excel/boot.c
index 3652b8b..485bb19 100644
--- a/plugins/excel/boot.c
+++ b/plugins/excel/boot.c
@@ -142,7 +142,7 @@ excel_read_metadata (GsfDocMetaData *meta_data, GsfInfile *ole, char const *name
 static void
 cb_dump_vba (char const *name, guint8 const *src_code)
 {
-	printf ("<module name=\"%s\">\n<![CDATA[%s]]>\n</module>\n", name, src_code);
+	g_printerr ("<module name=\"%s\">\n<![CDATA[%s]]>\n</module>\n", name, src_code);
 }
 #endif
 
@@ -346,18 +346,18 @@ go_plugin_init (GOPlugin *plugin, GOCmdContext *cc)
 			continue;
 		if (fd->flags & XL_XLM) {
 			if (fd->flags != XL_XLM)
-				fprintf (stderr, "%s : flags in addition to XLM\n", name);
+				g_printerr ("%s : flags in addition to XLM\n", name);
 			if (fd->min_args != fd->max_args)
-				fprintf (stderr, "%s : min != max\n", name);
+				g_printerr ("%s : min != max\n", name);
 			continue;
 		}
 		if (fd->min_args < 0)
-			fprintf (stderr, "%s : min_args < 0\n", name);
+			g_printerr ("%s : min_args < 0\n", name);
 		if (fd->max_args < 0)
-			fprintf (stderr, "%s : min_args < 0\n", name);
+			g_printerr ("%s : min_args < 0\n", name);
 		if (fd->known_args != NULL &&
 		    fd->num_known_args != strlen (fd->known_args))
-			fprintf (stderr, "%s : num_expected_args inconsistent\n", name);
+			g_printerr ("%s : num_expected_args inconsistent\n", name);
 	}
 }
 #endif
diff --git a/plugins/excel/ms-biff.c b/plugins/excel/ms-biff.c
index b8e003f..9895387 100644
--- a/plugins/excel/ms-biff.c
+++ b/plugins/excel/ms-biff.c
@@ -495,7 +495,7 @@ ms_biff_query_next (BiffQuery *q)
 		q->non_decrypted_data = q->data;
 
 #if BIFF_DEBUG > 2
-	printf ("Biff read code 0x%x, length %d\n", q->opcode, q->length);
+	g_printerr ("Biff read code 0x%x, length %d\n", q->opcode, q->length);
 	ms_biff_query_dump (q);
 #endif
 	return TRUE;
@@ -608,7 +608,7 @@ ms_biff_put_len_next (BiffPut *bp, guint16 opcode, guint32 len)
 		XL_CHECK_CONDITION_VAL (len < MAX_BIFF7_RECORD_SIZE, NULL);
 
 #if BIFF_DEBUG > 0
-	printf ("Biff put len 0x%x\n", opcode);
+	g_printerr ("Biff put len 0x%x\n", opcode);
 #endif
 
 	bp->len_fixed  = +1;
@@ -632,7 +632,7 @@ ms_biff_put_var_next (BiffPut *bp, guint16 opcode)
 	g_return_if_fail (bp->len_fixed == -1);
 
 #if BIFF_DEBUG > 0
-	printf ("Biff put var 0x%x\n", opcode);
+	g_printerr ("Biff put var 0x%x\n", opcode);
 #endif
 
 	bp->len_fixed  = 0;
diff --git a/plugins/excel/ms-escher.c b/plugins/excel/ms-escher.c
index f254e24..6be380e 100644
--- a/plugins/excel/ms-escher.c
+++ b/plugins/excel/ms-escher.c
@@ -212,7 +212,7 @@ ms_escher_get_data (MSEscherState *state,
 			return NULL;
 		}
 
-		d (1, printf ("Target is 0x%x bytes at 0x%x, current = 0x%x..0x%x;\n"
+		d (1, g_printerr ("Target is 0x%x bytes at 0x%x, current = 0x%x..0x%x;\n"
 			      "Adding biff-0x%x of length 0x%x;\n",
 			      num_bytes, offset,
 			      state->start_offset,
@@ -236,11 +236,11 @@ ms_escher_get_data (MSEscherState *state,
 		int len = q->length - (res - q->data);
 		int counter = 0;
 
-		d (1, printf ("MERGE needed (%d) which is >= %d + %d;\n",
+		d (1, g_printerr ("MERGE needed (%d) which is >= %d + %d;\n",
 			      num_bytes, offset, state->end_offset););
 
 		do {
-			d (1, printf ("record %d) add %d bytes;\n", ++counter, len););
+			d (1, g_printerr ("record %d) add %d bytes;\n", ++counter, len););
 			/* copy necessary portion of current record */
 			memcpy (tmp, res, len);
 			tmp += len;
@@ -272,7 +272,7 @@ ms_escher_get_data (MSEscherState *state,
 
 		/* Copy back stub */
 		memcpy (tmp, res, num_bytes - (tmp-buffer));
-		d (1, printf ("record %d) add %d bytes;\n",
+		d (1, g_printerr ("record %d) add %d bytes;\n",
 			      ++counter,
 			      num_bytes - (int)(tmp-buffer)););
 		return buffer;
@@ -304,7 +304,7 @@ ms_escher_read_ColorMRU (MSEscherState *state, MSEscherHeader *h)
 {
 	d (3 , {
 		guint const num_Colours = h->instance;
-		printf ("There are %d Colours in a record with remaining length %d;\n",
+		g_printerr ("There are %d Colours in a record with remaining length %d;\n",
 			num_Colours, (h->len - COMMON_HEADER_LEN));
 	});
 
@@ -329,7 +329,7 @@ ms_escher_read_SplitMenuColors (MSEscherState *state, MSEscherHeader *h)
 		guint32 const shadow	= GSF_LE_GET_GUINT32(data + 8);
 		guint32 const threeD	= GSF_LE_GET_GUINT32(data + 12);
 
-		d (0, printf ("top_level_fill = 0x%x;\nline = 0x%x;\nshadow = 0x%x;\nthreeD = 0x%x;\n",
+		d (0, g_printerr ("top_level_fill = 0x%x;\nline = 0x%x;\nshadow = 0x%x;\nthreeD = 0x%x;\n",
 			      top_level_fill, line, shadow, threeD););
 	} else
 		return TRUE;
@@ -378,26 +378,26 @@ ms_escher_read_BSE (MSEscherState *state, MSEscherHeader *h)
 		checksum[i] = GSF_LE_GET_GUINT8 (data + 2 + i);
 
 	d (0 , {
-		printf ("Win type = %s;\n", bliptype_name (win_type));
-		printf ("Mac type = %s;\n", bliptype_name (mac_type));
-		printf ("Size = 0x%x(=%d) RefCount = 0x%x DelayOffset = 0x%x '%s';\n",
+		g_printerr ("Win type = %s;\n", bliptype_name (win_type));
+		g_printerr ("Mac type = %s;\n", bliptype_name (mac_type));
+		g_printerr ("Size = 0x%x(=%d) RefCount = 0x%x DelayOffset = 0x%x '%s';\n",
 			size, size, ref_count, del_offset, name);
 
 		switch (is_texture) {
-		case 0: printf ("Default usage;\n"); break;
-		case 1: printf ("Is texture;\n"); break;
-		default:printf ("UNKNOWN USAGE : %d;\n", is_texture);
+		case 0: g_printerr ("Default usage;\n"); break;
+		case 1: g_printerr ("Is texture;\n"); break;
+		default:g_printerr ("UNKNOWN USAGE : %d;\n", is_texture);
 		}
 
-		printf ("Checksum = 0x");
+		g_printerr ("Checksum = 0x");
 		for (i = 0; i < 16; ++i)
-			printf ("%02x", checksum[i]);
-		printf (";\n");
+			g_printerr ("%02x", checksum[i]);
+		g_printerr (";\n");
 	});
 
 	/* Very red herring I think */
 	if (name_len != 0) {
-		puts ("WARNING : Maybe a name ?");
+		g_printerr ("WARNING : Maybe a name?\n");
 		/* name = biff_get_text (data+36, name_len, &txt_byte_len); */
 	}
 
@@ -697,7 +697,7 @@ ms_escher_read_Sp (MSEscherState *state, MSEscherHeader *h)
 	g_return_val_if_fail (h->instance >= 0, TRUE);
 	g_return_val_if_fail (h->instance <= 202, TRUE);
 
-	d (0, printf ("%s (0x%x);\n", shape_names[h->instance],
+	d (0, g_printerr ("%s (0x%x);\n", shape_names[h->instance],
 		      h->instance););
 
 	data = ms_escher_get_data (state,
@@ -707,7 +707,7 @@ ms_escher_read_Sp (MSEscherState *state, MSEscherHeader *h)
 
 	spid  = GSF_LE_GET_GUINT32 (data+0);
 	flags = GSF_LE_GET_GUINT32 (data+4);
-	d (0, printf ("SPID %d, Type %d,%s%s%s%s%s%s%s%s%s%s%s%s;\n",
+	d (0, g_printerr ("SPID %d, Type %d,%s%s%s%s%s%s%s%s%s%s%s%s;\n",
 		      spid, h->instance,
 			(flags&0x01) ? " Group": "",
 			(flags&0x02) ? " Child": "",
@@ -911,7 +911,7 @@ ms_escher_read_Dgg (MSEscherState *state, MSEscherHeader *h)
 	fd.num_shapes_saved   = GSF_LE_GET_GUINT32(data+ 8);
 	fd.num_drawings_saved = GSF_LE_GET_GUINT32(data+12);
 
-	printf ("maxspid 0x%x clusts 0x%x shapes 0x%x drawings x%x\n",
+	g_printerr ("maxspid 0x%x clusts 0x%x shapes 0x%x drawings x%x\n",
 		fd.max_spid, fd.num_id_clust, fd.num_shapes_saved,
 		fd.num_drawings_saved);
 
@@ -1310,7 +1310,7 @@ ms_escher_read_OPT_bools (MSEscherHeader *h,
 	g_return_if_fail (n_bools > 0);
 	g_return_if_fail (bools[n_bools-1].pid == pid);
 
-	d (2, printf ("Set of Bools %d-%d = 0x%08x;\n{\n",
+	d (2, g_printerr ("Set of Bools %d-%d = 0x%08x;\n{\n",
 		      bools[0].pid, bools[n_bools-1].pid, val););
 
 	pid -= (n_bools - 1);
@@ -1322,7 +1322,7 @@ ms_escher_read_OPT_bools (MSEscherHeader *h,
 		if (!(val & mask))	/* the value is set */
 			continue;
 
-		d (0, printf ("bool %s(%d) = %s; /* def: %s; gnm: %d */\n",
+		d (0, g_printerr ("bool %s(%d) = %s; /* def: %s; gnm: %d */\n",
 			      bools[i].name, pid,
 			      set_val ? "true" : "false",
 			      def_val ? "true" : "false",
@@ -1332,7 +1332,7 @@ ms_escher_read_OPT_bools (MSEscherHeader *h,
 			ms_escher_header_add_attr
 				(h, ms_obj_attr_new_flag (aid));
 	}
-	d (2, printf ("};\n"););
+	d (2, g_printerr ("};\n"););
 }
 
 static gboolean
@@ -1362,7 +1362,7 @@ ms_escher_read_OPT (MSEscherState *state, MSEscherHeader *h)
 
 		/* container is sorted by pid. Use this as sanity test */
 		if (prev_pid >= pid) {
-			printf ("Pids not monotonic %d >= %d;\n", prev_pid, pid);
+			g_printerr ("Pids not monotonic %d >= %d;\n", prev_pid, pid);
 			if (needs_free)
 				g_free ((guint8 *)data);
 			return TRUE;
@@ -1935,7 +1935,7 @@ ms_escher_read_OPT (MSEscherState *state, MSEscherHeader *h)
 
 		d (0, {
 			if (NULL != name)
-				   printf ("%s %d = 0x%08x (=%d) %s%s;\n", name, pid, val, val,
+				   g_printerr ("%s %d = 0x%08x (=%d) %s%s;\n", name, pid, val, val,
 			      is_blip ? " is blip" : "",
 					   is_complex ? " is complex" : "");
 		});
@@ -2020,7 +2020,7 @@ ms_escher_read_ClientTextbox (MSEscherState *state, MSEscherHeader *h)
 			ms_obj_attr_new_markup (MS_OBJ_ATTR_MARKUP, markup));
 		pango_attr_list_unref (markup);
 	}
-	d (0, printf ("'%s';\n", text););
+	d (0, g_printerr ("'%s';\n", text););
 	return FALSE;
 }
 
@@ -2089,7 +2089,7 @@ ms_escher_read_container (MSEscherState *state, MSEscherHeader *container,
 		h.ver      = tmp & 0x0f;
 		h.instance = (tmp >> 4) & 0xfff;
 
-		d (0 , printf ("length 0x%x(=%d), ver 0x%x, instance 0x%x, offset = 0x%x(=%d);\n",
+		d (0 , g_printerr ("length 0x%x(=%d), ver 0x%x, instance 0x%x, offset = 0x%x(=%d);\n",
 			       h.len, h.len, h.ver, h.instance, h.offset, h.offset););
 
 		if (needs_free)
@@ -2149,10 +2149,10 @@ ms_escher_read_container (MSEscherState *state, MSEscherHeader *container,
 			/* Not really needed */
 			g_return_val_if_fail (handler != NULL, TRUE);
 
-			d (0, printf ("{ /* %s */\n", fbt_name););
+			d (0, g_printerr ("{ /* %s */\n", fbt_name););
 			res = (*handler)(state, &h);
 
-			d (0, printf ("}; /* %s */\n", fbt_name););
+			d (0, g_printerr ("}; /* %s */\n", fbt_name););
 			if (res) {
 				ms_escher_header_release (&h);
 				g_warning ("%s;", fbt_name);
@@ -2216,10 +2216,10 @@ ms_escher_parse (BiffQuery *q, MSContainer *container, gboolean return_attrs)
 	fake_header.container = NULL;
 	fake_header.offset = 0;
 
-	d (0, printf ("{  /* Escher '%s'*/\n", drawing_record_name););
+	d (0, g_printerr ("{  /* Escher '%s'*/\n", drawing_record_name););
 	ms_escher_read_container (&state,
 		&fake_header, -COMMON_HEADER_LEN, return_attrs);
-	d (0, printf ("}; /* Escher '%s'*/\n", drawing_record_name););
+	d (0, g_printerr ("}; /* Escher '%s'*/\n", drawing_record_name););
 
 	if (return_attrs) {
 		res = fake_header.attrs;
diff --git a/plugins/excel/ms-excel-read.c b/plugins/excel/ms-excel-read.c
index 885d9be..1322ddb 100644
--- a/plugins/excel/ms-excel-read.c
+++ b/plugins/excel/ms-excel-read.c
@@ -238,7 +238,7 @@ gnm_xl_importer_set_codepage (GnmXLImporter *importer, int codepage)
 	g_object_set_data (G_OBJECT (importer->wb), "excel-codepage",
 			   GINT_TO_POINTER (codepage));
 
-	d (0, puts (gsf_msole_language_for_lid (
+	d (0, g_printerr ("%s\n", gsf_msole_language_for_lid (
 						gsf_msole_codepage_to_lid (codepage))););
 }
 
@@ -310,7 +310,7 @@ ms_sheet_parse_expr_internal (ExcelReadSheet *esheet, guint8 const *data, int le
 		tmp = gnm_expr_top_as_string (texpr,
 					      parse_pos_init (&pp, wb, sheet, 0, 0),
 					      gnm_conventions_default);
-		puts (tmp ? tmp : "(null)");
+		g_printerr ("%s\n", tmp ? tmp : "(null)");
 		g_free (tmp);
 	}
 
@@ -1358,7 +1358,7 @@ excel_read_SST (BiffQuery *q, GnmXLImporter *importer)
 			d (4, g_printerr ("Blank string in table at 0x%x.\n", i););
 #ifndef NO_DEBUG_EXCEL
 		else if (ms_excel_read_debug > 4)
-			puts (importer->sst[i].content->str);
+			g_printerr ("%s\n", importer->sst[i].content->str);
 #endif
 	}
 }
@@ -2382,7 +2382,7 @@ excel_read_XF_OLD (BiffQuery *q, GnmXLImporter *importer)
 	guint16 data;
         guint8 subdata;
 
-	d ( 2, fprintf(stderr, "XF # %d\n", importer->XF_cell_records->len); );
+	d ( 2, g_printerr ("XF # %d\n", importer->XF_cell_records->len); );
 	d ( 2, gsf_mem_dump (q->data, q->length); );
 
 	XL_CHECK_CONDITION (q->length > (importer->ver >= MS_BIFF_V3 ? 12 : 4));
@@ -4202,11 +4202,11 @@ excel_read_ROW (BiffQuery *q, ExcelReadSheet *esheet)
 	d (1, {
 			g_printerr ("Row %d height 0x%x, flags=0x%x 0x%x;\n", row + 1, height, flags, flags2);
 			if (is_std_height)
-				fputs ("Is Std Height;\n", stderr);
+				g_printerr ("%s\n", "Is Std Height;\n");
 			if (flags2 & 0x1000)
-				fputs ("Top thick;\n", stderr);
+				g_printerr ("%s\n", "Top thick;\n");
 			if (flags2 & 0x2000)
-				fputs ("Bottom thick;\n", stderr);
+				g_printerr ("%s\n", "Bottom thick;\n");
 		});
 
 	/* TODO: Put mechanism in place to handle thick margins */
@@ -5384,7 +5384,7 @@ excel_read_CF (BiffQuery *q, ExcelReadSheet *esheet, GnmStyleConditions *sc)
 		}
 
 		d (3, {
-				puts ("Font");
+				g_printerr ("%s\n", "Font");
 				gsf_mem_dump (data, 54);
 			});
 
@@ -7271,7 +7271,7 @@ excel_read_workbook (GOIOContext *context, WorkbookView *wb_view,
 			}
 
 		case BIFF_XL9FILE:
-			d (0, puts ("XL 2000 file"););
+			d (0, g_printerr ("%s\n", "XL 2000 file"););
 			break;
 
 		case BIFF_RECALCID:	break;
diff --git a/plugins/excel/ms-excel-write.c b/plugins/excel/ms-excel-write.c
index 4a2ef70..55f655c 100644
--- a/plugins/excel/ms-excel-write.c
+++ b/plugins/excel/ms-excel-write.c
@@ -918,7 +918,7 @@ map_script_to_xl (GnmStyle const *style)
 	}
 }
 
-void
+static void
 cb_write_condition (GnmStyleConditions const *sc, CondDetails *cd,
 		    ExcelWriteSheet *esheet)
 {
@@ -2405,8 +2405,10 @@ xf_init (XLExportBase *xle)
 						   "xls-default-style");
 	if (xle->xf.default_style == NULL)
 		xle->xf.default_style = gnm_style_new_default ();
-	else
+	else {
+		gnm_style_dump (xle->xf.default_style);
 		gnm_style_ref (xle->xf.default_style);
+	}
 
 	xle->xf.value_fmt_styles = g_hash_table_new_full (
 		g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)gnm_style_unlink);
diff --git a/plugins/excel/ms-formula-read.c b/plugins/excel/ms-formula-read.c
index 57d8c08..9db3fce 100644
--- a/plugins/excel/ms-formula-read.c
+++ b/plugins/excel/ms-formula-read.c
@@ -499,7 +499,7 @@ getRefV7 (GnmCellRef *cr,
 {
 	guint16 const row = (guint16)(gbitrw & 0x3fff);
 
-	d (2, fprintf (stderr, "7In : 0x%x, 0x%x  at %s%s\n", col, gbitrw,
+	d (2, g_printerr ("7In : 0x%x, 0x%x  at %s%s\n", col, gbitrw,
 		      cell_coord_name (curcol, currow), (shared?" (shared)":"")););
 
 	cr->sheet = NULL;
@@ -543,7 +543,7 @@ getRefV8 (GnmCellRef *cr,
 {
 	guint8 const col = (guint8)(gbitcl & 0xff);
 
-	d (2, fprintf (stderr, "8In : 0x%x, 0x%x  at %s%s\n", row, gbitcl,
+	d (2, g_printerr ("8In : 0x%x, 0x%x  at %s%s\n", row, gbitcl,
 		      cell_coord_name (curcol, currow), (shared?" (shared)":"")););
 
 	cr->sheet = NULL;
@@ -570,7 +570,7 @@ getRefV8 (GnmCellRef *cr,
 static void
 parse_list_push (GnmExprList **list, GnmExpr const *pd)
 {
-	d (5, fprintf (stderr, "Push 0x%p\n", (void *)pd););
+	d (5, g_printerr ("Push 0x%p\n", (void *)pd););
 	if (pd == NULL) {
 		g_warning ("FIXME: Pushing nothing onto excel function stack");
 		pd = xl_expr_err (NULL, -1, -1,
@@ -594,7 +594,7 @@ parse_list_pop (GnmExprList **list)
 	if (tmp != NULL) {
 		GnmExpr const *ans = tmp->data;
 		*list = g_slist_remove (*list, ans);
-		d (5, fprintf (stderr, "Pop 0x%p\n", (void *)ans););
+		d (5, g_printerr ("Pop 0x%p\n", (void *)ans););
 		return ans;
 	}
 
@@ -658,7 +658,7 @@ make_function (GnmExprList **stack, int fn_idx, int numargs, Workbook *wb)
 		}
 
 		name = gnm_func_lookup (f_name, wb);
-		d (2, fprintf (stderr, "Function '%s' of %d args\n",
+		d (2, g_printerr ("Function '%s' of %d args\n",
 			       f_name, numargs););
 
 		if (name == NULL)
@@ -671,7 +671,7 @@ make_function (GnmExprList **stack, int fn_idx, int numargs, Workbook *wb)
 		ExcelFuncDesc const *fd = excel_func_desc + fn_idx;
 		GnmExprList *args;
 
-		d (2, fprintf (stderr, "Function '%s', %d, max args: %d flags = 0x%x\n",
+		d (2, g_printerr ("Function '%s', %d, max args: %d flags = 0x%x\n",
 			       fd->name, numargs, fd->max_args, fd->flags););
 
 		if (numargs < 0) { /* fixed, use the built in */
@@ -725,12 +725,12 @@ ms_excel_dump_cellname (GnmXLImporter const *importer, ExcelReadSheet const *esh
 			int fn_col, int fn_row)
 {
 	if (esheet && esheet->sheet && esheet->sheet->name_unquoted)
-		fprintf (stderr, "%s!", esheet->sheet->name_unquoted);
+		g_printerr ("%s!", esheet->sheet->name_unquoted);
 	else if (importer && importer->wb && go_doc_get_uri (GO_DOC (importer->wb))) {
-		fprintf (stderr, "[%s]", go_doc_get_uri (GO_DOC (importer->wb)));
+		g_printerr ("[%s]", go_doc_get_uri (GO_DOC (importer->wb)));
 		return;
 	}
-	fprintf (stderr, "%s%d : ", col_name(fn_col), fn_row+1);
+	g_printerr ("%s%d : ", col_name(fn_col), fn_row+1);
 }
 
 /* Binary operator tokens */
@@ -782,7 +782,7 @@ excel_formula_parses_ref_sheets (MSContainer const *container, guint8 const *dat
 		if (a < 0 || b < 0) /* deleted sheets */
 			return TRUE;
 
-		d (1, fprintf (stderr, " : 0x%hx : 0x%hx : 0x%hx\n", ixals, a, b););
+		d (1, g_printerr (" : 0x%hx : 0x%hx : 0x%hx\n", ixals, a, b););
 
 		/* ixals < 0 == reference within the current workbook
 		 *    ixals == negative one based index into containers externsheet table
@@ -912,7 +912,7 @@ excel_parse_formula1 (MSContainer const *container,
 #ifndef NO_DEBUG_EXCEL
 	if (ms_excel_formula_debug > 1) {
 		ms_excel_dump_cellname (container->importer, esheet, fn_col, fn_row);
-		fprintf (stderr, "\n");
+		g_printerr ("\n");
 		if (ms_excel_formula_debug > 1) {
 			gsf_mem_dump (mem, length);
 		}
@@ -926,10 +926,10 @@ excel_parse_formula1 (MSContainer const *container,
 		if (ptg > FORMULA_PTG_MAX)
 			break;
 		d (2, {
-			fprintf (stderr, "Ptg : %s 0x%02x", ptg_name [ptgbase], ptg);
+			g_printerr ("Ptg : %s 0x%02x", ptg_name [ptgbase], ptg);
 			if (ptg != ptgbase)
-				fprintf (stderr, "(0x%02x)", ptgbase);
-			fprintf (stderr, "\n");
+				g_printerr ("(0x%02x)", ptgbase);
+			g_printerr ("\n");
 		});
 
 		switch (ptgbase) {
@@ -967,7 +967,7 @@ excel_parse_formula1 (MSContainer const *container,
 				return NULL;
 			}
 
-			d (0, fprintf (stderr, "Parse shared formula\n"););
+			d (0, g_printerr ("Parse shared formula\n"););
 			expr = excel_parse_formula1 (container, esheet, fn_col, fn_row,
 						     sf->data, sf->data_len, sf->array_data_len,
 						     TRUE, array_element);
@@ -1085,7 +1085,7 @@ excel_parse_formula1 (MSContainer const *container,
 			if (grbit == 0x00) {
 #if 0
 				ms_excel_dump_cellname (container->importer, esheet, fn_col, fn_row);
-				fprintf (stderr, "Hmm, ptgAttr of type 0 ??\n"
+				g_printerr ("Hmm, ptgAttr of type 0 ??\n"
 					"I've seen a case where an instance of this with flag A and another with flag 3\n"
 					"bracket a 1x1 array formula.  please send us this file.\n"
 					"Flags = 0x%X\n", w);
@@ -1093,29 +1093,29 @@ excel_parse_formula1 (MSContainer const *container,
 				; /* this looks ignoreable */
 #endif
 			} else if (grbit & 0x01) {
-				d (2, fprintf (stderr, "A volatile function\n"););
+				d (2, g_printerr ("A volatile function\n"););
 
 			/* AttrIf: stores jump to FALSE condition */
 			} else if (grbit & 0x02) {
 				/* Ignore cached result */
-				d (2, fprintf (stderr, "ATTR IF\n"););
+				d (2, g_printerr ("ATTR IF\n"););
 
 			/* AttrChoose : stores table of inputs */
 			} else if (grbit & 0x04) {
 				/* Ignore the optimzation to specify which arg to use */
-				d (2, fprintf (stderr, "ATTR CHOOSE\n"););
+				d (2, g_printerr ("ATTR CHOOSE\n"););
 				ptg_length = 2 * ((w + 1) /* args */ + 1 /* count */) + 1;
 
 			/* AttrGoto : bytes/words to skip during _evaluation_.
 			 * We still need to parse them */
 			} else if (grbit & 0x08) {
-				d (2, fprintf (stderr, "ATTR GOTO\n"););
+				d (2, g_printerr ("ATTR GOTO\n"););
 
 			/* AttrSum: 'optimised' SUM function */
 			} else if (grbit & 0x10) {
 				if (!make_function (&stack, 0x04, 1, container->importer->wb)) {
 					error = TRUE;
-					fprintf (stderr, "Error in optimised SUM\n");
+					g_printerr ("Error in optimised SUM\n");
 				}
 
 			/* AttrSpace */
@@ -1125,10 +1125,10 @@ excel_parse_formula1 (MSContainer const *container,
 				if (attrs == 0) /* bitFSpace : ignore it for now */
 					;
 				else
-					d (2, fprintf (stderr, "Redundant whitespace in formula 0x%x count %d\n", attrs, num_space););
+					d (2, g_printerr ("Redundant whitespace in formula 0x%x count %d\n", attrs, num_space););
 			} else {
 				ms_excel_dump_cellname (container->importer, esheet, fn_col, fn_row);
-				fprintf (stderr, "Unknown PTG Attr gr = 0x%x, w = 0x%x ptg = 0x%x\n", grbit, w, ptg);
+				g_printerr ("Unknown PTG Attr gr = 0x%x, w = 0x%x ptg = 0x%x\n", grbit, w, ptg);
 				error = TRUE;
 			}
 		}
@@ -1178,10 +1178,10 @@ excel_parse_formula1 (MSContainer const *container,
 			ptg_length = 1 + byte_len;
 
 			if (str != NULL) {
-				d (2, fprintf (stderr, "   -> '%s'\n", str););
+				d (2, g_printerr ("   -> '%s'\n", str););
 				parse_list_push_raw (&stack, value_new_string_nocopy (str));
 			} else {
-				d (2, fprintf (stderr, "   -> \'\'\n"););
+				d (2, g_printerr ("   -> \'\'\n"););
 				parse_list_push_raw (&stack, value_new_string (""));
 			}
 			break;
@@ -1312,7 +1312,7 @@ excel_parse_formula1 (MSContainer const *container,
 				/* no way to dump the content because we have
 				 * no idea how long it is
 				 */
-				fprintf (stderr, "An Array how interesting: (%d,%d)\n",
+				g_printerr ("An Array how interesting: (%d,%d)\n",
 					cols, rows);
 			}
 #endif
@@ -1326,7 +1326,7 @@ excel_parse_formula1 (MSContainer const *container,
 					array_data++;
 #ifndef NO_DEBUG_EXCEL
 					if (ms_excel_formula_debug > 5) {
-						fprintf (stderr, "\tArray elem type 0x%x (%d,%d)\n", val_type, lpx, lpy);
+						g_printerr ("\tArray elem type 0x%x (%d,%d)\n", val_type, lpx, lpy);
 					}
 #endif
 					switch (val_type) {
@@ -1358,7 +1358,7 @@ excel_parse_formula1 (MSContainer const *container,
 						if (str) {
 #ifndef NO_DEBUG_EXCEL
 							if (ms_excel_formula_debug > 5) {
-								fprintf (stderr, "\tString '%s'\n", str);
+								g_printerr ("\tString '%s'\n", str);
 							}
 #endif
 							elem = value_new_string_nocopy (str);
@@ -1377,7 +1377,7 @@ excel_parse_formula1 (MSContainer const *container,
 						break;
 
 					default :
-						fprintf (stderr, "FIXME: Duff array item type %d @ %s%d:%d,%d\n",
+						g_printerr ("FIXME: Duff array item type %d @ %s%d:%d,%d\n",
 							val_type, col_name(fn_col), fn_row+1, lpx, lpy);
 						gsf_mem_dump (array_data-1, 9);
 						elem = value_new_empty ();
@@ -1403,7 +1403,7 @@ excel_parse_formula1 (MSContainer const *container,
 
 			if (!make_function (&stack, iftab, -1, container->importer->wb)) {
 				error = TRUE;
-				fprintf (stderr, "error making func\n");
+				g_printerr ("error making func\n");
 			}
 			break;
 		}
@@ -1429,7 +1429,7 @@ excel_parse_formula1 (MSContainer const *container,
 
 			if (!make_function (&stack, iftab, numargs, container->importer->wb)) {
 				error = TRUE;
-				fprintf (stderr, "error making func var\n");
+				g_printerr ("error making func var\n");
 			}
 			break;
 		}
@@ -1463,7 +1463,7 @@ excel_parse_formula1 (MSContainer const *container,
 					nexpr = g_ptr_array_index (names, name_idx-1) =
 						expr_name_new (stub_name);
 					name = gnm_expr_new_name (nexpr, NULL, NULL);
-					d (1, fprintf (stderr, "creating stub '%s'", stub_name););
+					d (1, g_printerr ("creating stub '%s'", stub_name););
 					g_free (stub_name);
 				} else
 				{
@@ -1476,7 +1476,7 @@ excel_parse_formula1 (MSContainer const *container,
 				name = gnm_expr_new_name (nexpr, NULL, NULL);
 
 			parse_list_push (&stack, name);
-			d (2, fprintf (stderr, "Name idx %hu\n", name_idx););
+			d (2, g_printerr ("Name idx %hu\n", name_idx););
 		}
 		break;
 
@@ -1577,7 +1577,7 @@ excel_parse_formula1 (MSContainer const *container,
 
 				name_idx  = GSF_LE_GET_GUINT16 (cur+2);
 
-				d (2, fprintf (stderr, "name %hu : externsheet %hu\n",
+				d (2, g_printerr ("name %hu : externsheet %hu\n",
 					       name_idx, sheet_idx););
 			} else {
 				gint16 sheet_idx;
@@ -1587,7 +1587,7 @@ excel_parse_formula1 (MSContainer const *container,
 				name_idx  = GSF_LE_GET_GUINT16 (cur+10);
 #if 0
 				gsf_mem_dump (cur, 24);
-				d (-2, fprintf (stderr, "name = %hu, externsheet = %hd\n",
+				d (-2, g_printerr ("name = %hu, externsheet = %hd\n",
 					       name_idx, sheet_idx););
 #endif
 				if (sheet_idx < 0) {
@@ -1615,7 +1615,7 @@ excel_parse_formula1 (MSContainer const *container,
 			}
 
 			parse_list_push (&stack, name);
-			d (2, fprintf (stderr, "Name idx %hu\n", name_idx););
+			d (2, g_printerr ("Name idx %hu\n", name_idx););
 		}
 		break;
 
@@ -1699,7 +1699,7 @@ excel_parse_formula1 (MSContainer const *container,
 				ptg_length = 1;
 			}
 		}
-/*		fprintf (stderr, "Ptg 0x%x length (not inc. ptg byte) %d\n", ptgbase, ptg_length); */
+/*		g_printerr ("Ptg 0x%x length (not inc. ptg byte) %d\n", ptgbase, ptg_length); */
 		cur      += ptg_length + 1;
 		len_left -= ptg_length + 1;
 	}
diff --git a/plugins/excel/ms-formula-write.c b/plugins/excel/ms-formula-write.c
index 2e252a4..6c375eb 100644
--- a/plugins/excel/ms-formula-write.c
+++ b/plugins/excel/ms-formula-write.c
@@ -59,7 +59,7 @@ sheet_pair_add_if_unknown (GHashTable *hash, ExcelSheetPair const *pair)
 		new_pair->b = pair->b;
 		new_pair->idx_a = new_pair->idx_b = 0;
 		g_hash_table_insert (hash, new_pair, new_pair);
-		/* fprintf (stderr, "Adding %p:%p\n", pair->a, pair->b); */
+		/* g_printerr ("Adding %p:%p\n", pair->a, pair->b); */
 	}
 }
 
@@ -578,8 +578,8 @@ write_funcall (PolishData *pd, GnmExpr const *expr,
 			xl_map_char_to_type (ef->efunc->type), target_type);
 
 #if FORMULA_DEBUG > 1
-		printf ("Writing function '%s' as idx %d, args %d\n",
-			name, ef->u.std.idx, fce->u.std.efunc->num_known_args);
+		g_printerr ("Writing function '%s' as idx %d, args %d\n",
+			    name, ef->u.std.idx, fce->u.std.efunc->num_known_args);
 #endif
 
 		/* If XL requires more arguments than we do
diff --git a/plugins/excel/xls-read-pivot.c b/plugins/excel/xls-read-pivot.c
index 51ae32e..236ef5d 100644
--- a/plugins/excel/xls-read-pivot.c
+++ b/plugins/excel/xls-read-pivot.c
@@ -100,35 +100,35 @@ xls_read_pivot_cache_value (XLSReadPivot *s, BiffQuery *q)
 		switch (opcode) {
 		case BIFF_SXNUM: if (check_next (q, 8)) {
 			double v = GSF_LE_GET_DOUBLE  (q->data + 0);
-			d (1, fprintf (stderr, "%g (num);\n", v););
+			d (1, g_printerr ("%g (num);\n", v););
 			return go_val_new_float (v);
 		}
 		break;
 
 		case BIFF_SXBOOL: if (check_next (q, 2)) {
 			gboolean v = 0 != GSF_LE_GET_GINT16  (q->data + 0);
-			d (1, fprintf (stderr, "%s (bool);\n", v ? "true" : "false"););
+			d (1, g_printerr ("%s (bool);\n", v ? "true" : "false"););
 			return go_val_new_bool (v);
 		}
 		break;
 
 		case BIFF_SXERR: if (check_next (q, 2)) {
 			gint16 v = GSF_LE_GET_GINT16  (q->data + 0);
-			d (1, fprintf (stderr, "%hx (err);\n", v););
+			d (1, g_printerr ("%hx (err);\n", v););
 			return xls_value_new_err (NULL, v);
 		}
 		break;
 
 		case BIFF_SXINT: if (check_next (q, 2)) {
 			gint16 v = GSF_LE_GET_GINT16  (q->data + 0);
-			d (1, fprintf (stderr, "%hx (short);\n", v););
+			d (1, g_printerr ("%hx (short);\n", v););
 			return go_val_new_float (v);
 		}
 		break;
 
 		case BIFF_SXSTRING: if (check_next_min (q, 2)) {
 			char *v = excel_biff_text_2 (s->imp, q, 0);
-			d (1, fprintf (stderr, "'%s' (string);\n", v););
+			d (1, g_printerr ("'%s' (string);\n", v););
 			return go_val_new_str_nocopy (v);
 		}
 		break;
@@ -142,7 +142,7 @@ xls_read_pivot_cache_value (XLSReadPivot *s, BiffQuery *q)
 			guint8  se = GSF_LE_GET_GUINT8  (q->data + 7);
 			GDate date;
 
-			d (1, fprintf (stderr, "%hu-%hu-%hhuT%hhu:%hhu:%hhu (data);\n",
+			d (1, g_printerr ("%hu-%hu-%hhuT%hhu:%hhu:%hhu (data);\n",
 				       y, m, d, h, mi, se););
 
 			g_date_set_dmy (&date, d, m, y);
@@ -159,17 +159,17 @@ xls_read_pivot_cache_value (XLSReadPivot *s, BiffQuery *q)
 		break;
 
 		case BIFF_SXNIL: if (check_next (q, 0)) {
-			d (1, fprintf (stderr, "(empty);\n"););
+			d (1, g_printerr ("(empty);\n"););
 			return go_val_new_empty ();
 		}
 
 		default :
-			d (0, fprintf (stderr, "UNEXPECTED RECORD %hx;\n", opcode););
+			d (0, g_printerr ("UNEXPECTED RECORD %hx;\n", opcode););
 			break;
 		}
 	}
 
-	d (0, fprintf (stderr, "missing value;\n"););
+	d (0, g_printerr ("missing value;\n"););
 	return NULL;
 }
 
@@ -181,7 +181,7 @@ xls_read_pivot_cache_values (XLSReadPivot *s, BiffQuery *q, unsigned int n, cons
 	GnmValue *v;
 	unsigned int i;
 
-	d (1, fprintf (stderr, "/* %u %s items */ ;\n", n, type););
+	d (1, g_printerr ("/* %u %s items */ ;\n", n, type););
 	for (i = 0 ; i < n ; i++) {
 		if (NULL == (v = xls_read_pivot_cache_value (s, q))) {
 	/* TODO : go_val_array_set_size */
@@ -214,7 +214,7 @@ xls_read_pivot_cache_group (XLSReadPivot *s, BiffQuery *q, GODataCacheField *fie
 
 		go_val_bucketer_init (&bucketer);
 		bucketer.details.series.step	= 1.;
-		d (0, fprintf (stderr, "group with 0x%hx flag type = %d;\n", flags, type););
+		d (0, g_printerr ("group with 0x%hx flag type = %d;\n", flags, type););
 		switch (type) {
 		case 1 : bucketer.type = GO_VAL_BUCKET_SECOND; break;
 		case 2 : bucketer.type = GO_VAL_BUCKET_MINUTE; break;
@@ -318,7 +318,7 @@ of the calculated field is stored in a directly following SXFormula record. If f
 	guint16 std_items	= GSF_LE_GET_GUINT16  (q->data + 12);
 	GOString *name		= go_string_new_nocopy (excel_biff_text_2 (s->imp, q, 14));
 
-	d(0, fprintf (stderr, "FIELD [%d] '%s' type %d, has %d %d %d %d items, and flags = 0x%hx, parent = %d, child = %d;\n",
+	d(0, g_printerr ("FIELD [%d] '%s' type %d, has %d %d %d %d items, and flags = 0x%hx, parent = %d, child = %d;\n",
 		field_num, name ? name->str : "<UNDEFINED>", index_type, count, grouped_items, base_items, std_items, flags,
 		group_parent, group_child););
 
@@ -388,7 +388,7 @@ xls_read_pivot_cache (XLSReadPivot *s, BiffQuery *q)
 		guint16 base_fields	= GSF_LE_GET_GUINT16 (q->data + 10);	/* base */
 		/* guint16 zero */
 		guint16 type		= GSF_LE_GET_GUINT16 (q->data + 16);
-		fprintf (stderr, "num_rec = %u;\nstream_id = %hu;\n"
+		g_printerr ("num_rec = %u;\nstream_id = %hu;\n"
 			 "rec per block = %hu;\nbase fields = %hu;\ntotal fields = %hu;\n"
 			 "last modified by = '%s';type = 0x%x, flags = 0x%x;\n",
 			 num_records, stream_id, rec_per_block, base_fields,
@@ -403,7 +403,7 @@ xls_read_pivot_cache (XLSReadPivot *s, BiffQuery *q)
 		g_object_set (s->cache, "refreshed-on", refreshedDate, NULL);
 		d (0, {
 			guint32 num_fmla	= GSF_LE_GET_GUINT32 (q->data + 8);
-			fprintf (stderr, "num_fmla %u : last refresh %s\n",
+			g_printerr ("num_fmla %u : last refresh %s\n",
 				 num_fmla, value_peek_string (refreshedDate));
 		});
 		go_val_free (refreshedDate);
@@ -413,7 +413,7 @@ xls_read_pivot_cache (XLSReadPivot *s, BiffQuery *q)
 		if (ms_biff_query_peek_next (q, &opcode) && opcode == BIFF_SXFDB && check_next_min (q, 12))
 			xls_read_pivot_cache_field (s, q, i);
 		else {
-			fprintf (stderr, "expected FDB not %hx\n", opcode);
+			g_printerr ("expected FDB not %hx\n", opcode);
 			return FALSE;
 		}
 
@@ -426,9 +426,9 @@ xls_read_pivot_cache (XLSReadPivot *s, BiffQuery *q)
 				go_data_cache_set_index (s->cache,
 					g_array_index (s->indexed, unsigned int, i), record_count,
 					GSF_LE_GET_GINT8 (q->data + i));
-				d (1, fprintf (stderr, "%hhu ", GSF_LE_GET_GINT8 (q->data + i)););
+				d (1, g_printerr ("%hhu ", GSF_LE_GET_GINT8 (q->data + i)););
 			}
-			d (1, fprintf (stderr, "\n"); );
+			d (1, g_printerr ("\n"); );
 
 			if (s->inlined->len > 0) {
 				GOValArray *vals = xls_read_pivot_cache_values (s, q, s->inlined->len, "inline");
@@ -475,13 +475,13 @@ xls_read_pivot_cache_by_id (XLSReadPivot *s, GsfInfile *container, guint16 n)
 	cache_stream = gsf_infile_child_by_name (GSF_INFILE (dir), name);
 	if (NULL != cache_stream) {
 		q = ms_biff_query_new (cache_stream);
-		d (0, fprintf (stderr, "{ /* PIVOT CACHE [%s] */\n", name););
+		d (0, g_printerr ("{ /* PIVOT CACHE [%s] */\n", name););
 		if (!xls_read_pivot_cache (s, q)) {
 			g_object_unref (s->cache);
 			s->cache = NULL;
 		} else
 			d (2, go_data_cache_dump (s->cache, NULL, NULL););
-		d (0, fprintf (stderr, "}; /* PIVOT CACHE [%s] */\n", name););
+		d (0, g_printerr ("}; /* PIVOT CACHE [%s] */\n", name););
 
 		ms_biff_query_destroy (q);
 		g_object_unref (cache_stream);
@@ -752,7 +752,7 @@ xls_read_SXVIEW (BiffQuery *q, ExcelReadSheet *esheet)
 		excel_get_text (imp, q->data + 44 + len, data_field_name_len,
 				&len, NULL, q->length - 44 - len));
 
-	d(0, fprintf (stderr, "Slicer in : %s named '%s';\n",
+	d(0, g_printerr ("Slicer in : %s named '%s';\n",
 		       range_as_string (&range), name ? name->str : "<UNDEFINED>"););
 	if (NULL != imp->pivot.slicer)
 		g_object_unref (imp->pivot.slicer);
diff --git a/plugins/excel/xlsx-read-drawing.c b/plugins/excel/xlsx-read-drawing.c
index 6c150e0..abb66c7 100644
--- a/plugins/excel/xlsx-read-drawing.c
+++ b/plugins/excel/xlsx-read-drawing.c
@@ -2133,7 +2133,7 @@ xlsx_drawing_pos (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
 	state->drawing_pos[xin->node->user_data.v_int] = val;
 	state->drawing_pos_flags |= 1 << xin->node->user_data.v_int;
 #if 0
-	fprintf (stderr, "%s %s %s = %" G_GINT64_FORMAT "\n",
+	g_printerr ("%s %s %s = %" G_GINT64_FORMAT "\n",
 		 (xin->node->user_data.v_int & TO) ? "To" : "From",
 		 (xin->node->user_data.v_int & ROW) ? "Row" : "Col",
 		 (xin->node->user_data.v_int & OFFSET) ? "Offset" : "",



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