Make string arguments const where appropriate (patch by Colomban Wendling, thanks).
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4862 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
3f3d2d1b9b
commit
8c963d2829
@ -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>
|
||||
|
39
src/build.c
39
src/build.c
@ -211,7 +211,7 @@ static GeanyBuildCommand **cl[GEANY_GBG_COUNT][GEANY_BCS_COUNT] = {
|
||||
|
||||
|
||||
/* 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 @@ static gchar *prepare_run_script(GeanyDocument *doc, gchar **vte_cmd_nonscript,
|
||||
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 @@ static void on_build_menu_item(GtkWidget *w, gpointer user_data)
|
||||
}
|
||||
else
|
||||
build_command(doc, grp, cmd, NULL);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/* group codes for menu items other than the known commands
|
||||
@ -1337,7 +1338,7 @@ static struct BuildMenuItemSpec {
|
||||
|
||||
|
||||
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 @@ static void create_build_menu(BuildMenuItems *build_menu_items)
|
||||
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 @@ static void create_build_menu(BuildMenuItems *build_menu_items)
|
||||
/* 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 @@ void build_menu_update(GeanyDocument *doc)
|
||||
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 @@ static void on_label_button_clicked(GtkWidget *wid)
|
||||
|
||||
|
||||
/* Column headings, array NULL-terminated */
|
||||
static gchar *colheads[] =
|
||||
static const gchar *colheads[] =
|
||||
{
|
||||
N_("Item"),
|
||||
N_("Label"),
|
||||
@ -1785,11 +1786,11 @@ static gchar *colheads[] =
|
||||
#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 @@ static RowWidgets *build_add_dialog_row(GeanyDocument *doc, GtkTable *table, gin
|
||||
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 @@ static RowWidgets *build_add_dialog_row(GeanyDocument *doc, GtkTable *table, gin
|
||||
|
||||
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 *build_commands_table(GeanyDocument *doc, GeanyBuildSource dst, TableD
|
||||
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 @@ gint build_get_group_count(GeanyBuildGroup grp)
|
||||
|
||||
static struct
|
||||
{
|
||||
gchar *entries[GEANY_BC_CMDENTRIES_COUNT];
|
||||
const gchar *entries[GEANY_BC_CMDENTRIES_COUNT];
|
||||
GeanyBuildCommand **ptr;
|
||||
gint index;
|
||||
} default_cmds[] = {
|
||||
|
@ -127,7 +127,7 @@ typedef enum GeanyBuildCmdEntries
|
||||
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. */
|
||||
|
@ -470,7 +470,7 @@ on_reload_as_activate (GtkMenuItem *menuitem,
|
||||
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 @@ on_comments_fileheader_activate (GtkMenuItem *menuitem,
|
||||
{
|
||||
GeanyDocument *doc = document_get_current();
|
||||
gchar *text;
|
||||
gchar *fname;
|
||||
const gchar *fname;
|
||||
GeanyFiletype *ft;
|
||||
|
||||
g_return_if_fail(doc != NULL);
|
||||
@ -1385,7 +1385,7 @@ on_insert_date_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
GeanyDocument *doc = document_get_current();
|
||||
gchar *format = NULL;
|
||||
const gchar *format = NULL;
|
||||
gchar *time_str;
|
||||
|
||||
g_return_if_fail(doc != NULL);
|
||||
|
@ -84,7 +84,7 @@ on_file_open_dialog_response (GtkDialog *dialog,
|
||||
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 */
|
||||
|
@ -99,7 +99,7 @@ static enum
|
||||
AUTOC_CANCELLED,
|
||||
AUTOC_SCOPE,
|
||||
AUTOC_TAGS,
|
||||
AUTOC_DOC_WORDS,
|
||||
AUTOC_DOC_WORDS
|
||||
} autocompletion_mode = AUTOC_CANCELLED;
|
||||
|
||||
static gchar indent[100];
|
||||
@ -1951,7 +1951,7 @@ gboolean editor_start_auto_complete(GeanyEditor *editor, gint pos, gboolean forc
|
||||
gchar *linebuf, *root;
|
||||
ScintillaObject *sci;
|
||||
gboolean ret = FALSE;
|
||||
gchar *wordchars;
|
||||
const gchar *wordchars;
|
||||
GeanyFiletype *ft;
|
||||
|
||||
if (! editor_prefs.auto_complete_symbols && ! force)
|
||||
|
@ -523,7 +523,7 @@ gchar *encodings_convert_to_utf8(const gchar *buffer, gsize size, gchar **used_e
|
||||
{
|
||||
gchar *locale_charset = NULL;
|
||||
gchar *regex_charset = NULL;
|
||||
gchar *charset;
|
||||
const gchar *charset;
|
||||
gchar *utf8_content;
|
||||
gboolean check_regex = FALSE;
|
||||
gboolean check_locale = FALSE;
|
||||
|
@ -63,9 +63,9 @@ typedef struct
|
||||
/** 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;
|
||||
|
||||
|
||||
|
2
src/gb.c
2
src/gb.c
@ -44,7 +44,7 @@ gint points;
|
||||
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;
|
||||
|
||||
|
@ -52,7 +52,7 @@ enum
|
||||
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)
|
||||
|
@ -56,7 +56,7 @@ enum
|
||||
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)
|
||||
|
@ -53,7 +53,7 @@ struct _GeanyObjectPrivate
|
||||
};
|
||||
|
||||
|
||||
G_DEFINE_TYPE(GeanyObject, geany_object, G_TYPE_OBJECT);
|
||||
G_DEFINE_TYPE(GeanyObject, geany_object, G_TYPE_OBJECT)
|
||||
|
||||
|
||||
|
||||
|
@ -57,7 +57,7 @@ static void geany_wrap_label_size_request (GtkWidget *widget, GtkRequisition *re
|
||||
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)
|
||||
|
@ -738,7 +738,7 @@ static void load_dialog_prefs(GKeyFile *config)
|
||||
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);
|
||||
|
@ -89,7 +89,7 @@ static gboolean write_config(gboolean emit_signal);
|
||||
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 gboolean load_config(const gchar *filename)
|
||||
}
|
||||
|
||||
|
||||
static void apply_editor_prefs()
|
||||
static void apply_editor_prefs(void)
|
||||
{
|
||||
guint i;
|
||||
|
||||
@ -1135,7 +1135,7 @@ void project_save_prefs(GKeyFile *config)
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ static void create_default_tag_tree(void)
|
||||
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",
|
||||
|
@ -122,7 +122,7 @@ static gint socket_fd_close (gint sock);
|
||||
|
||||
|
||||
|
||||
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;
|
||||
|
@ -128,7 +128,7 @@ void symbols_reload_config_files(void)
|
||||
}
|
||||
|
||||
|
||||
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 @@ static gchar *get_symbol_tooltip(GeanyDocument *doc, const TMTag *tag)
|
||||
|
||||
|
||||
/* 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);
|
||||
|
@ -495,9 +495,9 @@ void templates_init(void)
|
||||
/* 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_function(GeanyDocument *doc, const gchar *func_nam
|
||||
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);
|
||||
|
@ -770,7 +770,7 @@ void ui_sidebar_show_hide(void)
|
||||
|
||||
void ui_document_show_hide(GeanyDocument *doc)
|
||||
{
|
||||
gchar *widget_name;
|
||||
const gchar *widget_name;
|
||||
GtkWidget *item;
|
||||
const GeanyIndentPrefs *iprefs;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user