chewing through canonicalize
authorFred T. Hamster <fred@gruntose.com>
Sun, 27 Apr 2025 16:43:44 +0000 (12:43 -0400)
committerFred T. Hamster <fred@gruntose.com>
Sun, 27 Apr 2025 16:43:44 +0000 (12:43 -0400)
scripts/files/filename_helper.py

index b121a20fd9f180845c31f40ba4ef2540390d6e25..f865d660e54e866b4edfca1e18a9329dc67df719 100644 (file)
@@ -238,23 +238,22 @@ def canonicalizer(directory_name: str, dirsep: str) -> str:
     # IS_MSYS is calculated by feisty meow scripts startup; it will be
     # non-empty if this is the msys tool kit.
     if len(IS_MSYS) > 0):
-#hmmm: unconverted below here--monsters !!!
       # msys utilities version (http://www.mingw.org)
-      $directory_name =~ s/^(.):[\\\/](.*)$/\/\1\/\2/;
-    } else {
+#      $directory_name =~ s/^(.):[\\\/](.*)$/\/\1\/\2/;
+      directory_name = re.sub('^(.):[\\\/](.*)$', '\/\1\/\2')
+    else:
       # cygwin utilities version (http://www.cygwin.com)
-      $directory_name =~ s/^(.):[\\\/](.*)$/\/cygdrive\/\1\/\2/;
-    }
+#      $directory_name =~ s/^(.):[\\\/](.*)$/\/cygdrive\/\1\/\2/;
+      directory_name = re.sub('^(.):[\\\/](.*)$', '\/cygdrive\/\1\/\2/')
 #print "new dir name is \"$directory_name\"";
-  }
 
   # turn all the non-default separators into the default.
-  for (local($j) = 0; $j < length($directory_name); $j++) {
-    if ( (substr($directory_name, $j, 1) eq "\\") 
-        || (substr($directory_name, $j, 1) eq "/") ) {
-      substr($directory_name, $j, 1) = $dirsep;
-    }
-  }
+  for j in range(0, len(directory_name)):
+#  for (local($j) = 0; $j < length($directory_name); $j++) {
+    if directory_name[j, j+1] == "\\" or directory_name[j, j+1] == "/":
+      directory_name[j] = dirsep
+
+#hmmm: unconverted below here--monsters !!!
   # remove all occurrences of double separators except for the first
   # double set, which could be a UNC filename.
   local($saw_sep) = 0;