Re: [PATCH 3/5] Add is_root_path()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nguyễn Thái Ngọc Duy schrieb:
This function returns the length of the root part of a path, or zero if
there is no root.

That is, the function primarily doesn't act as a predicate, and in fact you never use it as such.

I just noticed that this function is identical to offset_1st_component() in sha1_file.c.

--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -210,6 +210,17 @@ static inline const char *skip_prefix(const char *str, const char *prefix)
 	return strncmp(str, prefix, len) ? NULL : str + len;
 }
+/* path must be canonical */
+static inline int is_root_path(const char *path)
+{
+	int len = 0;
+	if (has_dos_drive_prefix(path))
+		len += 2;
+	if (is_dir_sep(path[len]))
+		len++;
+	return len;
+}
+
 #if defined(NO_MMAP) || defined(USE_WIN32_MMAP)

This is not a good location for this function because on Windows we get warnings about implicitly defined function isalpha() (which is hidden in the macro has_dos_drive_prefix).

I suggest to move offset_1st_component() to path.c, which would not be inlined anymore.

-- Hannes
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]