[geany/geany] 2d31d8: make: Support for combined targets

Colomban Wendling git-noreply at xxxxx
Mon Apr 20 17:48:30 UTC 2015


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Mon, 20 Apr 2015 17:48:30 UTC
Commit:      2d31d8f836e3a16ae86dfb3f3426e5a272ca6f8c
             https://github.com/geany/geany/commit/2d31d8f836e3a16ae86dfb3f3426e5a272ca6f8c

Log Message:
-----------
make: Support for combined targets


Modified Paths:
--------------
    tagmanager/ctags/make.c
    tests/ctags/Makefile.am
    tests/ctags/make-multi-target.mak
    tests/ctags/make-multi-target.mak.tags
    tests/ctags/simple.mak.tags

Modified: tagmanager/ctags/make.c
130 lines changed, 52 insertions(+), 78 deletions(-)
===================================================================
@@ -105,42 +105,19 @@ static void newMacro (vString *const name)
 	makeSimpleTag (name, MakeKinds, K_MACRO);
 }
 
-static void newMacroFromDefine (vString *const name)
-{
-	/* name is something like "define JAVAHPP_RULE", find the space and jump to the next char */
-	char *name_val = strchr (vStringValue (name), ' ');
-
-	if (name_val != NULL) {
-		vStringCopyS (name, name_val + 1);
-		makeSimpleTag (name, MakeKinds, K_MACRO);
-	}
-}
-
 static void readIdentifier (const int first, vString *const id)
 {
 	int depth = 0;
 	int c = first;
-	int c_prev = first;
-	int c_next = first;
 	vStringClear (id);
-	while (isIdentifier (c) || c == ' ' || (depth > 0 && c != EOF && c != '\n'))
+	while (isIdentifier (c) || (depth > 0 && c != EOF && c != '\n'))
 	{
-		c_next = nextChar ();
 		if (c == '(' || c == '}')
 			depth++;
 		else if (depth > 0 && (c == ')' || c == '}'))
 			depth--;
-		if (depth < 1 && c == ' ') {
-			/* add the space character only if the previous and
-			 * next character are valid identifiers */
-			if (isIdentifier (c_prev) && isIdentifier (c_next))
-				vStringPut (id, c);
-		}
-		else {
-			vStringPut (id, c);
-		}
-		c_prev = c;
-		c = c_next;
+		vStringPut (id, c);
+		c = nextChar ();
 	}
 	fileUngetc (c);
 	vStringTerminate (id);
@@ -148,7 +125,7 @@ static void readIdentifier (const int first, vString *const id)
 
 static void findMakeTags (void)
 {
-	vString *name = vStringNew ();
+	stringList *identifiers = stringListNew ();
 	boolean newline = TRUE;
 	boolean in_define = FALSE;
 	boolean in_rule = FALSE;
@@ -169,6 +146,7 @@ static void findMakeTags (void)
 				else
 					in_rule = FALSE;
 			}
+			stringListClear (identifiers);
 			variable_possible = (boolean)(!in_rule);
 			newline = FALSE;
 		}
@@ -178,74 +156,70 @@ static void findMakeTags (void)
 			continue;
 		else if (c == '#')
 			skipLine ();
-		else if (c == ':')
+		else if (variable_possible && c == '?')
+		{
+			c = nextChar ();
+			fileUngetc (c);
+			variable_possible = (c == '=');
+		}
+		else if (variable_possible && c == ':' &&
+				 stringListCount (identifiers) > 0)
+		{
+			c = nextChar ();
+			fileUngetc (c);
+			if (c != '=')
+			{
+				unsigned int i;
+				for (i = 0; i < stringListCount (identifiers); i++)
+					newTarget (stringListItem (identifiers, i));
+				stringListClear (identifiers);
+				in_rule = TRUE;
+			}
+		}
+		else if (variable_possible && c == '=' &&
+				 stringListCount (identifiers) == 1)
 		{
-			variable_possible = TRUE;
-			in_rule = TRUE;
+			newMacro (stringListItem (identifiers, 0));
+			skipLine ();
+			in_rule = FALSE;
 		}
 		else if (variable_possible && isIdentifier (c))
 		{
+			vString *name = vStringNew ();
 			readIdentifier (c, name);
-			if (strncmp (vStringValue (name), "endef", 5) == 0)
-				in_define = FALSE;
-			else if (in_define)
-				skipLine ();
-			else if (strncmp (vStringValue (name), "define", 6) == 0  &&
-				isIdentifier (c))
+			stringListAdd (identifiers, name);
+
+			if (stringListCount (identifiers) == 1)
 			{
-				in_define = TRUE;
-				c = skipToNonWhite ();
-				newMacroFromDefine (name);
-				skipLine ();
-			}
-			else {
-				c = skipToNonWhite ();
-				if (strchr (":?+", c) != NULL)
+				if (in_define && ! strcmp (vStringValue (name), "endef"))
+					in_define = FALSE;
+				else if (in_define)
+					skipLine ();
+				else if (! strcmp (vStringValue (name), "define"))
 				{
-					boolean append = (boolean)(c == '+');
-					boolean was_colon = (c == ':');
-					c = nextChar ();
-					if (was_colon)
-					{
-						if (c == '=')
-						{
-							newMacro (name);
-							in_rule = FALSE;
-							skipLine ();
-						}
-						else
-						{
-							fileUngetc (c);
-							in_rule = TRUE;
-							newTarget (name);
-						}
-					}
-					else if (append)
+					in_define = TRUE;
+					c = skipToNonWhite ();
+					vStringClear (name);
+					/* all remaining characters on the line are the name -- even spaces */
+					while (c != EOF && c != '\n')
 					{
-						skipLine ();
-						continue;
+						vStringPut (name, c);
+						c = nextChar ();
 					}
-					else
-					{
+					if (c == '\n')
 						fileUngetc (c);
-					}
-				}
-				else if (c == '=')
-				{
+					vStringTerminate (name);
+					vStringStripTrailing (name);
 					newMacro (name);
-					in_rule = FALSE;
-					skipLine ();
-				}
-				else
-				{
-					fileUngetc (c);
 				}
+				else if (! strcmp (vStringValue (name), "export"))
+					stringListClear (identifiers);
 			}
 		}
 		else
 			variable_possible = FALSE;
 	}
-	vStringDelete (name);
+	stringListDelete (identifiers);
 }
 
 extern parserDefinition* MakefileParser (void)


Modified: tests/ctags/Makefile.am
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -200,6 +200,7 @@ test_sources = \
 	line_directives.c				\
 	local.c							\
 	macros.c						\
+	make-multi-target.mak			\
 	make-target-with-parentheses.mak	\
 	make-variable-on-cmdline.mak	\
 	masm.asm						\


Modified: tests/ctags/make-multi-target.mak
8 lines changed, 8 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,8 @@
+
+all: foo bar
+
+foo bar: baz
+	echo $@
+
+baz:
+	echo $@


Modified: tests/ctags/make-multi-target.mak.tags
5 lines changed, 5 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,5 @@
+# format=tagmanager
+all�16�0
+bar�16�0
+baz�16�0
+foo�16�0


Modified: tests/ctags/simple.mak.tags
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -8,7 +8,7 @@ E
 F�65536�0
 G�65536�0
 H�65536�0
+I�65536�0
 a.o�16�0
 b.o�16�0
 default�16�0
-export I�65536�0



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list