Re: [PATCH v3 2/3] relative_path should honor DOS and UNC paths
- From
Jiang Xin <worldhello.net@gmail.com>
- Date
- Sep 18, 2013, 09:02 UTC
- Message-ID
- <CANYiYbF1XwKbD13AMZhE1c4hGMqVzpH9hZ-J8Gk-8AVFUCnn0g@mail.gmail.com>
- In-Reply-To
- <xmqqli2v1l7f.fsf@gitster.dls.corp.google.com>
2013/9/18 Junio C Hamano <gitster@pobox.com>:
Show 14 quoted lines
> Jiang Xin <worldhello.net@gmail.com> writes:
>
>> diff --git a/compat/mingw.h b/compat/mingw.h
>> index bd0a88b..06e9f49 100644
>> --- a/compat/mingw.h
>> +++ b/compat/mingw.h
>> @@ -311,6 +311,15 @@ int winansi_fprintf(FILE *stream, const char *format, ...) __attribute__((format
>>
>> #define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':')
>> #define is_dir_sep(c) ((c) == '/' || (c) == '\\')
>> +static inline int is_unc_path(const char *path)
>> +{
>> + if (!is_dir_sep(*path) || !is_dir_sep(*(path+1)) || is_dir_sep(*(path+2)))
>> + return 0;A UNC path must start with two slashes, but not three or more slashes.
> > If path[1] == '\0', it would be !is_dir_sep() and we end up > inspecting past the end of the string?
The funciton "is_unc_path" will return false (0), if path is "", "/", "//", "///three/slashes/", or "/usr/local". So the problem is ?
-- Jiang Xin