[geany/geany] f0e7af: Make combinePathAndFile() return char * instead of vString

Jiří Techet git-noreply at xxxxx
Mon Dec 17 21:05:32 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:      f0e7af2c3279cd8ced9806050f38629c930502f3
             https://github.com/geany/geany/commit/f0e7af2c3279cd8ced9806050f38629c930502f3

Log Message:
-----------
Make combinePathAndFile() return char * instead of vString

Also move eStrdup() to the correct position in the header.

In addition add the same includes into debug.h as those in uctags (the
removal of vstring inclusion inside routines.h causes compilation errors -
it would be best to explicitly include all needed files in every source to
avoid problems like this but let's do just syncing the two implementations
for now).


Modified Paths:
--------------
    ctags/main/debug.h
    ctags/main/read.c
    ctags/main/routines.c
    ctags/main/routines.h

Modified: ctags/main/debug.h
22 lines changed, 22 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,22 @@
+/*
+*   Copyright (c) 1998-2002, Darren Hiebert
+*
+*   This source code is released for free distribution under the terms of the
+*   GNU General Public License version 2 or (at your option) any later version.
+*
+*   External interface to debug.c
+*/
+#ifndef CTAGS_MAIN_DEBUG_H
+#define CTAGS_MAIN_DEBUG_H
+
+/*
+*   Include files
+*/
+#include "general.h"  /* must always come first */
+
+#ifdef DEBUG
+# include <assert.h>
+#endif
+#include "entry.h"
+
+#endif  /* CTAGS_MAIN_DEBUG_H */


Modified: ctags/main/read.c
7 lines changed, 5 insertions(+), 2 deletions(-)
===================================================================
@@ -112,8 +112,11 @@ static bool setSourceFileName (vString *const fileName)
 		if (isAbsolutePath (vStringValue (fileName)) || File.path == NULL)
 			pathName = vStringNewCopy (fileName);
 		else
-			pathName = combinePathAndFile (vStringValue (File.path),
-										vStringValue (fileName));
+		{
+			char *tmp = combinePathAndFile (
+				vStringValue (File.path), vStringValue (fileName));
+			pathName = vStringNewOwn (tmp);
+		}
 		setSourceFileParameters (pathName, -1);
 		result = true;
 	}


Modified: ctags/main/routines.c
12 lines changed, 4 insertions(+), 8 deletions(-)
===================================================================
@@ -490,23 +490,19 @@ extern bool isAbsolutePath (const char *const path)
 	return result;
 }
 
-extern vString *combinePathAndFile (const char *const path,
-									const char *const file)
+extern char *combinePathAndFile (
+	const char *const path, const char *const file)
 {
 	vString *const filePath = vStringNew ();
 	const int lastChar = path [strlen (path) - 1];
-# ifdef MSDOS_STYLE_PATH
-	bool terminated = (bool) (strchr (PathDelimiters, lastChar) != NULL);
-# else
-	bool terminated = (bool) (lastChar == PATH_SEPARATOR);
-# endif
+	bool terminated = isPathSeparator (lastChar);
 
 	vStringCopyS (filePath, path);
 	if (! terminated)
 		vStringPut (filePath, OUTPUT_PATH_SEPARATOR);
 	vStringCatS (filePath, file);
 
-	return filePath;
+	return vStringDeleteUnwrap (filePath);
 }
 
 /* Return a newly-allocated string whose contents concatenate those of


Modified: ctags/main/routines.h
5 lines changed, 2 insertions(+), 3 deletions(-)
===================================================================
@@ -16,7 +16,6 @@
 
 #include <stdio.h>
 
-#include "vstring.h"
 #include "mio.h"
 
 /*
@@ -106,6 +105,7 @@ extern void eFree (void *const ptr);
 #ifndef HAVE_STRSTR
 extern char* strstr (const char *str, const char *substr);
 #endif
+extern char* eStrdup (const char* str);
 extern void toLowerString (char* str);
 extern void toUpperString (char* str);
 extern char* newLowerString (const char* str);
@@ -120,11 +120,10 @@ extern bool isSameFile (const char *const name1, const char *const name2);
 extern const char *baseFilename (const char *const filePath);
 extern const char *fileExtension (const char *const fileName);
 extern bool isAbsolutePath (const char *const path);
-extern vString *combinePathAndFile (const char *const path, const char *const file);
+extern char *combinePathAndFile (const char *const path, const char *const file);
 extern char* absoluteFilename (const char *file);
 extern char* absoluteDirname (char *file);
 extern char* relativeFilename (const char *file, const char *dir);
 extern MIO *tempFile (const char *const mode, char **const pName);
-extern char* eStrdup (const char* str);
 
 #endif  /* CTAGS_MAIN_ROUTINES_H */



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