SF.net SVN: geany:[3449] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Tue Jan 6 14:53:31 UTC 2009


Revision: 3449
          http://geany.svn.sourceforge.net/geany/?rev=3449&view=rev
Author:   eht16
Date:     2009-01-06 14:53:31 +0000 (Tue, 06 Jan 2009)

Log Message:
-----------
Fix some bugs in parsing FreeBasic code (#2489605).

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/tagmanager/basic.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-01-04 23:32:33 UTC (rev 3448)
+++ trunk/ChangeLog	2009-01-06 14:53:31 UTC (rev 3449)
@@ -1,3 +1,9 @@
+2009-01-06  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
+
+ * tagmanager/basic.c:
+   Fix some bugs in parsing FreeBasic code (#2489605).
+
+
 2009-01-04  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
 
  * wscript, THANKS, data/filetype_extensions.conf, src/templates.c,

Modified: trunk/tagmanager/basic.c
===================================================================
--- trunk/tagmanager/basic.c	2009-01-04 23:32:33 UTC (rev 3448)
+++ trunk/tagmanager/basic.c	2009-01-06 14:53:31 UTC (rev 3449)
@@ -71,9 +71,14 @@
 /* Match the name of a dim or const starting at pos. */
 static int extract_dim (char const *pos, vString * name, BasicKind kind)
 {
+	const char *old_pos = pos;
 	while (isspace (*pos))
 		pos++;
 
+	/* create tags only if there is some space between the keyword and the identifier */
+	if (old_pos == pos)
+		return 0;
+
 	vStringClear (name);
 
 	if (strncasecmp (pos, "shared", 6) == 0)
@@ -95,15 +100,20 @@
 			pos++;
 		/* now we are at the name */
 	}
-
 	/* capture "dim as foo ptr bar" */
-	if (strncasecmp (pos, "ptr", 3) == 0)
+	if (strncasecmp (pos, "ptr", 3) == 0 && isspace(*(pos+4)))
 	{
 		pos += 3; /* skip keyword "ptr" */
-
 		while (isspace (*pos))
 			pos++;
 	}
+	/*	capture "dim as string * 4096 chunk" */
+	if (strncmp (pos, "*", 1) == 0)
+	{
+		pos += 1; /* skip "*" */
+		while (isspace (*pos) || isdigit(*pos) || ispunct(*pos))
+			pos++;
+	}
 
 	for (; *pos && !isspace (*pos) && *pos != '(' && *pos != ',' && *pos != '='; pos++)
 		vStringPut (name, *pos);
@@ -155,6 +165,7 @@
 	vString *name;
 	size_t i;
 	int j;
+	const char *old_p;
 	for (i = 0; i < strlen (kw->token); i++)
 	{
 		if (tolower (p[i]) != kw->token[i])
@@ -167,6 +178,17 @@
 		kw == &freebasic_keywords[2])
 		return extract_dim (p, name, kw->kind); /* extract_dim adds the found tag(s) */
 
+	old_p = p;
+	while (isspace (*p))
+		p++;
+
+	/* create tags only if there is some space between the keyword and the identifier */
+	if (old_p == p)
+	{
+		vStringDelete (name);
+		return 0;
+	}
+
 	for (j = 0; j < 1; j++)
 	{
 		p = extract_name (p, name);
@@ -207,8 +229,8 @@
 		while (isspace (*p))
 			p++;
 
-		/* Empty line? */
-		if (!*p)
+		/* Empty line or comment? */
+		if (!*p || *p == '\'')
 			continue;
 
 		/* In Basic, keywords always are at the start of the line. */


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