Re: [PATCH v2 1/4] Refactor skipping DOS drive prefixes
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Jan 8, 2016, 21:51 UTC
- Message-ID
- <CAPig+cRRaMbEGibYnQBTfGFQT6fybNU8e6ZAkX11V-TLAo9AfA@mail.gmail.com>
- In-Reply-To
- <c70ed05f275a44fbfae831b4cb67e59a0ce05724.1452270051.git.johannes.schindelin@gmx.de>
On Fri, Jan 8, 2016 at 11:21 AM, Johannes Schindelin <johannes.schindelin@gmx.de> wrote:
Show 10 quoted lines
> Junio Hamano pointed out that there is an implicit assumption in pretty > much all the code calling has_dos_drive_prefix(): it assumes that the > DOS drive prefix is always two bytes long. > > While this assumption is pretty safe, we can still make the code more > readable and less error-prone by introducing a function that skips the > DOS drive prefix safely. > > While at it, we change the has_dos_drive_prefix() return value: it now > returns the number of bytes to be skipped if there is a DOS drive prefix.
With this change, code such as:
for (i = has_dos_drive_prefix(src); i > 0; i--)
...in path.c reads a bit oddly. Renaming the function might help. For instance:
for (i = dos_drive_prefix_len(src); i > 0; i--)
...> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>