[geany/geany] 0aea05: Fix various integer signedness and minor styling issues
Colomban Wendling
git-noreply at xxxxx
Thu Jul 26 00:02:17 UTC 2012
Branch: refs/heads/document-messages
Author: Colomban Wendling <ban at herbesfolles.org>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Sat, 17 Dec 2011 23:32:22
Commit: 0aea05d10d46e822316267a3a72a50672c4ba81a
https://github.com/geany/geany/commit/0aea05d10d46e822316267a3a72a50672c4ba81a
Log Message:
-----------
Fix various integer signedness and minor styling issues
Most noteworthy change is that all build commands IDs and groups are
now unsigned everywhere negative values aren't explicitly handled with
a special meaning. This should not change anything in behavior, only
makes clear the index won't underflow.
Modified Paths:
--------------
src/about.c
src/build.c
src/build.h
src/dialogs.c
src/document.c
src/gb.c
src/geanywraplabel.c
src/keyfile.c
src/prefs.c
src/printing.c
src/project.c
src/socket.h
src/symbols.c
src/templates.c
src/toolbar.c
src/utils.c
Modified: src/about.c
12 files changed, 5 insertions(+), 7 deletions(-)
===================================================================
@@ -76,14 +76,14 @@
{ "zh_CN", "Dormouse Young <mouselinux at 163.com>,\nXhacker Liu <liu.dongyuan at gmail.com>" },
{ "zh_TW", "KoViCH <kovich.ian at gmail.com>\nWei-Lun Chao <chaoweilun at gmail.com>" }
};
-static const gint translators_len = G_N_ELEMENTS(translators);
+static const guint translators_len = G_N_ELEMENTS(translators);
const gchar *prev_translators[][2] = {
{ "es", "Damián Viano <debian at damianv.com.ar>\nNacho Cabanes <ncabanes at gmail.com>" },
{ "pl", "Jacek Wolszczak <shutdownrunner at o2.pl>\nJarosław Foksa <jfoksa at gmail.com>" },
{ "nl", "Kurt De Bree <kdebree at telenet.be>" }
};
-static const gint prev_translators_len = G_N_ELEMENTS(prev_translators);
+static const guint prev_translators_len = G_N_ELEMENTS(prev_translators);
static const gchar *contributors =
"Adam Ples, "
@@ -144,7 +144,7 @@ static GtkWidget *create_dialog(void)
gchar *license_text = NULL;
gchar buffer[512];
gchar buffer2[128];
- gint i, row = 0;
+ guint i, row = 0;
dialog = gtk_dialog_new();
@@ -271,9 +271,7 @@ static GtkWidget *create_dialog(void)
g_snprintf(buffer, sizeof(buffer),
"<span size=\"larger\" weight=\"bold\">%s</span>", _("Developers"));
label = gtk_label_new(buffer);
- gtk_table_attach(GTK_TABLE(table), label, 0, 2, row, row + 1,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 5);
+ gtk_table_attach(GTK_TABLE(table), label, 0, 2, row, row + 1, GTK_FILL, 0, 0, 5);
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
row++;
@@ -422,7 +420,7 @@ static GtkWidget *create_dialog(void)
_("License text could not be found, please visit http://www.gnu.org/licenses/gpl-2.0.txt to view it online."));
}
tb = gtk_text_view_get_buffer(GTK_TEXT_VIEW(license_textview));
- gtk_text_buffer_set_text(tb, license_text, strlen(license_text));
+ gtk_text_buffer_set_text(tb, license_text, -1);
g_free(license_text);
Modified: src/build.c
119 files changed, 63 insertions(+), 56 deletions(-)
===================================================================
@@ -90,10 +90,10 @@
#endif
/* pack group (<8) and command (<32) into a user_data pointer */
-#define GRP_CMD_TO_POINTER(grp, cmd) GINT_TO_POINTER((((grp)&7) << 5) | ((cmd)&0x1f))
+#define GRP_CMD_TO_POINTER(grp, cmd) GUINT_TO_POINTER((((grp)&7) << 5) | ((cmd)&0x1f))
#define GBO_TO_POINTER(gbo) (GRP_CMD_TO_POINTER(GBO_TO_GBG(gbo), GBO_TO_CMD(gbo)))
-#define GPOINTER_TO_CMD(gptr) (GPOINTER_TO_INT(gptr)&0x1f)
-#define GPOINTER_TO_GRP(gptr) ((GPOINTER_TO_INT(gptr)&0xe0) >> 5)
+#define GPOINTER_TO_CMD(gptr) (GPOINTER_TO_UINT(gptr)&0x1f)
+#define GPOINTER_TO_GRP(gptr) ((GPOINTER_TO_UINT(gptr)&0xe0) >> 5)
static gpointer last_toolbutton_action = GBO_TO_POINTER(GEANY_GBO_BUILD);
@@ -114,8 +114,8 @@
}
widgets;
-static gint build_groups_count[GEANY_GBG_COUNT] = { 3, 4, 2 };
-static gint build_items_count = 9;
+static guint build_groups_count[GEANY_GBG_COUNT] = { 3, 4, 2 };
+static guint build_items_count = 9;
#ifndef SYNC_SPAWN
static void build_exit_cb(GPid child_pid, gint status, gpointer user_data);
@@ -330,12 +330,12 @@ static void printfcmds(void)
/* get the next lowest command taking priority into account */
-static GeanyBuildCommand *get_next_build_cmd(GeanyDocument *doc, gint cmdgrp, gint cmdindex,
- gint below, gint *from)
+static GeanyBuildCommand *get_next_build_cmd(GeanyDocument *doc, guint cmdgrp, guint cmdindex,
+ guint below, guint *from)
{
/* Note: parameter below used in macros above */
GeanyFiletype *ft = NULL;
- gint sink, *fr = &sink;
+ guint sink, *fr = &sink;
if (printbuildcmds)
printfcmds();
@@ -381,7 +381,7 @@ static GeanyBuildCommand *get_next_build_cmd(GeanyDocument *doc, gint cmdgrp, gi
/* shortcut to start looking at the top */
-static GeanyBuildCommand *get_build_cmd(GeanyDocument *doc, gint grp, gint cmdindex, gint *from)
+static GeanyBuildCommand *get_build_cmd(GeanyDocument *doc, guint grp, guint cmdindex, guint *from)
{
return get_next_build_cmd(doc, grp, cmdindex, GEANY_BCS_COUNT, from);
}
@@ -393,9 +393,9 @@ static GeanyBuildCommand *get_build_cmd(GeanyDocument *doc, gint grp, gint cmdin
/* like get_build_cmd, but for regexen, used by filetypes */
-gchar **build_get_regex(GeanyBuildGroup grp, GeanyFiletype *ft, gint *from)
+gchar **build_get_regex(GeanyBuildGroup grp, GeanyFiletype *ft, guint *from)
{
- gint sink, *fr = &sink;
+ guint sink, *fr = &sink;
if (from != NULL)
fr = from;
@@ -495,7 +495,7 @@ static GeanyBuildCommand *get_build_group(GeanyBuildSource src, GeanyBuildGroup
void build_remove_menu_item(GeanyBuildSource src, GeanyBuildGroup grp, gint cmd)
{
GeanyBuildCommand *bc;
- gint i;
+ guint i;
bc = get_build_group(src, grp);
if (bc == NULL)
@@ -505,7 +505,7 @@ void build_remove_menu_item(GeanyBuildSource src, GeanyBuildGroup grp, gint cmd)
for (i = 0; i < build_groups_count[grp]; ++i)
bc[i].exists = FALSE;
}
- else if (cmd < build_groups_count[grp])
+ else if ((guint) cmd < build_groups_count[grp])
bc[cmd].exists = FALSE;
}
@@ -524,12 +524,14 @@ void build_remove_menu_item(GeanyBuildSource src, GeanyBuildGroup grp, gint cmd)
*
* @see build_menu_update
**/
-GeanyBuildCommand *build_get_menu_item(GeanyBuildSource src, GeanyBuildGroup grp, gint cmd)
+GeanyBuildCommand *build_get_menu_item(GeanyBuildSource src, GeanyBuildGroup grp, guint cmd)
{
GeanyBuildCommand *bc;
- if (src >= GEANY_BCS_COUNT || grp >= GEANY_GBG_COUNT || cmd >= build_groups_count[grp])
- return NULL;
+ g_return_val_if_fail(src < GEANY_BCS_COUNT, NULL);
+ g_return_val_if_fail(grp < GEANY_GBG_COUNT, NULL);
+ g_return_val_if_fail(cmd < build_groups_count[grp], NULL);
+
bc = get_build_group(src, grp);
if (bc == NULL)
return NULL;
@@ -553,10 +555,12 @@ GeanyBuildCommand *build_get_menu_item(GeanyBuildSource src, GeanyBuildGroup grp
* @see build_menu_update
**/
/* parameter checked version of get_build_cmd for external interface */
-GeanyBuildCommand *build_get_current_menu_item(GeanyBuildGroup grp, gint cmd, gint *src)
+GeanyBuildCommand *build_get_current_menu_item(GeanyBuildGroup grp, guint cmd, guint *src)
{
- if (*src >= GEANY_BCS_COUNT || grp >= GEANY_GBG_COUNT || cmd >= build_groups_count[grp])
- return NULL;
+ g_return_val_if_fail(*src < GEANY_BCS_COUNT, NULL);
+ g_return_val_if_fail(grp < GEANY_GBG_COUNT, NULL);
+ g_return_val_if_fail(cmd < build_groups_count[grp], NULL);
+
return get_build_cmd(NULL, grp, cmd, src);
}
@@ -774,7 +778,7 @@ static GPid build_spawn_cmd(GeanyDocument *doc, const gchar *cmd, const gchar *d
/* Returns: NULL if there was an error, or the working directory the script was created in.
* vte_cmd_nonscript is the location of a string which is filled with the command to be used
* when vc->skip_run_script is set, otherwise it will be set to NULL */
-static gchar *prepare_run_script(GeanyDocument *doc, gchar **vte_cmd_nonscript, gint cmdindex)
+static gchar *prepare_run_script(GeanyDocument *doc, gchar **vte_cmd_nonscript, guint cmdindex)
{
gchar *locale_filename = NULL;
GeanyBuildCommand *cmd = NULL;
@@ -848,7 +852,7 @@ static gchar *prepare_run_script(GeanyDocument *doc, gchar **vte_cmd_nonscript,
}
-static GPid build_run_cmd(GeanyDocument *doc, gint cmdindex)
+static GPid build_run_cmd(GeanyDocument *doc, guint cmdindex)
{
gchar *working_dir;
gchar *vte_cmd_nonscript = NULL;
@@ -1208,7 +1212,7 @@ static gboolean build_create_shellscript(const gchar *fname, const gchar *cmd, g
typedef void Callback(GtkWidget *w, gpointer u);
/* run the command catenating cmd_cat if present */
-static void build_command(GeanyDocument *doc, GeanyBuildGroup grp, gint cmd, gchar *cmd_cat)
+static void build_command(GeanyDocument *doc, GeanyBuildGroup grp, guint cmd, gchar *cmd_cat)
{
gchar *dir;
gchar *full_command, *subs_command;
@@ -1263,8 +1267,8 @@ static void on_build_menu_item(GtkWidget *w, gpointer user_data)
{
GeanyDocument *doc = document_get_current();
GeanyBuildCommand *bc;
- gint grp = GPOINTER_TO_GRP(user_data);
- gint cmd = GPOINTER_TO_CMD(user_data);
+ guint grp = GPOINTER_TO_GRP(user_data);
+ guint cmd = GPOINTER_TO_CMD(user_data);
if (doc && doc->changed)
{
@@ -1334,8 +1338,8 @@ static void on_build_menu_item(GtkWidget *w, gpointer user_data)
static struct BuildMenuItemSpec {
const gchar *stock_id;
const gint key_binding;
- const gint build_grp;
- const gint build_cmd;
+ const guint build_grp;
+ const guint build_cmd;
const gchar *fix_label;
Callback *cb;
} build_menu_specs[] = {
@@ -1377,7 +1381,7 @@ static void on_build_menu_item(GtkWidget *w, gpointer user_data)
static void create_build_menu_item(GtkWidget *menu, GeanyKeyGroup *group, GtkAccelGroup *ag,
- struct BuildMenuItemSpec *bs, const gchar *lbl, gint grp, gint cmd)
+ struct BuildMenuItemSpec *bs, const gchar *lbl, guint grp, guint cmd)
{
GtkWidget *item = gtk_image_menu_item_new_with_mnemonic(lbl);
@@ -1403,7 +1407,7 @@ static void create_build_menu(BuildMenuItems *build_menu_items)
GtkWidget *menu;
GtkAccelGroup *accel_group = gtk_accel_group_new();
GeanyKeyGroup *keygroup = keybindings_get_core_group(GEANY_KEY_GROUP_BUILD);
- gint i, j;
+ guint i, j;
menu = gtk_menu_new();
build_menu_items->menu_item[GEANY_GBG_FT] = g_new0(GtkWidget*, build_groups_count[GEANY_GBG_FT]);
@@ -1428,7 +1432,7 @@ static void create_build_menu(BuildMenuItems *build_menu_items)
}
else if (bs->build_grp >= MENU_FT_REST && bs->build_grp <= MENU_SEPARATOR)
{
- gint grp = bs->build_grp - GEANY_GBG_COUNT;
+ guint grp = bs->build_grp - GEANY_GBG_COUNT;
for (j = bs->build_cmd; j < build_groups_count[grp]; ++j)
{
GeanyBuildCommand *bc = get_build_cmd(NULL, grp, j, NULL);
@@ -1476,7 +1480,7 @@ static void geany_menu_item_set_label(GtkWidget *w, const gchar *label)
**/
void build_menu_update(GeanyDocument *doc)
{
- gint i, cmdcount, cmd, grp;
+ guint i, cmdcount, cmd, grp;
gboolean vis = FALSE;
gboolean have_path, build_running, exec_running, have_errors, cmd_sensitivity;
gboolean can_compile, can_build, can_make, run_sensitivity = FALSE, run_running = FALSE;
@@ -1753,8 +1757,8 @@ void build_toolbutton_build_clicked(GtkAction *action, gpointer unused)
GeanyBuildSource src;
GeanyBuildSource dst;
GeanyBuildCommand *cmdsrc;
- gint grp;
- gint cmd;
+ guint grp;
+ guint cmd;
gboolean cleared;
gboolean used_dst;
} RowWidgets;
@@ -1782,7 +1786,7 @@ static void set_build_command_entry_text(GtkWidget *wid, const gchar *text)
static void on_clear_dialog_row(GtkWidget *unused, gpointer user_data)
{
RowWidgets *r = user_data;
- gint src;
+ guint src;
enum GeanyBuildCmdEntries i;
GeanyBuildCommand *bc = get_next_build_cmd(NULL, r->grp, r->cmd, r->dst, &src);
@@ -1869,12 +1873,12 @@ static void on_entry_focus(GtkWidget *wid, GdkEventFocus *unused, gpointer user_
static RowWidgets *build_add_dialog_row(GeanyDocument *doc, GtkTable *table, guint row,
- GeanyBuildSource dst, gint grp, gint cmd, gboolean dir)
+ GeanyBuildSource dst, guint grp, guint cmd, gboolean dir)
{
GtkWidget *label, *clear, *clearicon;
RowWidgets *roww;
GeanyBuildCommand *bc;
- gint src;
+ guint src;
enum GeanyBuildCmdEntries i;
guint column = 0;
gchar *text;
@@ -1929,14 +1933,14 @@ static RowWidgets *build_add_dialog_row(GeanyDocument *doc, GtkTable *table, gui
{
if ((str = id_to_str(bc, i)) == NULL)
str = "";
- else if ((gint)dst == src)
+ else if (dst == src)
roww->used_dst = TRUE;
}
set_build_command_entry_text(roww->entries[i], str);
}
- if (bc != NULL && ((gint)dst > src))
+ if (bc != NULL && (dst > src))
set_row_color(roww, insensitive_color);
- if (bc != NULL && (src > (gint)dst || (grp == GEANY_GBG_FT && (doc == NULL || doc->file_type == NULL))))
+ if (bc != NULL && (src > dst || (grp == GEANY_GBG_FT && (doc == NULL || doc->file_type == NULL))))
{
for (i = 0; i < GEANY_BC_CMDENTRIES_COUNT; i++)
gtk_widget_set_sensitive(roww->entries[i], FALSE);
@@ -1965,8 +1969,8 @@ GtkWidget *build_commands_table(GeanyDocument *doc, GeanyBuildSource dst, BuildT
const gchar **ch;
gchar *txt;
guint col, row, cmdindex;
- gint cmd;
- gint src;
+ guint cmd;
+ guint src;
gboolean sensitivity;
guint sep_padding = entry_y_padding + 3;
@@ -2003,7 +2007,7 @@ GtkWidget *build_commands_table(GeanyDocument *doc, GeanyBuildSource dst, BuildT
if (fields->fileregexstring != NULL && *(fields->fileregexstring) != NULL)
{
gtk_entry_set_text(GTK_ENTRY(fields->fileregex), *(fields->fileregexstring));
- if (src > (gint)dst)
+ if (src > dst)
sensitivity = FALSE;
}
gtk_table_attach(table, fields->fileregex, DC_ENTRIES + 1, DC_CLEAR, row, row + 1, GTK_FILL,
@@ -2038,7 +2042,7 @@ GtkWidget *build_commands_table(GeanyDocument *doc, GeanyBuildSource dst, BuildT
if (fields->nonfileregexstring != NULL && *(fields->nonfileregexstring) != NULL)
{
gtk_entry_set_text(GTK_ENTRY(fields->nonfileregex), *(fields->nonfileregexstring));
- sensitivity = src > (gint)dst ? FALSE : TRUE;
+ sensitivity = src > dst ? FALSE : TRUE;
}
gtk_table_attach(table, fields->nonfileregex, DC_ENTRIES + 1, DC_CLEAR, row, row + 1, GTK_FILL,
GTK_FILL | GTK_EXPAND, entry_x_padding, entry_y_padding);
@@ -2088,7 +2092,7 @@ GtkWidget *build_commands_table(GeanyDocument *doc, GeanyBuildSource dst, BuildT
void build_free_fields(BuildTableData table_data)
{
- gint cmdindex;
+ guint cmdindex;
for (cmdindex = 0; cmdindex < build_items_count; ++cmdindex)
g_free(table_data->rows[cmdindex]);
@@ -2121,7 +2125,7 @@ static const gchar *get_build_command_entry_text(GtkWidget *wid)
}
-static gboolean read_row(BuildDestination *dst, BuildTableData table_data, gint drow, gint grp, gint cmd)
+static gboolean read_row(BuildDestination *dst, BuildTableData table_data, guint drow, guint grp, guint cmd)
{
gchar *entries[GEANY_BC_CMDENTRIES_COUNT];
gboolean changed = FALSE;
@@ -2188,7 +2192,7 @@ static gboolean read_regex(GtkWidget *regexentry, gchar **src, gchar **dst)
static gboolean build_read_commands(BuildDestination *dst, BuildTableData table_data, gint response)
{
- gint cmdindex, cmd;
+ guint cmdindex, cmd;
gboolean changed = FALSE;
if (response == GTK_RESPONSE_ACCEPT)
@@ -2307,7 +2311,7 @@ BuildMenuItems *build_get_menu_items(gint filetype_idx)
static void build_load_menu_grp(GKeyFile *config, GeanyBuildCommand **dst, gint grp,
gchar *prefix, gboolean loc)
{
- gint cmd;
+ guint cmd;
gsize prefixlen; /* NOTE prefixlen used in macros above */
GeanyBuildCommand *dstcmd;
gchar *key;
@@ -2321,7 +2325,7 @@ static void build_load_menu_grp(GKeyFile *config, GeanyBuildCommand **dst, gint
for (cmd = 0; cmd < build_groups_count[grp]; ++cmd)
{
gchar *label;
- if (cmd < 0 || cmd >= 100)
+ if (cmd >= 100)
return; /* ensure no buffer overflow */
sprintf(cmdbuf, "%02d", cmd);
set_key_grp(key, groups[grp]);
@@ -2517,12 +2521,12 @@ void build_load_menu(GKeyFile *config, GeanyBuildSource src, gpointer p)
}
-static gint build_save_menu_grp(GKeyFile *config, GeanyBuildCommand *src, gint grp, gchar *prefix)
+static guint build_save_menu_grp(GKeyFile *config, GeanyBuildCommand *src, gint grp, gchar *prefix)
{
- gint cmd;
+ guint cmd;
gsize prefixlen; /* NOTE prefixlen used in macros above */
gchar *key;
- gint count = 0;
+ guint count = 0;
enum GeanyBuildCmdEntries i;
if (src == NULL)
@@ -2535,7 +2539,7 @@ static gint build_save_menu_grp(GKeyFile *config, GeanyBuildCommand *src, gint g
if (src[cmd].changed)
{
static gchar cmdbuf[4] = " ";
- if (cmd < 0 || cmd >= 100)
+ if (cmd >= 100)
return count; /* ensure no buffer overflow */
sprintf(cmdbuf, "%02d", cmd);
set_key_grp(key, groups[grp]);
@@ -2574,7 +2578,7 @@ static void foreach_project_filetype(gpointer data, gpointer user_data)
{
GeanyFiletype *ft = data;
ForEachData *d = user_data;
- gint i = 0;
+ guint i = 0;
gchar *regkey = g_strdup_printf("%serror_regex", ft->name);
i += build_save_menu_grp(d->config, ft->projfilecmds, GEANY_GBG_FT, ft->name);
@@ -2647,19 +2651,22 @@ void build_save_menu(GKeyFile *config, gpointer ptr, GeanyBuildSource src)
}
+/* FIXME: count is int only because calling code doesn't handle checking its value itself */
void build_set_group_count(GeanyBuildGroup grp, gint count)
{
- gint i, sum;
+ guint i, sum;
+
+ g_return_if_fail(count >= 0);
- if (count > build_groups_count[grp])
- build_groups_count[grp] = count;
+ if ((guint) count > build_groups_count[grp])
+ build_groups_count[grp] = (guint) count;
for (i = 0, sum = 0; i < GEANY_GBG_COUNT; ++i)
sum += build_groups_count[i];
build_items_count = sum;
}
-gint build_get_group_count(GeanyBuildGroup grp)
+guint build_get_group_count(GeanyBuildGroup grp)
{
return build_groups_count[grp];
}
Modified: src/build.h
10 files changed, 5 insertions(+), 5 deletions(-)
===================================================================
@@ -107,7 +107,7 @@ enum GeanyBuildFixedMenuItems
typedef struct GeanyBuildInfo
{
GeanyBuildGroup grp;
- gint cmd;
+ guint cmd;
GPid pid; /* process id of the spawned process */
gchar *dir;
guint file_type_id;
@@ -179,9 +179,9 @@ enum GeanyBuildFixedMenuItems
void build_remove_menu_item(GeanyBuildSource src, GeanyBuildGroup grp, gint cmd);
-GeanyBuildCommand *build_get_menu_item(GeanyBuildSource src, GeanyBuildGroup grp, gint cmd);
+GeanyBuildCommand *build_get_menu_item(GeanyBuildSource src, GeanyBuildGroup grp, guint cmd);
-GeanyBuildCommand *build_get_current_menu_item(GeanyBuildGroup grp, gint cmd, gint *src);
+GeanyBuildCommand *build_get_current_menu_item(GeanyBuildGroup grp, guint cmd, guint *src);
BuildMenuItems *build_get_menu_items(gint filetype_idx);
@@ -192,8 +192,8 @@ enum GeanyBuildFixedMenuItems
void build_set_group_count(GeanyBuildGroup grp, gint count);
-gint build_get_group_count(GeanyBuildGroup grp);
+guint build_get_group_count(GeanyBuildGroup grp);
-gchar **build_get_regex(GeanyBuildGroup grp, GeanyFiletype *ft, gint *from);
+gchar **build_get_regex(GeanyBuildGroup grp, GeanyFiletype *ft, guint *from);
#endif
Modified: src/dialogs.c
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -146,7 +146,7 @@ static void open_file_dialog_handle_response(GtkWidget *dialog, gint response)
/* ignore detect from file item */
if (filesel_state.open.filetype_idx > 0)
- ft = g_slist_nth_data(filetypes_by_title, filesel_state.open.filetype_idx);
+ ft = g_slist_nth_data(filetypes_by_title, (guint) filesel_state.open.filetype_idx);
encoding_model = gtk_combo_box_get_model(GTK_COMBO_BOX(encoding_combo));
gtk_combo_box_get_active_iter(GTK_COMBO_BOX(encoding_combo), &encoding_iter);
Modified: src/document.c
6 files changed, 3 insertions(+), 3 deletions(-)
===================================================================
@@ -1542,7 +1542,7 @@ static gsize save_convert_to_encoding(GeanyDocument *doc, gchar **data, gsize *l
static gchar *write_data_to_disk(const gchar *locale_filename,
- const gchar *data, gint len)
+ const gchar *data, gsize len)
{
GError *error = NULL;
@@ -1588,7 +1588,7 @@ static gchar *write_data_to_disk(const gchar *locale_filename,
}
else
{
- gint bytes_written;
+ gsize bytes_written;
errno = 0;
bytes_written = fwrite(data, sizeof(gchar), len, fp);
@@ -1634,7 +1634,7 @@ static gchar *write_data_to_disk(const gchar *locale_filename,
static gchar *save_doc(GeanyDocument *doc, const gchar *locale_filename,
- const gchar *data, gint len)
+ const gchar *data, gsize len)
{
gchar *err;
Modified: src/gb.c
52 files changed, 18 insertions(+), 34 deletions(-)
===================================================================
@@ -213,20 +213,11 @@ static void close_clicked_cb(GtkButton *button, gpointer user_data)
static gint get_points(gushort a, gushort b, gushort c)
{
if (a == b && b == c)
- {
return 2;
- }
+ else if (a == b || b == c || a == c)
+ return 1;
else
- {
- if (a == b || b == c || a == c)
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
+ return 0;
}
@@ -234,23 +225,16 @@ static gint get_points(gushort a, gushort b, gushort c)
static void ensure_different_icons(gushort *a, gushort *b, gushort *c)
{
if (*a == *b)
- {
- (*b)++;
- if (*b > 9)
- *b = 0;
- }
+ *b = (gushort) ((*b + 1) % MAX_PICS);
if (*b == *c)
- {
- (*c)++;
- if (*c > 9)
- *c = 0;
- }
+ *c = (gushort) ((*c + 1) % MAX_PICS);
}
static void arm_clicked_cb(GtkButton *button, gpointer user_data)
{
- gushort erg_a, erg_b, erg_c, i, l, m, n, loops;
+ gushort erg_a, erg_b, erg_c, l, m, n;
+ gint i, loops;
if (is_running)
return; /* prevent multiple clicks */
@@ -261,12 +245,12 @@ static void arm_clicked_cb(GtkButton *button, gpointer user_data)
bout++;
update_labels(gb_window, FALSE, 3);
- l = g_random_int_range(0, MAX_PICS);
- m = g_random_int_range(0, MAX_PICS);
- n = g_random_int_range(0, MAX_PICS);
- erg_a = g_random_int_range(0, MAX_PICS);
- erg_b = g_random_int_range(0, MAX_PICS);
- erg_c = g_random_int_range(0, MAX_PICS);
+ l = (gushort) g_random_int_range(0, MAX_PICS);
+ m = (gushort) g_random_int_range(0, MAX_PICS);
+ n = (gushort) g_random_int_range(0, MAX_PICS);
+ erg_a = (gushort) g_random_int_range(0, MAX_PICS);
+ erg_b = (gushort) g_random_int_range(0, MAX_PICS);
+ erg_c = (gushort) g_random_int_range(0, MAX_PICS);
ensure_different_icons(&l, &m, &n);
@@ -298,7 +282,7 @@ static void arm_clicked_cb(GtkButton *button, gpointer user_data)
gtk_image_set_from_pixbuf(GTK_IMAGE(image3), icons[erg_c]);
i = get_points(erg_a, erg_b, erg_c);
- points += (i * 50);
+ points += i * 50;
update_labels(gb_window, FALSE, i);
@@ -318,7 +302,7 @@ static void help_clicked_cb(GtkButton *button, gpointer user_data)
g_signal_connect(okbutton1, "clicked", G_CALLBACK(destroydialog), G_OBJECT(dialog));
buffer = gtk_text_buffer_new(NULL);
- gtk_text_buffer_set_text(buffer, help_text, strlen(help_text));
+ gtk_text_buffer_set_text(buffer, help_text, -1);
gtk_text_view_set_buffer(GTK_TEXT_VIEW(textview1), buffer);
gtk_widget_show(dialog);
@@ -1721,9 +1705,9 @@ static void init_images(void)
gushort l, m, n;
/* define start images */
- l = g_random_int_range(0, MAX_PICS);
- m = g_random_int_range(0, MAX_PICS);
- n = g_random_int_range(0, MAX_PICS);
+ l = (gushort) g_random_int_range(0, MAX_PICS);
+ m = (gushort) g_random_int_range(0, MAX_PICS);
+ n = (gushort) g_random_int_range(0, MAX_PICS);
ensure_different_icons(&l, &m, &n);
Modified: src/geanywraplabel.c
8 files changed, 4 insertions(+), 4 deletions(-)
===================================================================
@@ -41,7 +41,7 @@ struct _GeanyWrapLabelClass
typedef struct
{
- gsize wrap_width;
+ gint wrap_width;
} GeanyWrapLabelPrivate;
struct _GeanyWrapLabel
@@ -53,7 +53,7 @@ struct _GeanyWrapLabel
static void geany_wrap_label_size_request (GtkWidget *widget, GtkRequisition *req);
static void geany_wrap_label_size_allocate (GtkWidget *widget, GtkAllocation *alloc);
-static void geany_wrap_label_set_wrap_width (GtkWidget *widget, gsize width);
+static void geany_wrap_label_set_wrap_width (GtkWidget *widget, gint width);
static void geany_wrap_label_label_notify (GObject *object, GParamSpec *pspec, gpointer data);
G_DEFINE_TYPE(GeanyWrapLabel, geany_wrap_label, GTK_TYPE_LABEL)
@@ -87,11 +87,11 @@ static void geany_wrap_label_init(GeanyWrapLabel *self)
/* Sets the point at which the text should wrap. */
-static void geany_wrap_label_set_wrap_width(GtkWidget *widget, gsize width)
+static void geany_wrap_label_set_wrap_width(GtkWidget *widget, gint width)
{
GeanyWrapLabelPrivate *priv;
- if (width == 0)
+ if (width <= 0)
return;
/*
Modified: src/keyfile.c
6 files changed, 3 insertions(+), 3 deletions(-)
===================================================================
@@ -99,9 +99,9 @@
static struct
{
- int number_ft_menu_items;
- int number_non_ft_menu_items;
- int number_exec_menu_items;
+ gint number_ft_menu_items;
+ gint number_non_ft_menu_items;
+ gint number_exec_menu_items;
}
build_menu_prefs;
Modified: src/prefs.c
17 files changed, 9 insertions(+), 8 deletions(-)
===================================================================
@@ -213,7 +213,8 @@ static void kb_show_popup_menu(GtkWidget *widget, GdkEventButton *event)
{
GtkWidget *item;
static GtkWidget *menu = NULL;
- gint button, event_time;
+ guint button;
+ guint32 event_time;
if (menu == NULL)
{
@@ -815,7 +816,7 @@ static void kb_update(void)
{
GtkWidget *widget;
guint i;
- guint autoclose_brackets[5];
+ gboolean autoclose_brackets[5];
gboolean old_invert_all = interface_prefs.highlighting_invert_all;
gboolean old_sidebar_pos = interface_prefs.sidebar_pos;
GeanyDocument *doc = document_get_current();
@@ -1078,11 +1079,11 @@ static void kb_update(void)
autoclose_brackets[4] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
editor_prefs.autoclose_chars =
- (autoclose_brackets[0] ? GEANY_AC_PARENTHESIS : 0)
- | (autoclose_brackets[1] ? GEANY_AC_CBRACKET : 0)
- | (autoclose_brackets[2] ? GEANY_AC_SBRACKET : 0)
- | (autoclose_brackets[3] ? GEANY_AC_SQUOTE : 0)
- | (autoclose_brackets[4] ? GEANY_AC_DQUOTE : 0);
+ (autoclose_brackets[0] ? GEANY_AC_PARENTHESIS : 0u)
+ | (autoclose_brackets[1] ? GEANY_AC_CBRACKET : 0u)
+ | (autoclose_brackets[2] ? GEANY_AC_SBRACKET : 0u)
+ | (autoclose_brackets[3] ? GEANY_AC_SQUOTE : 0u)
+ | (autoclose_brackets[4] ? GEANY_AC_DQUOTE : 0u);
/* Tools Settings */
@@ -1348,7 +1349,7 @@ static void kb_cell_edited_cb(GtkCellRendererText *cellrenderertext,
static gboolean kb_grab_key_dialog_key_press_cb(GtkWidget *dialog, GdkEventKey *event, gpointer user_data)
{
gchar *str;
- gint state;
+ guint state;
state = event->state & gtk_accelerator_get_default_mod_mask();
Modified: src/printing.c
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -51,7 +51,7 @@
#define ADD_ATTR(l, a) \
pango_attr_list_insert((l), (a)); \
(a)->start_index = 0; \
- (a)->end_index = -1;
+ (a)->end_index = G_MAXUINT;
enum
Modified: src/project.c
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -642,7 +642,7 @@ static gboolean update_config(const PropertyDialogElements *e, gboolean new_proj
{
const gchar *name, *file_name, *base_path;
gchar *locale_filename;
- gint name_len;
+ gsize name_len;
gint err_code = 0;
GeanyProject *p;
Modified: src/socket.h
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -30,7 +30,7 @@ struct socket_info_struct
gchar *file_name;
GIOChannel *read_ioc;
gint lock_socket;
- gint lock_socket_tag;
+ guint lock_socket_tag;
};
extern struct socket_info_struct socket_info;
Modified: src/symbols.c
6 files changed, 3 insertions(+), 3 deletions(-)
===================================================================
@@ -371,7 +371,7 @@ GString *symbols_get_macro_list(gint lang)
static TMTag *find_work_object_tag(const TMWorkObject *workobj,
- const gchar *tag_name, gint type)
+ const gchar *tag_name, guint type)
{
GPtrArray *tags;
TMTag *tmtag;
@@ -393,7 +393,7 @@ static TMTag *find_work_object_tag(const TMWorkObject *workobj,
}
-static TMTag *find_workspace_tag(const gchar *tag_name, gint type)
+static TMTag *find_workspace_tag(const gchar *tag_name, guint type)
{
guint j;
const GPtrArray *work_objects = NULL;
@@ -1785,7 +1785,7 @@ static void load_user_tags(filetype_id ft_id)
static gboolean goto_tag(const gchar *name, gboolean definition)
{
const gint forward_types = tm_tag_prototype_t | tm_tag_externvar_t;
- gint type;
+ guint type;
TMTag *tmtag = NULL;
GeanyDocument *old_doc = document_get_current();
Modified: src/templates.c
4 files changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -351,7 +351,7 @@ static void make_comment_block(GString *comment_text, gint filetype_idx, guint i
gchar *tmp;
gchar *prefix;
gchar **lines;
- guint i, len;
+ gsize i, len;
gint template_eol_mode;
const gchar *template_eol_char;
GeanyFiletype *ft = filetypes_index(filetype_idx);
@@ -655,7 +655,7 @@ static void templates_replace_command(GString *text, const gchar *file_name,
while (*match != '}' && *match != '\0')
match++;
- wildcard = g_strndup(cmd, match - cmd + 1);
+ wildcard = g_strndup(cmd, (gsize) (match - cmd + 1));
cmd = g_strndup(wildcard + 9, strlen(wildcard) - 10);
result = run_command(cmd, file_name, file_type, func_name);
Modified: src/toolbar.c
2 files changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -1063,7 +1063,7 @@ void toolbar_configure(GtkWindow *parent)
/* read the current active toolbar items */
markup = gtk_ui_manager_get_ui(uim);
- used_items = tb_editor_parse_ui(markup, strlen(markup), NULL);
+ used_items = tb_editor_parse_ui(markup, -1, NULL);
g_free(markup);
/* get all available actions */
Modified: src/utils.c
24 files changed, 13 insertions(+), 11 deletions(-)
===================================================================
@@ -1868,19 +1868,21 @@ gboolean utils_is_remote_path(const gchar *path)
return TRUE;
#ifndef G_OS_WIN32
- static gchar *fuse_path = NULL;
- static gsize len = 0;
-
- if (G_UNLIKELY(fuse_path == NULL))
{
- fuse_path = g_build_filename(g_get_home_dir(), ".gvfs", NULL);
- len = strlen(fuse_path);
+ static gchar *fuse_path = NULL;
+ static gsize len = 0;
+
+ if (G_UNLIKELY(fuse_path == NULL))
+ {
+ fuse_path = g_build_filename(g_get_home_dir(), ".gvfs", NULL);
+ len = strlen(fuse_path);
+ }
+ /* Comparing the file path against a hardcoded path is not the most elegant solution
+ * but for now it is better than nothing. Ideally, g_file_new_for_path() should create
+ * proper GFile objects for Fuse paths, but it only does in future GVFS
+ * versions (gvfs 1.1.1). */
+ return (strncmp(path, fuse_path, len) == 0);
}
- /* Comparing the file path against a hardcoded path is not the most elegant solution
- * but for now it is better than nothing. Ideally, g_file_new_for_path() should create
- * proper GFile objects for Fuse paths, but it only does in future GVFS
- * versions (gvfs 1.1.1). */
- return (strncmp(path, fuse_path, len) == 0);
#endif
return FALSE;
@@ Diff output truncated at 100000 characters. @@
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).
More information about the Commits
mailing list