https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a91a709a8d70dc417a54ee...
commit a91a709a8d70dc417a54eea5e5b271e04d8fa828 Author: chirsz chirsz@foxmail.com AuthorDate: Mon Oct 12 03:57:08 2020 +0800 Commit: GitHub noreply@github.com CommitDate: Sun Oct 11 21:57:08 2020 +0200
[CMD] Fix a typo in filename completion (#3293)
Fix filename completion that could cause a incorrect result when the path contains "dots". (See also HBelusca@d12169b.) See CORE-8623 and CORE-1901 (bug introduced in r25896 / 54cf74f).
For example:
- The current directory is `C:\Documents and Settings\Administrator`, and you input `".` and press TAB. The completion result would be `".Administrator"`, which even does not exist.
- You input "some(file).ext", and you remove the final quote (or the quote and "ext") and you attempt to complete the file name.
- Import two additional fixes from HBelusca@a826730: Fix the search ordering in the comparisons between szSearch1, szSearch2 and szSearch3.
Co-authored-by: Hermès BÉLUSCA - MAÏTO hermes.belusca-maito@reactos.org --- base/shell/cmd/filecomp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/base/shell/cmd/filecomp.c b/base/shell/cmd/filecomp.c index 9dfa2943fdc..4e486692a66 100644 --- a/base/shell/cmd/filecomp.c +++ b/base/shell/cmd/filecomp.c @@ -394,10 +394,10 @@ VOID FindPrefixAndSuffix(LPTSTR strIN, LPTSTR szPrefix, LPTSTR szSuffix) /* Find the one closest to end */ szSearch1 = _tcsrchr(str, _T('"')); szSearch2 = _tcsrchr(str, _T('\')); - szSearch3 = _tcsrchr(str, _T('.')); - if (szSearch2 != NULL && _tcslen(szSearch1) > _tcslen(szSearch2)) + szSearch3 = _tcsrchr(str, _T('/')); + if ((szSearch2 != NULL) && (szSearch1 < szSearch2)) szSearch = szSearch2; - else if (szSearch3 != NULL && _tcslen(szSearch1) > _tcslen(szSearch3)) + else if ((szSearch3 != NULL) && (szSearch1 < szSearch3)) szSearch = szSearch3; else szSearch = szSearch1; @@ -440,9 +440,9 @@ VOID FindPrefixAndSuffix(LPTSTR strIN, LPTSTR szPrefix, LPTSTR szSuffix) szSearch1 = _tcsrchr(str, _T(' ')); szSearch2 = _tcsrchr(str, _T('\')); szSearch3 = _tcsrchr(str, _T('/')); - if (szSearch2 != NULL && _tcslen(szSearch1) > _tcslen(szSearch2)) + if ((szSearch2 != NULL) && (szSearch1 < szSearch2)) szSearch = szSearch2; - else if (szSearch3 != NULL && _tcslen(szSearch1) > _tcslen(szSearch3)) + else if ((szSearch3 != NULL) && (szSearch1 < szSearch3)) szSearch = szSearch3; else szSearch = szSearch1;