Revision: 4862 http://geany.svn.sourceforge.net/geany/?rev=4862&view=rev Author: eht16 Date: 2010-04-25 17:43:39 +0000 (Sun, 25 Apr 2010)
Log Message: ----------- Make string arguments const where appropriate (patch by Colomban Wendling, thanks).
Modified Paths: -------------- trunk/ChangeLog trunk/src/build.c trunk/src/build.h trunk/src/callbacks.c trunk/src/dialogs.c trunk/src/editor.c trunk/src/encodings.c trunk/src/encodings.h trunk/src/gb.c trunk/src/geanyentryaction.c trunk/src/geanymenubuttonaction.c trunk/src/geanyobject.c trunk/src/geanywraplabel.c trunk/src/keyfile.c trunk/src/project.c trunk/src/sidebar.c trunk/src/socket.c trunk/src/symbols.c trunk/src/templates.c trunk/src/ui_utils.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-04-25 17:43:09 UTC (rev 4861) +++ trunk/ChangeLog 2010-04-25 17:43:39 UTC (rev 4862) @@ -16,6 +16,13 @@ plugins/saveactions.c: Make string arguments const where appropriate (patch by Colomban Wendling, thanks). + * src/build.c, src/build.h, src/callbacks.c, src/editor.c, + src/encodings.c, src/encodings.h, src/gb.c, src/geanyentryaction.c, + src/geanymenubuttonaction.c, src/geanyobject.c, src/geanywraplabel.c, + src/keyfile.c, src/project.c, src/sidebar.c, src/socket.c, + src/symbols.c, src/templates.c, src/ui_utils.c: + Make string arguments const where appropriate (patch by + Colomban Wendling, thanks).
2010-04-22 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/src/build.c =================================================================== --- trunk/src/build.c 2010-04-25 17:43:09 UTC (rev 4861) +++ trunk/src/build.c 2010-04-25 17:43:39 UTC (rev 4862) @@ -211,7 +211,7 @@
/* for debug only, print the commands structures in priority order */ -static void printfcmds() +static void printfcmds(void) { GeanyFiletype *ft = NULL; GeanyDocument *doc; @@ -752,7 +752,8 @@ GeanyProject *project = app->project; GeanyBuildCommand *cmd = NULL; gchar *executable = NULL; - gchar *working_dir = NULL, *cmd_working_dir; + gchar *working_dir = NULL; + const gchar *cmd_working_dir; gboolean autoclose = FALSE; gboolean result = FALSE; gchar *tmp; @@ -1272,7 +1273,7 @@ } else build_command(doc, grp, cmd, NULL); -}; +}
/* group codes for menu items other than the known commands @@ -1337,7 +1338,7 @@
static void create_build_menu_item(GtkWidget *menu, GeanyKeyGroup *group, GtkAccelGroup *ag, - struct BuildMenuItemSpec *bs, gchar *lbl, gint grp, gint cmd) + struct BuildMenuItemSpec *bs, const gchar *lbl, gint grp, gint cmd) { GtkWidget *item = gtk_image_menu_item_new_with_mnemonic(lbl); if (bs->stock_id != NULL) @@ -1392,14 +1393,14 @@ for (j = bs->build_cmd; j < build_groups_count[grp]; ++j) { GeanyBuildCommand *bc = get_build_cmd(NULL, grp, j, NULL); - gchar *lbl = (bc == NULL) ? "" : buildcmd_label(bc); + const gchar *lbl = (bc == NULL) ? "" : buildcmd_label(bc); create_build_menu_item(menu, keygroup, accel_group, bs, lbl, grp, j); } } else { GeanyBuildCommand *bc = get_build_cmd(NULL, bs->build_grp, bs->build_cmd, NULL); - gchar *lbl = (bc == NULL) ? "" : buildcmd_label(bc); + const gchar *lbl = (bc == NULL) ? "" : buildcmd_label(bc); create_build_menu_item(menu, keygroup, accel_group, bs, lbl, bs->build_grp, bs->build_cmd); } } @@ -1412,7 +1413,7 @@ /* portability to various GTK versions needs checking * conforms to description of gtk_accel_label as child of menu item * NB 2.16 adds set_label but not yet set_label_mnemonic */ -static void geany_menu_item_set_label(GtkWidget *w, gchar *label) +static void geany_menu_item_set_label(GtkWidget *w, const gchar *label) { GtkWidget *c = gtk_bin_get_child(GTK_BIN(w)); gtk_label_set_text_with_mnemonic(GTK_LABEL(c), label); @@ -1484,7 +1485,7 @@ for (cmd = bs->build_cmd; cmd < cmdcount; ++cmd) { GtkWidget *menu_item = menu_items.menu_item[grp][cmd]; - gchar *label; + const gchar *label; bc = get_build_cmd(doc, grp, cmd, NULL); if (bc) label = buildcmd_label(bc); @@ -1771,7 +1772,7 @@
/* Column headings, array NULL-terminated */ -static gchar *colheads[] = +static const gchar *colheads[] = { N_("Item"), N_("Label"), @@ -1785,11 +1786,11 @@ #define DC_CLEAR 4 #define DC_N_COL 5
-static const int entry_x_padding = 3; -static const int entry_y_padding = 0; +static const guint entry_x_padding = 3; +static const guint entry_y_padding = 0;
-static RowWidgets *build_add_dialog_row(GeanyDocument *doc, GtkTable *table, gint row, +static RowWidgets *build_add_dialog_row(GeanyDocument *doc, GtkTable *table, guint row, GeanyBuildSource dst, gint grp, gint cmd, gboolean dir) { GtkWidget *label, *clear, *clearicon; @@ -1797,7 +1798,7 @@ GeanyBuildCommand *bc; gint src; enum GeanyBuildCmdEntries i; - gint column = 0; + guint column = 0;
label = gtk_label_new(g_strdup_printf("%d:", cmd + 1)); gtk_table_attach(table, label, column, column + 1, row, row + 1, GTK_FILL, @@ -1837,7 +1838,7 @@
for (i = 0; i < GEANY_BC_CMDENTRIES_COUNT; i++) { - gchar *str = ""; + const gchar *str = ""; if (bc != NULL && (str = bc->entries[i]) == NULL) str = ""; set_build_command_entry_text(roww->entries[i], str); @@ -1868,11 +1869,13 @@ GtkWidget *label, *sep, *clearicon, *clear; TableFields *fields; GtkTable *table; - gchar **ch, *txt; - gint col, row, cmdindex, cmd; + const gchar **ch; + gchar *txt; + guint col, row, cmdindex; + gint cmd; gint src; gboolean sensitivity; - gint sep_padding = entry_y_padding + 3; + guint sep_padding = entry_y_padding + 3;
table = GTK_TABLE(gtk_table_new(build_items_count + 12, 5, FALSE)); fields = g_new0(TableFields, 1); @@ -2580,7 +2583,7 @@
static struct { - gchar *entries[GEANY_BC_CMDENTRIES_COUNT]; + const gchar *entries[GEANY_BC_CMDENTRIES_COUNT]; GeanyBuildCommand **ptr; gint index; } default_cmds[] = {
Modified: trunk/src/build.h =================================================================== --- trunk/src/build.h 2010-04-25 17:43:09 UTC (rev 4861) +++ trunk/src/build.h 2010-04-25 17:43:39 UTC (rev 4862) @@ -127,7 +127,7 @@ GEANY_BC_LABEL, /**< The menu item label, _ marks mnemonic */ GEANY_BC_COMMAND, /**< The command to run. */ GEANY_BC_WORKING_DIR, /**< The directory to run in */ - GEANY_BC_CMDENTRIES_COUNT, /**< Count of entries */ + GEANY_BC_CMDENTRIES_COUNT /**< Count of entries */ } GeanyBuildCmdEntries;
/** The command for a menu item. */
Modified: trunk/src/callbacks.c =================================================================== --- trunk/src/callbacks.c 2010-04-25 17:43:09 UTC (rev 4861) +++ trunk/src/callbacks.c 2010-04-25 17:43:39 UTC (rev 4862) @@ -470,7 +470,7 @@ GeanyDocument *doc = document_get_current(); gchar *base_name; gint i = GPOINTER_TO_INT(user_data); - gchar *charset = NULL; + const gchar *charset = NULL;
g_return_if_fail(doc != NULL); g_return_if_fail(doc->file_name != NULL); @@ -1365,7 +1365,7 @@ { GeanyDocument *doc = document_get_current(); gchar *text; - gchar *fname; + const gchar *fname; GeanyFiletype *ft;
g_return_if_fail(doc != NULL); @@ -1385,7 +1385,7 @@ gpointer user_data) { GeanyDocument *doc = document_get_current(); - gchar *format = NULL; + const gchar *format = NULL; gchar *time_str;
g_return_if_fail(doc != NULL);
Modified: trunk/src/dialogs.c =================================================================== --- trunk/src/dialogs.c 2010-04-25 17:43:09 UTC (rev 4861) +++ trunk/src/dialogs.c 2010-04-25 17:43:39 UTC (rev 4862) @@ -84,7 +84,7 @@ gint encoding_idx = gtk_combo_box_get_active(GTK_COMBO_BOX( ui_lookup_widget(GTK_WIDGET(dialog), "encoding_combo"))); GeanyFiletype *ft = NULL; - gchar *charset = NULL; + const gchar *charset = NULL; gboolean ro = (response == GEANY_RESPONSE_VIEW); /* View clicked */
/* ignore detect from file item */
Modified: trunk/src/editor.c =================================================================== --- trunk/src/editor.c 2010-04-25 17:43:09 UTC (rev 4861) +++ trunk/src/editor.c 2010-04-25 17:43:39 UTC (rev 4862) @@ -99,7 +99,7 @@ AUTOC_CANCELLED, AUTOC_SCOPE, AUTOC_TAGS, - AUTOC_DOC_WORDS, + AUTOC_DOC_WORDS } autocompletion_mode = AUTOC_CANCELLED;
static gchar indent[100]; @@ -1951,7 +1951,7 @@ gchar *linebuf, *root; ScintillaObject *sci; gboolean ret = FALSE; - gchar *wordchars; + const gchar *wordchars; GeanyFiletype *ft;
if (! editor_prefs.auto_complete_symbols && ! force)
Modified: trunk/src/encodings.c =================================================================== --- trunk/src/encodings.c 2010-04-25 17:43:09 UTC (rev 4861) +++ trunk/src/encodings.c 2010-04-25 17:43:39 UTC (rev 4862) @@ -523,7 +523,7 @@ { gchar *locale_charset = NULL; gchar *regex_charset = NULL; - gchar *charset; + const gchar *charset; gchar *utf8_content; gboolean check_regex = FALSE; gboolean check_locale = FALSE;
Modified: trunk/src/encodings.h =================================================================== --- trunk/src/encodings.h 2010-04-25 17:43:09 UTC (rev 4861) +++ trunk/src/encodings.h 2010-04-25 17:43:39 UTC (rev 4862) @@ -63,9 +63,9 @@ /** Internally used member for grouping */ GeanyEncodingGroup group; /** String representation of the encoding, e.g. "ISO-8859-3" */ - gchar *charset; + const gchar *charset; /** Translatable and descriptive name of the encoding, e.g. "South European" */ - gchar *name; + const gchar *name; } GeanyEncoding;
Modified: trunk/src/gb.c =================================================================== --- trunk/src/gb.c 2010-04-25 17:43:09 UTC (rev 4861) +++ trunk/src/gb.c 2010-04-25 17:43:39 UTC (rev 4862) @@ -44,7 +44,7 @@ gushort iconset; GtkWidget *image1, *image2, *image3, *image4, *label1, *label2, *label3, *okbutton1, *textview1; gchar info_texts[4][50]; -gchar *help_text; +const gchar *help_text; gboolean is_running; static GdkPixbuf **icons;
Modified: trunk/src/geanyentryaction.c =================================================================== --- trunk/src/geanyentryaction.c 2010-04-25 17:43:09 UTC (rev 4861) +++ trunk/src/geanyentryaction.c 2010-04-25 17:43:39 UTC (rev 4862) @@ -52,7 +52,7 @@ static guint signals[LAST_SIGNAL];
-G_DEFINE_TYPE(GeanyEntryAction, geany_entry_action, GTK_TYPE_ACTION); +G_DEFINE_TYPE(GeanyEntryAction, geany_entry_action, GTK_TYPE_ACTION)
static GtkWidget *geany_entry_action_create_tool_item(GtkAction *action)
Modified: trunk/src/geanymenubuttonaction.c =================================================================== --- trunk/src/geanymenubuttonaction.c 2010-04-25 17:43:09 UTC (rev 4861) +++ trunk/src/geanymenubuttonaction.c 2010-04-25 17:43:39 UTC (rev 4862) @@ -56,7 +56,7 @@ static guint signals[LAST_SIGNAL];
-G_DEFINE_TYPE(GeanyMenubuttonAction, geany_menu_button_action, GTK_TYPE_ACTION); +G_DEFINE_TYPE(GeanyMenubuttonAction, geany_menu_button_action, GTK_TYPE_ACTION)
static void geany_menu_button_action_finalize(GObject *object)
Modified: trunk/src/geanyobject.c =================================================================== --- trunk/src/geanyobject.c 2010-04-25 17:43:09 UTC (rev 4861) +++ trunk/src/geanyobject.c 2010-04-25 17:43:39 UTC (rev 4862) @@ -53,7 +53,7 @@ };
-G_DEFINE_TYPE(GeanyObject, geany_object, G_TYPE_OBJECT); +G_DEFINE_TYPE(GeanyObject, geany_object, G_TYPE_OBJECT)
Modified: trunk/src/geanywraplabel.c =================================================================== --- trunk/src/geanywraplabel.c 2010-04-25 17:43:09 UTC (rev 4861) +++ trunk/src/geanywraplabel.c 2010-04-25 17:43:39 UTC (rev 4862) @@ -57,7 +57,7 @@ static void geany_wrap_label_size_allocate (GtkWidget *widget, GtkAllocation *alloc); static void geany_wrap_label_set_wrap_width (GtkWidget *widget, gsize width);
-G_DEFINE_TYPE(GeanyWrapLabel, geany_wrap_label, GTK_TYPE_LABEL); +G_DEFINE_TYPE(GeanyWrapLabel, geany_wrap_label, GTK_TYPE_LABEL)
static void geany_wrap_label_class_init(GeanyWrapLabelClass *klass)
Modified: trunk/src/keyfile.c =================================================================== --- trunk/src/keyfile.c 2010-04-25 17:43:09 UTC (rev 4861) +++ trunk/src/keyfile.c 2010-04-25 17:43:39 UTC (rev 4862) @@ -738,7 +738,7 @@ if (vte_info.load_vte) { struct passwd *pw = getpwuid(getuid()); - gchar *shell = (pw != NULL) ? pw->pw_shell : "/bin/sh"; + const gchar *shell = (pw != NULL) ? pw->pw_shell : "/bin/sh";
vc = g_new0(VteConfig, 1); vte_info.dir = utils_get_setting_string(config, "VTE", "last_dir", NULL);
Modified: trunk/src/project.c =================================================================== --- trunk/src/project.c 2010-04-25 17:43:09 UTC (rev 4861) +++ trunk/src/project.c 2010-04-25 17:43:39 UTC (rev 4862) @@ -89,7 +89,7 @@ static void on_name_entry_changed(GtkEditable *editable, PropertyDialogElements *e); static void on_entries_changed(GtkEditable *editable, PropertyDialogElements *e); static void on_radio_long_line_custom_toggled(GtkToggleButton *radio, GtkWidget *spin_long_line); -static void apply_editor_prefs(); +static void apply_editor_prefs(void);
#define SHOW_ERR(args) dialogs_show_msgbox(GTK_MESSAGE_ERROR, args) @@ -1033,7 +1033,7 @@ }
-static void apply_editor_prefs() +static void apply_editor_prefs(void) { guint i;
@@ -1135,7 +1135,7 @@
if (cl_options.load_session) { - gchar *utf8_filename = (project == NULL) ? "" : project->file_name; + const gchar *utf8_filename = (project == NULL) ? "" : project->file_name;
g_key_file_set_string(config, "project", "session_file", utf8_filename); }
Modified: trunk/src/sidebar.c =================================================================== --- trunk/src/sidebar.c 2010-04-25 17:43:09 UTC (rev 4861) +++ trunk/src/sidebar.c 2010-04-25 17:43:39 UTC (rev 4862) @@ -184,7 +184,7 @@ gtk_scrolled_window_get_hadjustment(scrolled_window), gtk_scrolled_window_get_vadjustment(scrolled_window)); label = gtk_label_new(_("No tags found")); - gtk_misc_set_alignment(GTK_MISC(label), 0.1, 0.01); + gtk_misc_set_alignment(GTK_MISC(label), 0.1f, 0.01f); gtk_container_add(GTK_CONTAINER(tv.default_tag_tree), label); gtk_widget_show_all(tv.default_tag_tree); g_signal_connect(tv.default_tag_tree, "button-press-event",
Modified: trunk/src/socket.c =================================================================== --- trunk/src/socket.c 2010-04-25 17:43:09 UTC (rev 4861) +++ trunk/src/socket.c 2010-04-25 17:43:39 UTC (rev 4862) @@ -122,7 +122,7 @@
-void send_open_command(gint sock, gint argc, gchar **argv) +static void send_open_command(gint sock, gint argc, gchar **argv) { gint i; gchar *filename;
Modified: trunk/src/symbols.c =================================================================== --- trunk/src/symbols.c 2010-04-25 17:43:09 UTC (rev 4861) +++ trunk/src/symbols.c 2010-04-25 17:43:39 UTC (rev 4862) @@ -128,7 +128,7 @@ }
-static gsize get_tag_count() +static gsize get_tag_count(void) { GPtrArray *tags = tm_get_workspace()->global_tags; gsize count = tags ? tags->len : 0; @@ -975,7 +975,7 @@
/* find the last word in "foo::bar::blah", e.g. "blah" */ -const gchar *get_parent_name(const TMTag *tag, filetype_id ft_id) +static const gchar *get_parent_name(const TMTag *tag, filetype_id ft_id) { const gchar *scope = tag->atts.entry.scope; const gchar *separator = symbols_get_context_separator(ft_id);
Modified: trunk/src/templates.c =================================================================== --- trunk/src/templates.c 2010-04-25 17:43:09 UTC (rev 4861) +++ trunk/src/templates.c 2010-04-25 17:43:39 UTC (rev 4862) @@ -495,9 +495,9 @@ /* TODO make this function operating on a GString */ static gchar *make_comment_block(const gchar *comment_text, gint filetype_idx, guint indent) { - gchar *frame_start; /* to add before comment_text */ - gchar *frame_end; /* to add after comment_text */ - gchar *line_prefix; /* to add before every line in comment_text */ + gchar *frame_start; /* to add before comment_text */ + gchar *frame_end; /* to add after comment_text */ + const gchar *line_prefix; /* to add before every line in comment_text */ gchar *result; gchar *tmp; gchar *prefix; @@ -666,7 +666,7 @@ gchar *templates_get_template_changelog(GeanyDocument *doc) { GString *result = g_string_new(templates[GEANY_TEMPLATE_CHANGELOG]); - gchar *file_type_name = (doc != NULL) ? doc->file_type->name : ""; + const gchar *file_type_name = (doc != NULL) ? doc->file_type->name : "";
replace_static_values(result); templates_replace_default_dates(result);
Modified: trunk/src/ui_utils.c =================================================================== --- trunk/src/ui_utils.c 2010-04-25 17:43:09 UTC (rev 4861) +++ trunk/src/ui_utils.c 2010-04-25 17:43:39 UTC (rev 4862) @@ -770,7 +770,7 @@
void ui_document_show_hide(GeanyDocument *doc) { - gchar *widget_name; + const gchar *widget_name; GtkWidget *item; const GeanyIndentPrefs *iprefs;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.