Hi gnulib maintainers,

Does anyone can help me with my first patch-proposal on this repo ?

I did not manage to use "vc-dwim" properly. However I did read much of the README* and linked html files.

The patch-proposal is attached to this mail,

Thank you by advance.

Regard,
Patrick GARCIA


PS : I will, then, propose a shell unit-test to the coreutils team.
From c2b8f00679a50c1c4f48256eac7ec3ee4ba01816 Mon Sep 17 00:00:00 2001
From: Patrick GARCIA <[email protected]>
Date: Fri, 31 Oct 2025 18:20:34 +0100
Subject: [PATCH] Fix canonicalize_filename_mode_stk() for
 logical-current-directory-resolution - on logical resulution (NOLINKS flag is
 set), "."-directory must be resolFix canonicalize_filename_mode_stk() for
 logical-current-directory-resolution

* lib/canonicalize.c: fix canonicalize_filename_mode_stk() for "."-directory
on logical resulution (NOLINKS flag is set) and current-directory is a
sybolic-link. in this case, expected value is logical-current-directory.

no unit test can compile in C because chdir() refuse tu switch to a
sybolic-link-directory. a unit test is provided in coreutils project, for
realpath executable as this unit test is a shell script.
ve as logical-current-directory
---
 lib/canonicalize.c | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/lib/canonicalize.c b/lib/canonicalize.c
index 10d85ef..c437b1d 100644
--- a/lib/canonicalize.c
+++ b/lib/canonicalize.c
@@ -216,22 +216,30 @@ canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode,
 
   if (!IS_ABSOLUTE_FILE_NAME (name))
     {
-      while (!getcwd (bufs->rname.data, bufs->rname.length))
-        {
-          switch (errno)
+        if (logical) {
+            /* use "naiv" PWD env var */
+            char *cwd = get_current_dir_name();
+            strncpy (bufs->rname.data, cwd, bufs->rname.length);
+            free(cwd);
+        } else {
+            /* resolve phisical working dir */
+          while (!getcwd (bufs->rname.data, bufs->rname.length))
             {
-            case ERANGE:
-              if (scratch_buffer_grow (&bufs->rname))
-                break;
-              FALLTHROUGH;
-            case ENOMEM:
-              xalloc_die ();
-
-            default:
-              dest = rname;
-              goto error;
+              switch (errno)
+                {
+                case ERANGE:
+                  if (scratch_buffer_grow (&bufs->rname))
+                    break;
+                  FALLTHROUGH;
+                case ENOMEM:
+                  xalloc_die ();
+
+                default:
+                  dest = rname;
+                  goto error;
+                }
+              rname = bufs->rname.data;
             }
-          rname = bufs->rname.data;
         }
       dest = rawmemchr (rname, '\0');
       start = name;
-- 
2.30.2

Reply via email to