[geany/geany] 85a894: Grab args.c/h uctags implementation

Jiří Techet git-noreply at xxxxx
Mon Dec 17 21:05:35 UTC 2018


Branch:      refs/heads/master
Author:      Jiří Techet <techet at gmail.com>
Committer:   Jiří Techet <techet at gmail.com>
Date:        Sat, 08 Oct 2016 12:12:45 UTC
Commit:      85a894b09789f2ed7201ba6f92be3d0092e33da4
             https://github.com/geany/geany/commit/85a894b09789f2ed7201ba6f92be3d0092e33da4

Log Message:
-----------
Grab args.c/h uctags implementation

Basically dead code for us.


Modified Paths:
--------------
    ctags/main/args.c
    ctags/main/args.h

Modified: ctags/main/args.c
50 lines changed, 43 insertions(+), 7 deletions(-)
===================================================================
@@ -69,6 +69,12 @@ static char* nextStringLine (const char** const next)
 	}
 	if (*end == '\n')
 		++end;
+	else if (*end == '\r')
+	{
+		++end;
+		if (*end == '\n')
+			++end;
+	}
 	*next = end;
 	return result;
 }
@@ -121,26 +127,59 @@ static char* nextFileLine (FILE* const fp)
 		int c;
 
 		c = fgetc (fp);
-		while (c != EOF  &&  c != '\n')
+		while (c != EOF)
 		{
-			vStringPut (vs, c);
+			if (c != '\n'  &&  c != '\r')
+				vStringPut (vs, c);
+			else if (vStringLength (vs) > 0)
+				break;
 			c = fgetc (fp);
 		}
-		if (vStringLength (vs) > 0)
+		if (c != EOF  ||  vStringLength (vs) > 0)
 		{
+			if (c == '\r')
+			{
+				c = fgetc (fp);
+				if (c != '\n')
+					c = ungetc (c, fp);
+			}
+			vStringStripTrailing (vs);
 			result = xMalloc (vStringLength (vs) + 1, char);
+			vStringStripLeading (vs);
 			strcpy (result, vStringValue (vs));
 		}
 		vStringDelete (vs);
 	}
 	return result;
 }
 
+static bool isCommentLine (char* line)
+{
+	while (isspace(*line))
+		++line;
+	return (*line == '#');
+}
+
+static char* nextFileLineSkippingComments (FILE* const fp)
+{
+	char* result;
+	bool comment;
+
+	do
+	{
+		result = nextFileLine (fp);
+		comment = (result && isCommentLine (result));
+		if (comment)
+			eFree (result);
+	} while (comment);
+	return result;
+}
+
 static char* nextFileString (const Arguments* const current, FILE* const fp)
 {
 	char* result;
 	if (current->lineMode)
-		result = nextFileLine (fp);
+		result = nextFileLineSkippingComments (fp);
 	else
 		result = nextFileArg (fp);
 	return result;
@@ -151,8 +190,6 @@ extern Arguments* argNewFromString (const char* const string)
 	Arguments* result = xMalloc (1, Arguments);
 	memset (result, 0, sizeof (Arguments));
 	result->type = ARG_STRING;
-	result->u.stringArgs.string = string;
-	result->u.stringArgs.item = string;
 	result->u.stringArgs.next = string;
 	result->item = nextString (result, &result->u.stringArgs.next);
 	return result;
@@ -224,7 +261,6 @@ extern void argForth (Arguments* const current)
 		case ARG_STRING:
 			if (current->item != NULL)
 				eFree (current->item);
-			current->u.stringArgs.item = current->u.stringArgs.next;
 			current->item = nextString (current, &current->u.stringArgs.next);
 			break;
 		case ARG_ARGV:


Modified: ctags/main/args.h
6 lines changed, 3 insertions(+), 3 deletions(-)
===================================================================
@@ -20,13 +20,13 @@
 *   DATA DECLARATIONS
 */
 
+typedef enum { ARG_NONE, ARG_STRING, ARG_ARGV, ARG_FILE } argType;
+
 typedef struct sArgs {
-	enum { ARG_NONE, ARG_STRING, ARG_ARGV, ARG_FILE } type;
+	argType type;
 	union {
 		struct sStringArgs {
-			const char* string;
 			const char* next;
-			const char* item;
 		} stringArgs;
 		struct sArgvArgs {
 			char* const* argv;



--------------
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