Commit 3743f057 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Major constification. (-Wwrite-strings)

2002-02-20  Morten Welinder  <terra@diku.dk>

        * src/parser.y (yyerror): Constify.

        * src/xml-io.c (xml_node_set_print_unit): Constify.
        (xml_read_print_repeat_range): Constify.

        * src/summary.c (summary_item_name): Constify.

        * src/print-info.c (predefined_formats, render_ops): Constify.

        * src/expr-name.c (builtins): Constify.

        * src/complex.c (complex_to_string): Constify.

        * src/commands.c (cmd_set_text): Constify.
        (cmd_area_set_text): Constify.

        * src/mstyle.c (mstyle_to_string): Missing g_strdup added for
        sanity check, just in case.
        * src/summary.c (summary_item_as_text): Ditto.
        * src/value.c (value_get_as_string): Ditto.

        * configure.in (CFLAGS): Add -Wwrite-strings, if possible.

        * src/gui-util.c (gnumeric_dialog_raise_if_exists): Constify.
parent 01142b35
2002-02-20 Morten Welinder <terra@diku.dk>
* src/parser.y (yyerror): Constify.
* src/xml-io.c (xml_node_set_print_unit): Constify.
(xml_read_print_repeat_range): Constify.
* src/summary.c (summary_item_name): Constify.
* src/print-info.c (predefined_formats, render_ops): Constify.
* src/expr-name.c (builtins): Constify.
* src/complex.c (complex_to_string): Constify.
* src/commands.c (cmd_set_text): Constify.
(cmd_area_set_text): Constify.
* src/mstyle.c (mstyle_to_string): Missing g_strdup added for
sanity check, just in case.
* src/summary.c (summary_item_as_text): Ditto.
* src/value.c (value_get_as_string): Ditto.
* configure.in (CFLAGS): Add -Wwrite-strings, if possible.
* src/gui-util.c (gnumeric_dialog_raise_if_exists): Constify.
2002-02-20 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/analysis-tools.c (regression_tool) : use only values
......
2002-02-20 Morten Welinder <terra@diku.dk>
* src/parser.y (yyerror): Constify.
* src/xml-io.c (xml_node_set_print_unit): Constify.
(xml_read_print_repeat_range): Constify.
* src/summary.c (summary_item_name): Constify.
* src/print-info.c (predefined_formats, render_ops): Constify.
* src/expr-name.c (builtins): Constify.
* src/complex.c (complex_to_string): Constify.
* src/commands.c (cmd_set_text): Constify.
(cmd_area_set_text): Constify.
* src/mstyle.c (mstyle_to_string): Missing g_strdup added for
sanity check, just in case.
* src/summary.c (summary_item_as_text): Ditto.
* src/value.c (value_get_as_string): Ditto.
* configure.in (CFLAGS): Add -Wwrite-strings, if possible.
* src/gui-util.c (gnumeric_dialog_raise_if_exists): Constify.
2002-02-20 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/analysis-tools.c (regression_tool) : use only values
......
2002-02-20 Morten Welinder <terra@diku.dk>
* src/parser.y (yyerror): Constify.
* src/xml-io.c (xml_node_set_print_unit): Constify.
(xml_read_print_repeat_range): Constify.
* src/summary.c (summary_item_name): Constify.
* src/print-info.c (predefined_formats, render_ops): Constify.
* src/expr-name.c (builtins): Constify.
* src/complex.c (complex_to_string): Constify.
* src/commands.c (cmd_set_text): Constify.
(cmd_area_set_text): Constify.
* src/mstyle.c (mstyle_to_string): Missing g_strdup added for
sanity check, just in case.
* src/summary.c (summary_item_as_text): Ditto.
* src/value.c (value_get_as_string): Ditto.
* configure.in (CFLAGS): Add -Wwrite-strings, if possible.
* src/gui-util.c (gnumeric_dialog_raise_if_exists): Constify.
2002-02-20 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/analysis-tools.c (regression_tool) : use only values
......
......@@ -46,7 +46,7 @@ AC_PATH_PROG(GDK_PIXBUF_CSOURCE, gdk-pixbuf-csource)
GNOME_COMPILE_WARNINGS
set_mode_warnings=yes
if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
for option in -Wsign-promo -Wsign-compare -Wpointer-arith -Wnested-externs -Wchar-subscripts ; do
for option in -Wsign-promo -Wsign-compare -Wpointer-arith -Wnested-externs -Wchar-subscripts -Wwrite-strings; do
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $option"
AC_MSG_CHECKING([whether gcc understands $option])
......
......@@ -627,7 +627,7 @@ cmd_set_text (WorkbookControl *wbc,
{
GObject *obj;
CmdSetText *me;
gchar *pad = "";
const gchar *pad = "";
gchar *text, *corrected_text, *tmp, c = '\0';
Cell const *cell;
......@@ -826,7 +826,8 @@ cmd_area_set_text (WorkbookControl *wbc, ParsePos const *pos,
{
GObject *obj;
CmdAreaSetText *me;
gchar *text, *pad = "";
gchar *text;
const gchar *pad = "";
obj = g_object_new (CMD_AREA_SET_TEXT_TYPE, NULL);
me = CMD_AREA_SET_TEXT (obj);
......
......@@ -23,8 +23,8 @@ complex_to_string (const complex_t *src, const char *reformat,
{
char *re_buffer = NULL;
char *im_buffer = NULL;
char *sign = "";
char *suffix = "";
const char *sign = "";
const char *suffix = "";
char *res;
char suffix_buffer[2];
......
2002-02-20 Morten Welinder <terra@diku.dk>
* dialog-printer-setup.c (do_setup_page): Constify.
* dialog-paste-special.c (paste_types, paste_ops): Constify.
* dialog-cell-format.c (cb_validation_error_action_deactivate):
Constify.
* dialog-analysis-tools.c (dialog_tool_init): Constify.
* dialog-stf-preview.c (stf_preview_draw_box): Constify.
(stf_preview_draw_line): Constify.
(stf_preview_draw_text): Constify.
* dialog-printer-setup.c (unit_editor_configure): Constify.
2002-02-18 Jody Goldberg <jody@gnome.org>
* dialog-cell-format.c (fmt_dialog_impl) : fix signature
......
......@@ -485,7 +485,8 @@ dialog_tool_init_buttons (GenericToolState *state, GtkSignalFunc ok_function)
*
**/
static gboolean
dialog_tool_init (GenericToolState *state, char *gui_name, char *dialog_name,
dialog_tool_init (GenericToolState *state, const char *gui_name,
const char *dialog_name,
GtkSignalFunc ok_function, GtkSignalFunc sensitivity_cb,
GnumericExprEntryFlags flags)
{
......
......@@ -2064,7 +2064,7 @@ cb_validation_error_action_deactivate (GtkMenuShell *ignored, FormatState *state
gtk_widget_set_sensitive (GTK_WIDGET (state->validation.error.msg), flag);
if (flag) {
char *s = NULL;
const char *s = NULL;
switch (index) {
case 1 : s = "gnome-error.png"; break;
......@@ -2076,10 +2076,10 @@ cb_validation_error_action_deactivate (GtkMenuShell *ignored, FormatState *state
}
if (s != NULL) {
s = gnome_pixmap_file (s);
g_return_if_fail (s != NULL);
gtk_image_set_from_file (state->validation.error.image, s);
g_free (s);
char *sfile = gnome_pixmap_file (s);
g_return_if_fail (sfile != NULL);
gtk_image_set_from_file (state->validation.error.image, sfile);
g_free (sfile);
}
gtk_widget_show (GTK_WIDGET (state->validation.error.image));
} else
......
......@@ -18,7 +18,7 @@
#define BUTTON_PASTE_LINK 0
static struct {
static const struct {
char *name;
int disables_second_group;
} paste_types[] = {
......@@ -29,7 +29,7 @@ static struct {
{ NULL, 0 }
};
static char *paste_ops[] = {
static const char *paste_ops[] = {
N_("None"),
N_("Add "),
N_("Subtract"),
......
......@@ -733,7 +733,8 @@ unit_deactivated (GtkSpinButton *spin_button,
static void
unit_editor_configure (UnitInfo *target, PrinterSetupState *state,
char *spin_name, double init_points, UnitName unit)
const char *spin_name,
double init_points, UnitName unit)
{
GtkSpinButton *spin;
UnitInfo_cbdata *cbdata;
......@@ -1467,7 +1468,7 @@ do_setup_page (PrinterSetupState *state)
GtkCombo *first_page_combo, *paper_size_combo;
GtkTable *table;
GladeXML *gui;
char *toggle;
const char *toggle;
gui = state->gui;
table = GTK_TABLE (glade_xml_get_widget (gui, "table-orient"));
......
......@@ -49,7 +49,8 @@
* returns : the width of the rendered text
**/
static double
stf_preview_draw_text (GnomeCanvasGroup *group, char *text, GdkFont *font, char *color, double x, double y)
stf_preview_draw_text (GnomeCanvasGroup *group, const char *text,
GdkFont *font, const char *color, double x, double y)
{
GnomeCanvasText *canvastext;
double textwidth;
......@@ -87,7 +88,8 @@ stf_preview_draw_text (GnomeCanvasGroup *group, char *text, GdkFont *font, char
* returns : nothing
**/
static void
stf_preview_draw_line (GnomeCanvasGroup *group, char *color, double x1, double y1, double x2, double y2)
stf_preview_draw_line (GnomeCanvasGroup *group, const char *color,
double x1, double y1, double x2, double y2)
{
GnomeCanvasPoints *points = gnome_canvas_points_new (2);
......@@ -121,7 +123,8 @@ stf_preview_draw_line (GnomeCanvasGroup *group, char *color, double x1, double y
* returns : nothing
**/
static void
stf_preview_draw_box (GnomeCanvasGroup *group, char *color, double x1, double y1, double x2, double y2)
stf_preview_draw_box (GnomeCanvasGroup *group, const char *color,
double x1, double y1, double x2, double y2)
{
gnome_canvas_item_new (group, GNOME_TYPE_CANVAS_RECT,
"x1", x1, "y1", y1,
......
......@@ -532,8 +532,8 @@ name_sheet_title (FunctionEvalInfo *ei, Value **args)
return value_new_string (ei->pos->sheet->name_quoted);
}
static struct {
gchar *name;
static const struct {
gchar *name;
FunctionArgs *fn;
} builtins[] =
{
......
......@@ -490,7 +490,7 @@ gnumeric_keyed_dialog (WorkbookControlGUI *wbcg, GtkWindow *dialog, const char *
* Returns TRUE if dialog found, FALSE if not.
*/
gboolean
gnumeric_dialog_raise_if_exists (WorkbookControlGUI *wbcg, char *key)
gnumeric_dialog_raise_if_exists (WorkbookControlGUI *wbcg, const char *key)
{
GtkWidget *dialog;
......
......@@ -28,7 +28,7 @@ void gnumeric_keyed_dialog (WorkbookControlGUI *wbcg,
GtkWindow *dialog,
const char *key);
gboolean gnumeric_dialog_raise_if_exists (WorkbookControlGUI *wbcg,
char *key);
const char *key);
void gnumeric_editable_enters (GtkWindow *window, GtkWidget *w);
void gnumeric_combo_enters (GtkWindow *window, GtkCombo *combo);
void gnumeric_toolbar_insert_with_eventbox (GtkToolbar *toolbar,
......
......@@ -851,7 +851,7 @@ mstyle_to_string (const MStyle *style)
GString *ans;
char *txt_ans;
g_return_val_if_fail (style != NULL, "(null)");
g_return_val_if_fail (style != NULL, g_strdup ("(null)"));
ans = g_string_new ("Elements : ");
for (i = 0; i < MSTYLE_ELEMENT_MAX; i++) {
......
......@@ -183,7 +183,7 @@ unregister_allocation (void const *data)
/* Bison/Yacc internals */
static int yylex (void);
static int yyerror (char *s);
static int yyerror (const char *s);
typedef struct {
/* The expression being parsed */
......@@ -957,7 +957,7 @@ yylex (void)
}
int
yyerror (char *s)
yyerror (const char *s)
{
#if 0
printf ("Error: %s\n", s);
......
......@@ -20,7 +20,7 @@
#include <libgnome/gnome-config.h>
#include <string.h>
static PrintHF predefined_formats [] = {
static const PrintHF predefined_formats [] = {
{ "", "", "" },
{ "", N_("Page &[PAGE]"), "" },
{ "", N_("Page &[PAGE] of &[PAGES]"), "" },
......@@ -574,7 +574,7 @@ render_time (GString *target, HFRenderInfo *info, const char *args)
render_value_with_format (target, time_format, info);
}
static struct {
static const struct {
char *name;
void (*render)(GString *target, HFRenderInfo *info, const char *args);
} render_ops [] = {
......
......@@ -6,7 +6,7 @@
/*
* Callback functions
*/
typedef gboolean (* StfEWriteFunc) (char *string, gpointer data);
typedef gboolean (* StfEWriteFunc) (const char *string, gpointer data);
typedef enum {
TERMINATOR_TYPE_LINEFEED = 1 << 0, /* \n */
......
......@@ -24,7 +24,7 @@
* The field names are summary_item_name[i] prefixed with "glade_".
*
*/
gchar *summary_item_name[] = {
const gchar *summary_item_name[] = {
"codepage",
"title",
"subject",
......@@ -128,7 +128,7 @@ summary_item_as_text (const SummaryItem *sit)
if (sit->v.boolean == 1)
return g_strdup ("True");
return "Unrecognized boolean value";
return g_strdup ("Unrecognized boolean value");
case SUMMARY_SHORT:
return g_strdup_printf ("%d", sit->v.short_i);
......
......@@ -56,7 +56,7 @@ typedef enum { SUMMARY_I_CODEPAGE,
SUMMARY_I_MAX } SummaryItemBuiltin;
/* Builtin names: use summary_item_name[SUMMARY_I_TITLE] */
extern gchar *summary_item_name[SUMMARY_I_MAX];
extern const gchar *summary_item_name[SUMMARY_I_MAX];
/*
* Each Summary Item has a name it is hashed on,
......
......@@ -541,7 +541,7 @@ value_get_as_string (Value const *v)
g_return_val_if_fail (val->type == VALUE_STRING ||
val->type == VALUE_FLOAT ||
val->type == VALUE_INTEGER,
"Duff Array contents");
g_strdup ("Duff Array contents"));
if (x)
g_string_append_c (str, row_sep);
if (val->type == VALUE_STRING)
......
......@@ -273,7 +273,7 @@ xml_node_set_print_unit (xmlNodePtr node, char const *name,
PrintUnit const *pu)
{
xmlNodePtr child;
char *txt = "points";
const char *txt = "points";
xmlChar *tstr;
if (pu == NULL || name == NULL)
......@@ -1031,7 +1031,8 @@ xml_read_print_margins (XmlParseContext *ctxt, xmlNodePtr tree)
}
static void
xml_read_print_repeat_range (XmlParseContext *ctxt, xmlNodePtr tree, char *name, PrintRepeatRange *range)
xml_read_print_repeat_range (XmlParseContext *ctxt, xmlNodePtr tree,
const char *name, PrintRepeatRange *range)
{
xmlNodePtr child;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment