SF.net SVN: geany:[5610] trunk

colombanw at users.sourceforge.net colombanw at xxxxx
Sun Mar 20 16:02:53 UTC 2011


Revision: 5610
          http://geany.svn.sourceforge.net/geany/?rev=5610&view=rev
Author:   colombanw
Date:     2011-03-20 16:02:52 +0000 (Sun, 20 Mar 2011)

Log Message:
-----------
Fix a few warnings and style

* Don't use strlen(..) > 0 or == 0, simply check the first character
  against 0;
* Fix a return without a value (my bad in last commit);
* Fix storing a literal in a non-const string.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/editor.c
    trunk/src/search.c
    trunk/tagmanager/diff.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2011-03-20 15:02:22 UTC (rev 5609)
+++ trunk/ChangeLog	2011-03-20 16:02:52 UTC (rev 5610)
@@ -5,6 +5,9 @@
    Add new filetype setting "comment_single" to provide separated
    single-line and multiline comment support. Single-line are used in
    priority to comment code, and multiline to make template comments.
+ * src/editor.c, src/search.c, tagmanager/diff.c:
+   Don't use strlen(..) > 0 or == 0, simply check the first character
+   against 0.
 
 
 2011-03-19  Colomban Wendling  <colomban(at)geany(dot)org>

Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c	2011-03-20 15:02:22 UTC (rev 5609)
+++ trunk/src/editor.c	2011-03-20 16:02:52 UTC (rev 5610)
@@ -2944,7 +2944,7 @@
 		co = ft->comment_open;
 		cc = ft->comment_close;
 		if (co == NULL)
-			return;
+			return 0;
 	}
 
 	co_len = strlen(co);
@@ -2973,7 +2973,7 @@
 		if (x < line_len && sel[x] != '\0')
 		{
 			/* use single line comment */
-			if (cc == NULL || strlen(cc) == 0)
+			if (cc == NULL || cc[0] == '\0')
 			{
 				single_line = TRUE;
 
@@ -3281,7 +3281,7 @@
 		if (allow_empty_lines || (x < line_len && sel[x] != '\0'))
 		{
 			/* use single line comment */
-			if (cc == NULL || strlen(cc) == 0)
+			if (cc == NULL || cc[0] == '\0')
 			{
 				gint start = line_start;
 				single_line = TRUE;
@@ -3471,8 +3471,8 @@
 	{
 		gchar *previous_line = sci_get_line(sci, cur_line - 1);
 		/* the type of comment, '*' (C/C++/Java), '+' and the others (D) */
-		gchar *continuation = "*";
-		gchar *whitespace = ""; /* to hold whitespace if needed */
+		const gchar *continuation = "*";
+		const gchar *whitespace = ""; /* to hold whitespace if needed */
 		gchar *result;
 		gint len = strlen(previous_line);
 		gint i;

Modified: trunk/src/search.c
===================================================================
--- trunk/src/search.c	2011-03-20 15:02:22 UTC (rev 5609)
+++ trunk/src/search.c	2011-03-20 16:02:52 UTC (rev 5610)
@@ -1142,7 +1142,7 @@
 		search_data.flags = int_search_flags(settings.find_case_sensitive,
 			settings.find_match_whole_word, settings.find_regexp, settings.find_match_word_start);
 
-		if (strlen(search_data.text) == 0)
+		if (search_data.text[0] == '\0')
 		{
 			fail:
 			utils_beep();

Modified: trunk/tagmanager/diff.c
===================================================================
--- trunk/tagmanager/diff.c	2011-03-20 15:02:22 UTC (rev 5609)
+++ trunk/tagmanager/diff.c	2011-03-20 16:02:52 UTC (rev 5610)
@@ -60,7 +60,7 @@
 					tmp = (const unsigned char*) strrchr((const char*) cp, '\\');
 					if (tmp == NULL)
 					{	/* last fallback, probably the filename doesn't contain a path, so take it */
-						if (strlen((const char*) cp) > 0)
+						if (cp[0] != 0)
 						{
 							tmp = cp;
 							skipSlash = FALSE;


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