Alexandre Julliard : makefiles: Remove .. components from generated paths.

Alexandre Julliard julliard at winehq.org
Mon Sep 14 14:58:23 CDT 2020


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Sep 14 11:26:35 2020 +0200

makefiles: Remove .. components from generated paths.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 tools/makedep.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/tools/makedep.c b/tools/makedep.c
index fcb8c8adf3..cc09a0e1ce 100644
--- a/tools/makedep.c
+++ b/tools/makedep.c
@@ -711,10 +711,34 @@ static char *get_relative_path( const char *from, const char *dest )
  */
 static char *concat_paths( const char *base, const char *path )
 {
+    int i, len;
+    char *ret;
+
     if (!base || !base[0]) return xstrdup( path && path[0] ? path : "." );
     if (!path || !path[0]) return xstrdup( base );
     if (path[0] == '/') return xstrdup( path );
-    return strmake( "%s/%s", base, path );
+
+    len = strlen( base );
+    while (len && base[len - 1] == '/') len--;
+    while (len && !strncmp( path, "..", 2 ) && (!path[2] || path[2] == '/'))
+    {
+        for (i = len; i > 0; i--) if (base[i - 1] == '/') break;
+        if (i == len - 2 && !memcmp( base + i, "..", 2 )) break;  /* we can't go up if we already have ".." */
+        if (i != len - 1 || base[i] != '.')
+        {
+            path += 2;
+            while (*path == '/') path++;
+        }
+        /* else ignore "." element */
+        while (i > 0 && base[i - 1] == '/') i--;
+        len = i;
+    }
+    if (!len && base[0] != '/') return xstrdup( path[0] ? path : "." );
+    ret = xmalloc( len + strlen( path ) + 2 );
+    memcpy( ret, base, len );
+    ret[len++] = '/';
+    strcpy( ret + len, path );
+    return ret;
 }
 
 
@@ -2775,7 +2799,7 @@ static void output_source_rc( struct makefile *make, struct incl_file *source, c
     if (source->file->flags & FLAG_GENERATED) strarray_add( &make->clean_files, source->name );
     if (linguas.count && (source->file->flags & FLAG_RC_PO)) po_dir = top_obj_dir_path( make, "po" );
     strarray_add( &make->res_files, strmake( "%s.res", obj ));
-    if (source->file->flags & FLAG_RC_PO && !(source->file->flags & FLAG_PARENTDIR))
+    if (source->file->flags & FLAG_RC_PO)
     {
         strarray_add( &make->pot_files, strmake( "%s.pot", obj ));
         output( "%s.pot ", obj_dir_path( make, obj ) );




More information about the wine-cvs mailing list