SF.net SVN: geany:[5855] trunk
colombanw at users.sourceforge.net
colombanw at xxxxx
Fri Jun 17 22:52:18 UTC 2011
Revision: 5855
http://geany.svn.sourceforge.net/geany/?rev=5855&view=rev
Author: colombanw
Date: 2011-06-17 22:52:17 +0000 (Fri, 17 Jun 2011)
Log Message:
-----------
Fix a few signed vs. unsigned and differently-sized integer problems
Most notably, utils_get_line_endings() and document_open_file_list()
don't support -1 as the size anymore. If the size should be computed
from null-terminated data, the caller code must take care of doing so.
Modified Paths:
--------------
trunk/ChangeLog
trunk/plugins/classbuilder.c
trunk/plugins/htmlchars.c
trunk/src/dialogs.c
trunk/src/document.c
trunk/src/document.h
trunk/src/editor.c
trunk/src/utils.c
trunk/src/utils.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2011-06-17 22:51:51 UTC (rev 5854)
+++ trunk/ChangeLog 2011-06-17 22:52:17 UTC (rev 5855)
@@ -1,3 +1,11 @@
+2011-06-18 Colomban Wendling <colomban(at)geany(dot)org>
+
+ * src/document.c, src/document.h, src/editor.c:
+ Remove support of size being -1 in document_open_file_list().
+ * src/utils.c src/utils.h:
+ Remove support of size being -1 in utils_get_line_endings().
+
+
2011-06-16 Colomban Wendling <colomban(at)geany(dot)org>
* src/document.c, src/main.c, src/ui_utils.c, src/utils.c:
Modified: trunk/plugins/classbuilder.c
===================================================================
--- trunk/plugins/classbuilder.c 2011-06-17 22:51:51 UTC (rev 5854)
+++ trunk/plugins/classbuilder.c 2011-06-17 22:52:17 UTC (rev 5855)
@@ -374,7 +374,7 @@
/* Attaches a new section label at the specified table row, optionally
* padded at the top, and returns the new label. */
static GtkWidget *cc_table_attach_section_label(GtkWidget *table, const gchar *text,
- gint row, gboolean top_padding)
+ guint row, gboolean top_padding)
{
gchar *markup;
GtkWidget *label, *align;
@@ -399,7 +399,7 @@
/* Attach a new option label at the specified table row and returns
* the label */
-static GtkWidget *cc_table_attach_option_label(GtkWidget *table, const gchar *text, gint row)
+static GtkWidget *cc_table_attach_option_label(GtkWidget *table, const gchar *text, guint row)
{
GtkWidget *opt_label = cc_option_label_new(text);
gtk_table_attach(GTK_TABLE(table), opt_label,
@@ -412,7 +412,7 @@
* The label associated with the widget is set as data on the entry
* with the "label" key, if access to it is needed later. The entry
* widget is returned. */
-static GtkWidget *cc_table_attach_option_entry(GtkWidget *table, const gchar *text, gint row)
+static GtkWidget *cc_table_attach_option_entry(GtkWidget *table, const gchar *text, guint row)
{
GtkWidget *label;
GtkWidget *entry;
@@ -430,7 +430,7 @@
CreateClassDialog *cc_dlg;
GtkWidget *main_box, *table, *label, *hdr_hbox;
GtkWidget *opt_table, *align;
- gint row;
+ guint row;
cc_dlg = g_new0(CreateClassDialog, 1);
cc_dlg->class_type = type;
Modified: trunk/plugins/htmlchars.c
===================================================================
--- trunk/plugins/htmlchars.c 2011-06-17 22:51:51 UTC (rev 5854)
+++ trunk/plugins/htmlchars.c 2011-06-17 22:52:17 UTC (rev 5855)
@@ -649,10 +649,10 @@
if (doc != NULL && sci_has_selection(doc->editor->sci))
{
- guint selection_len;
+ gsize selection_len;
gchar *selection;
GString *replacement = g_string_new(NULL);
- guint i;
+ gsize i;
gchar *new;
const gchar *entity = NULL;
gchar buf[7];
@@ -664,7 +664,7 @@
for (i = 0; i < selection_len; i++)
{
len = g_unichar_to_utf8(g_utf8_get_char(selection + i), buf);
- i = len - 1 + i;
+ i = (guint)len - 1 + i;
buf[len] = '\0';
entity = get_entity(buf);
Modified: trunk/src/dialogs.c
===================================================================
--- trunk/src/dialogs.c 2011-06-17 22:51:51 UTC (rev 5854)
+++ trunk/src/dialogs.c 2011-06-17 22:52:17 UTC (rev 5855)
@@ -221,7 +221,7 @@
iter_utf8, iter_middleeast;
GtkTreeIter *iter_parent;
gchar *encoding_string;
- guint i;
+ gint i;
store = gtk_tree_store_new(2, G_TYPE_INT, G_TYPE_STRING);
Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c 2011-06-17 22:51:51 UTC (rev 5854)
+++ trunk/src/document.c 2011-06-17 22:52:17 UTC (rev 5855)
@@ -307,7 +307,7 @@
length = 30;
base_name = g_path_get_basename(DOC_FILENAME(doc));
- short_name = utils_str_middle_truncate(base_name, length);
+ short_name = utils_str_middle_truncate(base_name, (guint)length);
g_free(base_name);
@@ -926,7 +926,7 @@
ScintillaObject *sci = editor->sci;
gsize count = 0;
struct Sci_TextToFind ttf;
- gchar *soft_tab = g_strnfill(iprefs->width, ' ');
+ gchar *soft_tab = g_strnfill((gsize)iprefs->width, ' ');
gchar *regex = g_strconcat("^\t+", soft_tab, "[^ ]", NULL);
g_free(soft_tab);
@@ -955,7 +955,7 @@
{
const GeanyIndentPrefs *iprefs = editor_get_indent_prefs(editor);
ScintillaObject *sci = editor->sci;
- guint line, line_count;
+ gint line, line_count;
gsize tabs = 0, spaces = 0;
if (detect_tabs_and_spaces(editor))
@@ -997,7 +997,7 @@
{
const GeanyIndentPrefs *iprefs = editor_get_indent_prefs(editor);
ScintillaObject *sci = editor->sci;
- guint line, line_count;
+ gint line, line_count;
gint widths[7] = { 0 }; /* width can be from 2 to 8 */
gint count, width, i;
@@ -1282,18 +1282,15 @@
/* Takes a new line separated list of filename URIs and opens each file.
- * length is the length of the string or -1 if it should be detected */
-void document_open_file_list(const gchar *data, gssize length)
+ * length is the length of the string */
+void document_open_file_list(const gchar *data, gsize length)
{
- gint i;
+ guint i;
gchar *filename;
gchar **list;
g_return_if_fail(data != NULL);
- if (length < 0)
- length = strlen(data);
-
list = g_strsplit(data, utils_get_eol_char(utils_get_line_endings(data, length)), 0);
for (i = 0; list[i] != NULL; i++)
Modified: trunk/src/document.h
===================================================================
--- trunk/src/document.h 2011-06-17 22:51:51 UTC (rev 5854)
+++ trunk/src/document.h 2011-06-17 22:52:17 UTC (rev 5855)
@@ -209,7 +209,7 @@
GeanyDocument *document_open_file_full(GeanyDocument *doc, const gchar *filename, gint pos,
gboolean readonly, GeanyFiletype *ft, const gchar *forced_enc);
-void document_open_file_list(const gchar *data, gssize length);
+void document_open_file_list(const gchar *data, gsize length);
void document_open_files(const GSList *filenames, gboolean readonly, GeanyFiletype *ft,
const gchar *forced_enc);
Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c 2011-06-17 22:51:51 UTC (rev 5854)
+++ trunk/src/editor.c 2011-06-17 22:52:17 UTC (rev 5855)
@@ -1102,7 +1102,7 @@
case SCN_URIDROPPED:
if (nt->text != NULL)
{
- document_open_file_list(nt->text, -1);
+ document_open_file_list(nt->text, strlen(nt->text));
}
break;
Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c 2011-06-17 22:51:51 UTC (rev 5854)
+++ trunk/src/utils.c 2011-06-17 22:52:17 UTC (rev 5855)
@@ -120,15 +120,12 @@
/* taken from anjuta, to determine the EOL mode of the file */
-gint utils_get_line_endings(const gchar* buffer, glong size)
+gint utils_get_line_endings(const gchar* buffer, gsize size)
{
- gint i;
+ gsize i;
guint cr, lf, crlf, max_mode;
gint mode;
- if (size == -1)
- size = strlen(buffer);
-
cr = lf = crlf = 0;
for (i = 0; i < size ; i++)
@@ -247,7 +244,7 @@
else
{
FILE *fp;
- gint bytes_written, len;
+ gsize bytes_written, len;
gboolean fail = FALSE;
if (filename == NULL)
@@ -266,7 +263,7 @@
{
fail = TRUE;
geany_debug(
- "utils_write_file(): written only %d bytes, had to write %d bytes to %s",
+ "utils_write_file(): written only %"G_GSIZE_FORMAT" bytes, had to write %"G_GSIZE_FORMAT" bytes to %s",
bytes_written, len, filename);
}
if (fclose(fp) != 0)
@@ -291,7 +288,7 @@
gchar *utils_find_open_xml_tag(const gchar sel[], gint size)
{
const gchar *cur, *begin;
- gint len;
+ gsize len;
cur = utils_find_open_xml_tag_pos(sel, size);
if (cur == NULL)
@@ -302,7 +299,7 @@
while (strchr(":_-.", *cur) || isalnum(*cur))
cur++;
- len = cur - begin;
+ len = (gsize)(cur - begin);
return len ? g_strndup(begin, len) : NULL;
}
Modified: trunk/src/utils.h
===================================================================
--- trunk/src/utils.h 2011-06-17 22:51:51 UTC (rev 5854)
+++ trunk/src/utils.h 2011-06-17 22:52:17 UTC (rev 5855)
@@ -132,7 +132,7 @@
void utils_open_browser(const gchar *uri);
-gint utils_get_line_endings(const gchar* buffer, glong size);
+gint utils_get_line_endings(const gchar* buffer, gsize size);
gboolean utils_isbrace(gchar c, gboolean include_angles);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list