Alexandre Julliard : makedep: Add a helper function for concatenating paths.

Alexandre Julliard julliard at winehq.org
Mon Mar 10 14:38:29 CDT 2014


Module: wine
Branch: master
Commit: c3c35dcff8e25b74ef5cb2fcfb5b38e21efdc4a3
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c3c35dcff8e25b74ef5cb2fcfb5b38e21efdc4a3

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Mar 10 11:10:55 2014 +0100

makedep: Add a helper function for concatenating paths.

---

 tools/makedep.c |   23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/tools/makedep.c b/tools/makedep.c
index fe8a614..eb77d57 100644
--- a/tools/makedep.c
+++ b/tools/makedep.c
@@ -454,12 +454,23 @@ static char *get_relative_path( const char *from, const char *dest )
 
 
 /*******************************************************************
+ *         concat_paths
+ */
+static char *concat_paths( const char *base, const char *path )
+{
+    if (!base) return xstrdup( path[0] ? path : "." );
+    if (path[0] == '/') return xstrdup( path );
+    if (!path[0]) return xstrdup( base );
+    return strmake( "%s/%s", base, path );
+}
+
+
+/*******************************************************************
  *         base_dir_path
  */
 static char *base_dir_path( const char *path )
 {
-    if (base_dir && path[0] != '/') return strmake( "%s/%s", base_dir, path );
-    return xstrdup( path );
+    return concat_paths( base_dir, path );
 }
 
 
@@ -468,8 +479,7 @@ static char *base_dir_path( const char *path )
  */
 static char *src_dir_path( const char *path )
 {
-    if (src_dir) return strmake( "%s/%s", src_dir, path );
-    return xstrdup( path );
+    return concat_paths( src_dir, path );
 }
 
 
@@ -478,8 +488,7 @@ static char *src_dir_path( const char *path )
  */
 static char *top_obj_dir_path( const char *path )
 {
-    if (top_obj_dir) return strmake( "%s/%s", top_obj_dir, path );
-    return xstrdup( path );
+    return concat_paths( top_obj_dir, path );
 }
 
 
@@ -488,7 +497,7 @@ static char *top_obj_dir_path( const char *path )
  */
 static char *top_dir_path( const char *path )
 {
-    if (top_src_dir) return strmake( "%s/%s", top_src_dir, path );
+    if (top_src_dir) return concat_paths( top_src_dir, path );
     return top_obj_dir_path( path );
 }
 




More information about the wine-cvs mailing list