FLTK logo

[master] 1b1e8a4 - Issue #141: fl_filename_absolute bugs fixed for MSWindows.

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 1b1e8a4 - Issue #141: fl_filename_absolute bugs fixed for MSWindows. "MatthiasWM" Jun 12, 2022  
 
commit 1b1e8a4d4682dd802c66884db05f2ebdcaf82218
Author:     MatthiasWM <visualc.git@matthiasm.com>
AuthorDate: Sun Jun 12 14:53:06 2022 +0200
Commit:     MatthiasWM <visualc.git@matthiasm.com>
CommitDate: Sun Jun 12 14:53:06 2022 +0200

    Issue #141: fl_filename_absolute bugs fixed for MSWindows.

 src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx
index cc6aede..3aaa440 100644
--- src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx
+++ src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx
@@ -54,7 +54,7 @@ typedef RPC_STATUS (WINAPI *uuid_func)(UUID __RPC_FAR *Uuid);
 #  include <mntent.h>
 #endif
 
-inline int isdirsep(char c) { return c == '/' || c == '\\'; }
+static inline int isdirsep(char c) { return c == '/' || c == '\\'; }
 
 static wchar_t *mbwbuf = NULL;
 static wchar_t *wbuf = NULL;
@@ -644,16 +644,22 @@ int Fl_WinAPI_System_Driver::filename_absolute(char *to, int tolen, const char *
   if (isdirsep(*(a-1))) a--;
   /* remove intermediate . and .. names: */
   while (*start == '.') {
-    if (start[1]=='.' && isdirsep(start[2])) {
+    if (start[1]=='.' && (isdirsep(start[2]) || start[2]==0) ) {
+      // found "..", remove the last directory segment form cwd
       char *b;
       for (b = a-1; b >= temp && !isdirsep(*b); b--) {/*empty*/}
       if (b < temp) break;
       a = b;
-      start += 3;
+      if (start[2] == 0)
+        start += 2;
+      else
+        start += 3;
     } else if (isdirsep(start[1])) {
+      // found "./" in path, just skip it
       start += 2;
     } else if (!start[1]) {
-      start ++; // Skip lone "."
+      // found "." at end of path, just skip it
+      start ++;
       break;
     } else
       break;
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.