From b7fea87d07b000ae2a6e8879702e13c2ef6e406a Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Fri, 18 Jun 2021 12:56:58 +0300 Subject: [PATCH] os: fix normalize_drive_letter (used by os.real_path) returning a parameter --- vlib/os/os_c.v | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/vlib/os/os_c.v b/vlib/os/os_c.v index c3741db449..09bb8717db 100644 --- a/vlib/os/os_c.v +++ b/vlib/os/os_c.v @@ -799,17 +799,19 @@ pub fn real_path(fpath string) string { } res = unsafe { fullpath.vstring() } } - return normalize_drive_letter(res) + unsafe { normalize_drive_letter(res) } + return res } -[direct_array_access; manualfree] -fn normalize_drive_letter(path string) string { - // normalize_drive_letter is needed, because a path like c:\nv\.bin (note the small `c`) - // in %PATH is NOT recognized by cmd.exe (and probably other programs too)... - // Capital drive letters do work fine. +[direct_array_access; manualfree; unsafe] +fn normalize_drive_letter(path string) { $if !windows { - return path + return } + // normalize_drive_letter is needed, because + // a path like c:\nv\.bin (note the small `c`) in %PATH, + // is NOT recognized by cmd.exe (and probably other programs too)... + // Capital drive letters do work fine. if path.len > 2 && path[0] >= `a` && path[0] <= `z` && path[1] == `:` && path[2] == path_separator[0] { unsafe { @@ -817,7 +819,6 @@ fn normalize_drive_letter(path string) string { (*x) = *x - 32 } } - return path } // fork will fork the current system process and return the pid of the fork.