Commit 9379ee6e authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Constify. (set_group_option_signals): Constify. (new_frame): Constify.

2000-06-23  Morten Welinder  <terra@diku.dk>

	* src/dialogs/dialog-analysis-tools.c (set_output_option_signals):
 	Constify.
	(set_group_option_signals): Constify.
	(new_frame): Constify.
	(error_in_entry): Constify.
	(new_dialog): Constify.

	* src/analysis-tools.c: major cleanup.  Eliminate fixed-size
 	buffers that might overflow; constify; plug leaks; improve
 	precision; produce numbers without going through strings.
	(set_cell_float, set_cell_int, set_cell_na, set_cell_printf): New
 	functions.

	* src/xml-io.c (xml_write_range): Constify.
	(xml_get_gnome_canvas_points): Mark code as bogus.
	(xml_set_gnome_canvas_points): Constify.  Improve space checks.
	(xml_set_value_int): Improve buffer sizing.
	(xml_set_value_string): Constify.
	(xml_set_color_value): Improve buffer sizing.

	* src/ranges.c (parse_range): Constify, simplify, optimise, and
 	secure.
	(range_parse): Fix strict case.

	* src/parse-util.c (parse_cell_name_or_range): Remove bogus cast.
parent c480f24f
2000-06-23 Morten Welinder <terra@diku.dk>
* src/dialogs/dialog-analysis-tools.c (set_output_option_signals):
Constify.
(set_group_option_signals): Constify.
(new_frame): Constify.
(error_in_entry): Constify.
(new_dialog): Constify.
* src/analysis-tools.c: major cleanup. Eliminate fixed-size
buffers that might overflow; constify; plug leaks; improve
precision; produce numbers without going through strings.
(set_cell_float, set_cell_int, set_cell_na, set_cell_printf): New
functions.
* src/xml-io.c (xml_write_range): Constify.
(xml_get_gnome_canvas_points): Mark code as bogus.
(xml_set_gnome_canvas_points): Constify. Improve space checks.
(xml_set_value_int): Improve buffer sizing.
(xml_set_value_string): Constify.
(xml_set_color_value): Improve buffer sizing.
* src/ranges.c (parse_range): Constify, simplify, optimise, and
secure.
(range_parse): Fix strict case.
* src/parse-util.c (parse_cell_name_or_range): Remove bogus cast.
2000-06-23 Jon K Hellan <hellan@acm.org>
(sheet_object_container_new_bonobo): As suggested by Michael:
......
2000-06-23 Morten Welinder <terra@diku.dk>
* src/dialogs/dialog-analysis-tools.c (set_output_option_signals):
Constify.
(set_group_option_signals): Constify.
(new_frame): Constify.
(error_in_entry): Constify.
(new_dialog): Constify.
* src/analysis-tools.c: major cleanup. Eliminate fixed-size
buffers that might overflow; constify; plug leaks; improve
precision; produce numbers without going through strings.
(set_cell_float, set_cell_int, set_cell_na, set_cell_printf): New
functions.
* src/xml-io.c (xml_write_range): Constify.
(xml_get_gnome_canvas_points): Mark code as bogus.
(xml_set_gnome_canvas_points): Constify. Improve space checks.
(xml_set_value_int): Improve buffer sizing.
(xml_set_value_string): Constify.
(xml_set_color_value): Improve buffer sizing.
* src/ranges.c (parse_range): Constify, simplify, optimise, and
secure.
(range_parse): Fix strict case.
* src/parse-util.c (parse_cell_name_or_range): Remove bogus cast.
2000-06-23 Jon K Hellan <hellan@acm.org>
(sheet_object_container_new_bonobo): As suggested by Michael:
......
Gnumeric 0.55
Gnumeric 0.57
Morten
* Cleanup analysis tool code.
* Eliminate many fixed limits in the code. (Still some to go.)
--------------------------------------------------------------------------
Gnumeric 0.55/0.56
Almer:
* Stf importer bug fixes and enhancements.
......
2000-06-23 Morten Welinder <terra@diku.dk>
* src/dialogs/dialog-analysis-tools.c (set_output_option_signals):
Constify.
(set_group_option_signals): Constify.
(new_frame): Constify.
(error_in_entry): Constify.
(new_dialog): Constify.
* src/analysis-tools.c: major cleanup. Eliminate fixed-size
buffers that might overflow; constify; plug leaks; improve
precision; produce numbers without going through strings.
(set_cell_float, set_cell_int, set_cell_na, set_cell_printf): New
functions.
* src/xml-io.c (xml_write_range): Constify.
(xml_get_gnome_canvas_points): Mark code as bogus.
(xml_set_gnome_canvas_points): Constify. Improve space checks.
(xml_set_value_int): Improve buffer sizing.
(xml_set_value_string): Constify.
(xml_set_color_value): Improve buffer sizing.
* src/ranges.c (parse_range): Constify, simplify, optimise, and
secure.
(range_parse): Fix strict case.
* src/parse-util.c (parse_cell_name_or_range): Remove bogus cast.
2000-06-23 Jon K Hellan <hellan@acm.org>
(sheet_object_container_new_bonobo): As suggested by Michael:
......
2000-06-23 Morten Welinder <terra@diku.dk>
* src/dialogs/dialog-analysis-tools.c (set_output_option_signals):
Constify.
(set_group_option_signals): Constify.
(new_frame): Constify.
(error_in_entry): Constify.
(new_dialog): Constify.
* src/analysis-tools.c: major cleanup. Eliminate fixed-size
buffers that might overflow; constify; plug leaks; improve
precision; produce numbers without going through strings.
(set_cell_float, set_cell_int, set_cell_na, set_cell_printf): New
functions.
* src/xml-io.c (xml_write_range): Constify.
(xml_get_gnome_canvas_points): Mark code as bogus.
(xml_set_gnome_canvas_points): Constify. Improve space checks.
(xml_set_value_int): Improve buffer sizing.
(xml_set_value_string): Constify.
(xml_set_color_value): Improve buffer sizing.
* src/ranges.c (parse_range): Constify, simplify, optimise, and
secure.
(range_parse): Fix strict case.
* src/parse-util.c (parse_cell_name_or_range): Remove bogus cast.
2000-06-23 Jon K Hellan <hellan@acm.org>
(sheet_object_container_new_bonobo): As suggested by Michael:
......
2000-06-23 Morten Welinder <terra@diku.dk>
* src/dialogs/dialog-analysis-tools.c (set_output_option_signals):
Constify.
(set_group_option_signals): Constify.
(new_frame): Constify.
(error_in_entry): Constify.
(new_dialog): Constify.
* src/analysis-tools.c: major cleanup. Eliminate fixed-size
buffers that might overflow; constify; plug leaks; improve
precision; produce numbers without going through strings.
(set_cell_float, set_cell_int, set_cell_na, set_cell_printf): New
functions.
* src/xml-io.c (xml_write_range): Constify.
(xml_get_gnome_canvas_points): Mark code as bogus.
(xml_set_gnome_canvas_points): Constify. Improve space checks.
(xml_set_value_int): Improve buffer sizing.
(xml_set_value_string): Constify.
(xml_set_color_value): Improve buffer sizing.
* src/ranges.c (parse_range): Constify, simplify, optimise, and
secure.
(range_parse): Fix strict case.
* src/parse-util.c (parse_cell_name_or_range): Remove bogus cast.
2000-06-23 Jon K Hellan <hellan@acm.org>
(sheet_object_container_new_bonobo): As suggested by Michael:
......
2000-06-23 Morten Welinder <terra@diku.dk>
* src/dialogs/dialog-analysis-tools.c (set_output_option_signals):
Constify.
(set_group_option_signals): Constify.
(new_frame): Constify.
(error_in_entry): Constify.
(new_dialog): Constify.
* src/analysis-tools.c: major cleanup. Eliminate fixed-size
buffers that might overflow; constify; plug leaks; improve
precision; produce numbers without going through strings.
(set_cell_float, set_cell_int, set_cell_na, set_cell_printf): New
functions.
* src/xml-io.c (xml_write_range): Constify.
(xml_get_gnome_canvas_points): Mark code as bogus.
(xml_set_gnome_canvas_points): Constify. Improve space checks.
(xml_set_value_int): Improve buffer sizing.
(xml_set_value_string): Constify.
(xml_set_color_value): Improve buffer sizing.
* src/ranges.c (parse_range): Constify, simplify, optimise, and
secure.
(range_parse): Fix strict case.
* src/parse-util.c (parse_cell_name_or_range): Remove bogus cast.
2000-06-23 Jon K Hellan <hellan@acm.org>
(sheet_object_container_new_bonobo): As suggested by Michael:
......
2000-06-23 Morten Welinder <terra@diku.dk>
* src/dialogs/dialog-analysis-tools.c (set_output_option_signals):
Constify.
(set_group_option_signals): Constify.
(new_frame): Constify.
(error_in_entry): Constify.
(new_dialog): Constify.
* src/analysis-tools.c: major cleanup. Eliminate fixed-size
buffers that might overflow; constify; plug leaks; improve
precision; produce numbers without going through strings.
(set_cell_float, set_cell_int, set_cell_na, set_cell_printf): New
functions.
* src/xml-io.c (xml_write_range): Constify.
(xml_get_gnome_canvas_points): Mark code as bogus.
(xml_set_gnome_canvas_points): Constify. Improve space checks.
(xml_set_value_int): Improve buffer sizing.
(xml_set_value_string): Constify.
(xml_set_color_value): Improve buffer sizing.
* src/ranges.c (parse_range): Constify, simplify, optimise, and
secure.
(range_parse): Fix strict case.
* src/parse-util.c (parse_cell_name_or_range): Remove bogus cast.
2000-06-23 Jon K Hellan <hellan@acm.org>
(sheet_object_container_new_bonobo): As suggested by Michael:
......
This diff is collapsed.
......@@ -87,7 +87,12 @@ typedef struct {
void autofit_column (data_analysis_output_t *dao, int col);
Cell *set_cell (data_analysis_output_t *dao, int col, int row, char *text);
void prepare_output (Workbook *wb, data_analysis_output_t *dao, char *name);
void set_cell (data_analysis_output_t *dao, int col, int row, const char *text);
void set_cell_printf (data_analysis_output_t *dao, int col, int row, const char *fmt, ...)
G_GNUC_PRINTF (4, 5);
void set_cell_float (data_analysis_output_t *dao, int col, int row, float_t v);
void set_cell_int (data_analysis_output_t *dao, int col, int row, int v);
void set_cell_na (data_analysis_output_t *dao, int col, int row);
void prepare_output (Workbook *wb, data_analysis_output_t *dao, const char *name);
#endif
......@@ -129,7 +129,7 @@ static const DistributionStrs distribution_strs[] = {
};
static void
new_sheet_toggled(GtkWidget *widget, data_analysis_output_type_t *type)
new_sheet_toggled (GtkWidget *widget, data_analysis_output_type_t *type)
{
if (GTK_TOGGLE_BUTTON (widget)->active) {
*type = NewSheetOutput;
......@@ -137,7 +137,7 @@ new_sheet_toggled(GtkWidget *widget, data_analysis_output_type_t *type)
}
static void
new_workbook_toggled(GtkWidget *widget, data_analysis_output_type_t *type)
new_workbook_toggled (GtkWidget *widget, data_analysis_output_type_t *type)
{
if (GTK_TOGGLE_BUTTON (widget)->active) {
*type = NewWorkbookOutput;
......@@ -145,7 +145,7 @@ new_workbook_toggled(GtkWidget *widget, data_analysis_output_type_t *type)
}
static void
range_output_toggled(GtkWidget *widget, data_analysis_output_type_t *type)
range_output_toggled (GtkWidget *widget, data_analysis_output_type_t *type)
{
if (GTK_TOGGLE_BUTTON (widget)->active) {
*type = RangeOutput;
......@@ -160,7 +160,7 @@ focus_on_entry (GtkWidget *widget, GtkWidget *entry)
}
static void
columns_toggled(GtkWidget *widget, int *group)
columns_toggled (GtkWidget *widget, int *group)
{
if (GTK_TOGGLE_BUTTON (widget)->active) {
*group = 0;
......@@ -168,7 +168,7 @@ columns_toggled(GtkWidget *widget, int *group)
}
static void
rows_toggled(GtkWidget *widget, int *group)
rows_toggled (GtkWidget *widget, int *group)
{
if (GTK_TOGGLE_BUTTON (widget)->active) {
*group = 1;
......@@ -185,7 +185,7 @@ output_range_selected (GtkWidget *widget, GdkEventFocus *event,
}
static int
set_output_option_signals (GladeXML *gui, data_analysis_output_t *dao, char *n)
set_output_option_signals (GladeXML *gui, data_analysis_output_t *dao, const char *n)
{
GtkWidget *radiobutton;
GtkWidget *entry;
......@@ -235,7 +235,7 @@ set_output_option_signals (GladeXML *gui, data_analysis_output_t *dao, char *n)
}
static int
set_group_option_signals (GladeXML *gui, int *group, char *n)
set_group_option_signals (GladeXML *gui, int *group, const char *n)
{
GtkWidget *radiobutton;
char buf[256];
......@@ -263,7 +263,7 @@ set_group_option_signals (GladeXML *gui, int *group, char *n)
}
static void
checkbutton_toggled(GtkWidget *widget, gboolean *flag)
checkbutton_toggled (GtkWidget *widget, gboolean *flag)
{
*flag = GTK_TOGGLE_BUTTON (widget)->active;
}
......@@ -400,7 +400,7 @@ static char *sample_method_ops [] = {
};
static GtkWidget *
new_dialog(char *name)
new_dialog (const char *name)
{
GtkWidget *dialog;
......@@ -416,12 +416,12 @@ new_dialog(char *name)
}
static GtkWidget *
new_frame(char *name, GtkWidget *target_box)
new_frame (const char *name, GtkWidget *target_box)
{
GtkWidget *frame, *box;
frame = gtk_frame_new(name);
box = gtk_vbox_new(FALSE, 0);
frame = gtk_frame_new (name);
box = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (frame), box);
gtk_box_pack_start (GTK_BOX (target_box), frame, FALSE, FALSE, 0);
......@@ -429,14 +429,14 @@ new_frame(char *name, GtkWidget *target_box)
}
static void
error_in_entry(Workbook *wb, GtkWidget *entry, char *err_str)
error_in_entry (Workbook *wb, GtkWidget *entry, const char *err_str)
{
gnumeric_notice (wb, GNOME_MESSAGE_BOX_ERROR, err_str);
gtk_widget_grab_focus (entry);
gtk_entry_set_position(GTK_ENTRY (entry), 0);
gtk_entry_select_region(GTK_ENTRY (entry), 0,
GTK_ENTRY(entry)->text_length);
gtk_entry_set_position (GTK_ENTRY (entry), 0);
gtk_entry_select_region (GTK_ENTRY (entry), 0,
GTK_ENTRY(entry)->text_length);
}
static void
......@@ -471,8 +471,8 @@ add_check_buttons (GtkWidget *box, check_button_t *cbs)
}
static int
parse_output(int output, Sheet *sheet,
GtkWidget *entry, Workbook *wb, data_analysis_output_t *dao)
parse_output (int output, Sheet *sheet,
GtkWidget *entry, Workbook *wb, data_analysis_output_t *dao)
{
char *text;
Range range;
......@@ -509,7 +509,7 @@ parse_output(int output, Sheet *sheet,
}
static GtkWidget *
add_output_frame(GtkWidget *box, GSList **output_ops)
add_output_frame (GtkWidget *box, GSList **output_ops)
{
GtkWidget *r, *hbox, *output_range_entry;
......@@ -541,7 +541,7 @@ add_output_frame(GtkWidget *box, GSList **output_ops)
}
static GSList *
add_groupped_by(GtkWidget *box)
add_groupped_by (GtkWidget *box)
{
GtkWidget *r, *groupped_label, *group_box, *hbox;
GSList *group_ops;
......
......@@ -394,7 +394,7 @@ parse_cell_name_or_range (const char *cell_str, int *col, int *row, int *cols, i
*cols = *rows = 1;
if (!parse_cell_name (cell_str, col, row, strict, NULL)) {
if (!parse_range ((char *) cell_str, col, row, &e_col, &e_row))
if (!parse_range (cell_str, col, row, &e_col, &e_row))
return FALSE;
else {
*cols = e_col - *col + 1;
......
......@@ -41,6 +41,7 @@ range_init (Range *r, int start_col, int start_row,
* range_parse:
* @sheet: the sheet where the cell range is evaluated
* @range: a range specification (ex: "A1", "A1:C3").
* @strict: if FALSE, allow extra characters after range text.
*
* Returns a (Value *) of type VALUE_CELLRANGE if the @range was
* succesfully parsed or NULL on failure.
......@@ -49,9 +50,8 @@ Value *
range_parse (Sheet *sheet, const char *range, gboolean strict)
{
CellRef a, b;
Value *v;
int n_read = 0;
int n_read;
g_return_val_if_fail (range != NULL, FALSE);
a.col_relative = 0;
......@@ -59,48 +59,39 @@ range_parse (Sheet *sheet, const char *range, gboolean strict)
a.row_relative = 0;
b.row_relative = 0;
if (!parse_cell_name (range, &a.col, &a.row, strict, &n_read))
if (!parse_cell_name (range, &a.col, &a.row, FALSE, &n_read))
return FALSE;
a.sheet = sheet;
if (range [n_read] == ':'){
if (!parse_cell_name (&range [n_read+1], &b.col, &b.row, strict, NULL))
if (range[n_read] == ':') {
if (!parse_cell_name (&range[n_read+1], &b.col, &b.row, strict, NULL))
return FALSE;
b.sheet = sheet;
} else
} else if (strict && range[n_read])
return FALSE;
else
b = a;
/*
* We can dummy out the calling cell because we know that both
* refs use the same mode. This will handle inversions.
*/
v = value_new_cellrange (&a, &b, 0, 0);
return v;
return value_new_cellrange (&a, &b, 0, 0);
}
/* Pulled from dialog-analysis-tools.c
* Should be merged with range_parse
*/
int
parse_range (char *text, int *start_col, int *start_row,
parse_range (const char *text, int *start_col, int *start_row,
int *end_col, int *end_row)
{
char buf[256];
char *p;
strcpy(buf, text);
p = strchr(buf, ':');
if (p == NULL)
return 0;
*p = '\0';
if (!parse_cell_name (buf, start_col, start_row, TRUE, NULL))
return 0;
if (!parse_cell_name (p+1, end_col, end_row, TRUE, NULL))
return 0;
return 1;
int len;
return (parse_cell_name (text, start_col, start_row, FALSE, &len) &&
text[len] == ':' &&
parse_cell_name (text + len + 1, end_col, end_row, TRUE, NULL));
}
/**
......
......@@ -58,7 +58,7 @@
Range *range_init (Range *r, int start_col, int start_row,
int end_col, int end_row);
Value *range_parse (Sheet *sheet, const char *range, gboolean strict);
int parse_range (char *text, int *start_col, int *start_row,
int parse_range (const char *text, int *start_col, int *start_row,
int *end_col, int *end_row);
GSList *range_list_parse (Sheet *sheet, const char *cell_name_str, gboolean strict);
void range_list_destroy (GSList *ranges);
......
......@@ -881,7 +881,6 @@ solver_answer_report (Workbook *wb, Sheet *sheet, GSList *ov,
CellList *cell_list = param->input_cells;
Cell *cell;
char buf[256];
char *str;
int row, i;
......@@ -902,16 +901,15 @@ solver_answer_report (Workbook *wb, Sheet *sheet, GSList *ov,
set_bold (dao.sheet, 0, 2, 3, 2);
/* Set `Cell' field */
set_cell (&dao, 0, 3, (char*) cell_name(param->target_cell));
set_cell (&dao, 0, 3, cell_name (param->target_cell));
/* Set `Name' field */
set_cell (&dao, 1, 3, find_name (sheet, param->target_cell->col_info->pos,
param->target_cell->row_info->pos));
/* Set `Original Value' field */
sprintf (buf, "%f", ov_target);
set_cell (&dao, 2, 3, buf);
set_cell_float (&dao, 2, 3, ov_target);
/* Set `Final Value' field */
cell = sheet_cell_fetch (sheet, param->target_cell->col_info->pos,
param->target_cell->row_info->pos);
......@@ -933,7 +931,7 @@ solver_answer_report (Workbook *wb, Sheet *sheet, GSList *ov,
cell = (Cell *) cell_list->data;
/* Set `Cell' column */
set_cell (&dao, 0, row, (char *) cell_name(cell));
set_cell (&dao, 0, row, cell_name (cell));
/* Set `Name' column */
set_cell (&dao, 1, row, find_name (sheet, cell->col_info->pos,
......@@ -989,7 +987,7 @@ solver_answer_report (Workbook *wb, Sheet *sheet, GSList *ov,
}
/* Set `Cell' column */
set_cell (&dao, 0, row, (char *) cell_coord_name (tc, tr));
set_cell (&dao, 0, row, cell_coord_name (tc, tr));
/* Set `Name' column */
set_cell (&dao, 1, row, find_name (sheet, tc, tr));
......@@ -1008,14 +1006,13 @@ solver_answer_report (Workbook *wb, Sheet *sheet, GSList *ov,
cell = sheet_cell_fetch (sheet, tc, tr);
lhs = value_get_as_float (cell->value);
if (fabs (lhs-rhs) < 0.001)
if (fabs (lhs - rhs) < 0.001)
set_cell (&dao, 4, row, _("Binding"));
else
set_cell (&dao, 4, row, _("Not Binding"));
/* Set `Slack' column */
sprintf(buf, "%f", fabs (lhs-rhs));
set_cell (&dao, 5, row, buf);
set_cell_float (&dao, 5, row, fabs (lhs-rhs));
/* Go to next row */
++row;
......@@ -1042,7 +1039,7 @@ solver_sensitivity_report (Workbook *wb, Sheet *sheet, float_t *x,
CellList *cell_list = param->input_cells;
Cell *cell;
char *str, buf[256];
char *str;
int row=0, i;
dao.type = NewSheetOutput;
......@@ -1067,7 +1064,7 @@ solver_sensitivity_report (Workbook *wb, Sheet *sheet, float_t *x,
cell = (Cell *) cell_list->data;
/* Set `Cell' column */
set_cell (&dao, 0, row, (char *) cell_name(cell));
set_cell (&dao, 0, row, cell_name (cell));
/* Set `Name' column */
set_cell (&dao, 1, row, find_name (sheet, cell->col_info->pos,
......@@ -1081,12 +1078,10 @@ solver_sensitivity_report (Workbook *wb, Sheet *sheet, float_t *x,
g_free (str);
/* Set `Reduced Cost' column */
sprintf(buf, "%f", x[i]);
set_cell (&dao, 3, row, buf);
set_cell_float (&dao, 3, row, x[i]);
/* Set `Objective Coefficient' column */
sprintf(buf, "%f", x[i]);
set_cell (&dao, 4, row, buf);
set_cell_float (&dao, 4, row, x[i]);
/* Go to next row */
cell_list = cell_list->next;
......@@ -1119,7 +1114,7 @@ solver_sensitivity_report (Workbook *wb, Sheet *sheet, float_t *x,
SolverConstraint *c = (SolverConstraint *) constraints->data;
/* Set `Cell' column */
set_cell (&dao, 0, row, (char *) cell_pos_name (&c->lhs));
set_cell (&dao, 0, row, cell_pos_name (&c->lhs));
/* Set `Name' column */
set_cell (&dao, 1, row, find_name (sheet, c->lhs.col,
......@@ -1133,8 +1128,7 @@ solver_sensitivity_report (Workbook *wb, Sheet *sheet, float_t *x,
#if 0
/* Set `Shadow Prize' column */
sprintf(buf, "%f", shadow_prize[i]);
set_cell (&dao, 3, row, buf);
set_cell_float (&dao, 3, row, shadow_prize[i]);
#endif
/* Set `R.H. Side Value' column */
......
......@@ -11,6 +11,7 @@
#include <gnome.h>
#include <locale.h>
#include <math.h>
#include <limits.h>
#include "gnumeric.h"
#include "gnome-xml/parser.h"
#include "gnome-xml/parserInternals.h"
......@@ -256,7 +257,6 @@ xml_get_coordinate (xmlNodePtr node, const char *name, double *x, double *y)
{
int res;
char *ret;
float X, Y;
ret = xml_value_get (node, name);
if (ret == NULL) return 0;
......@@ -311,6 +311,7 @@ xml_get_gnome_canvas_points (xmlNodePtr node, const char *name)
ptr++;
if (*ptr == 0)
break;
THIS_DOES_NOT_LOOK_RIGHT = 1;
res = sscanf (ptr, "(%lf %lf)", &coord[index], &coord[index + 1]);
if (res != 2)
break;
......@@ -335,18 +336,19 @@ xml_get_gnome_canvas_points (xmlNodePtr node, const char *name)
*/
static void
xml_set_gnome_canvas_points (xmlNodePtr node, const char *name,
GnomeCanvasPoints *val)
const GnomeCanvasPoints *val)
{
xmlNodePtr child;
char *str, *base;
char *tstr;
int i;
int width1 = 30 + DBL_DIG;
if (val == NULL)
return;
if ((val->num_points < 0) || (val->num_points > 5000))
if (val->num_points < 0 || val->num_points > (INT_MAX - 1) / width1)
return;
base = str = g_malloc (val->num_points * 30 * sizeof (char) + 1);
base = str = g_malloc (val->num_points * width1 + 1);
if (str == NULL)
return;
for (i = 0; i < val->num_points; i++){
......@@ -404,7 +406,7 @@ xml_set_value (xmlNodePtr node, const char *name, const char *val)
* the content of a child.
*/
static void
xml_set_value_string (xmlNodePtr node, const char *name, String *val)
xml_set_value_string (xmlNodePtr node, const char *name, const String *val)
{
char *ret;
xmlNodePtr child;
......@@ -435,9 +437,9 @@ xml_set_value_int (xmlNodePtr node, const char *name, int val)
{
char *ret;
xmlNodePtr child;
char str[101];
char str[4 * sizeof (int)];
snprintf (str, 100, "%d", val);
sprintf (str, "%d", val);
ret = xmlGetProp (node, name);
if (ret != NULL){
xmlFree (ret);
......@@ -455,37 +457,6 @@ xml_set_value_int (xmlNodePtr node, const char *name, int val)
xmlSetProp (node, name, str);
}
#if 0
/*
* Set a float value for a node either carried as an attibute or as
* the content of a child.
*/
static void
xml_set_value_float (xmlNodePtr node, const char *name, float val)
{
char *ret;
xmlNodePtr child;
char str[101];
snprintf (str, 100, "%f", val);
ret = xmlGetProp (node, name);
if (ret != NULL){
xmlFree (ret);
xmlSetProp (node, name, str);
return;
}
child = node->childs;
while (child != NULL){
if (!strcmp (child->name, name)){
xmlNodeSetContent (child, str);
return;
}
child = child->next;
}
xmlSetProp (node, name, str);
}
#endif
/*
* Set a double value for a node either carried as an attibute or as
* the content of a child.
......@@ -616,7 +587,7 @@ xml_read_range (xmlNodePtr tree, Range *res)
}
static void
xml_write_range (xmlNodePtr tree, Range *value)
xml_write_range (xmlNodePtr tree, const Range *value)
{
xml_set_value_int (tree, "startCol", value->start.col);
xml_set_value_int (tree, "startRow", value->start.row);
......@@ -701,9 +672,9 @@ xml_set_color_value (xmlNodePtr node, const char *name, StyleColor *val)
{
char *ret;
xmlNodePtr child;
char str[101];
char str[4 * sizeof (val->color)];
snprintf (str, 100, "%X:%X:%X", val->color.red, val->color.green, val->color.blue);
sprintf (str, "%X:%X:%X", val->color.red, val->color.green, val->color.blue);
ret = xmlGetProp (node, name);
if (ret != NULL){
xmlFree (ret);
......@@ -2338,8 +2309,6 @@ xml_sheet_write (parse_xml_context_t *ctxt, Sheet *sheet)
xmlNodePtr styles;
xmlNodePtr solver;
GList *style_regions;
char str [50];
char *tstr;
/*
......@@ -2357,12 +2326,15 @@ xml_sheet_write (parse_xml_context_t *ctxt, Sheet *sheet)
xmlNewChild (cur, ctxt->ns, "Name", tstr);
if (tstr) xmlFree (tstr);
sprintf (str, "%d", sheet->cols.max_used);
xmlNewChild (cur, ctxt->ns, "MaxCol", str);
sprintf (str, "%d", sheet->rows.max_used);
xmlNewChild (cur, ctxt->ns, "MaxRow", str);
sprintf (str, "%f", sheet->last_zoom_factor_used);
xmlNewChild (cur, ctxt->ns, "Zoom", str);
{