X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=git-compat-util.h;h=e587ac4e2365bb790a8c74dd7646b349e1f69c5e;hb=d2c84dad1c88f40906799bc879f70b965efd8ba6;hp=7d2c0ca75922ea1ca8c67ec798ff8ce1249c925f;hpb=96d4b17bd6610275c3ae9d810f1557abaf168a23;p=thirdparty%2Fgit.git diff --git a/git-compat-util.h b/git-compat-util.h index 7d2c0ca759..e587ac4e23 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -370,6 +370,10 @@ static inline int git_offset_1st_component(const char *path) #define offset_1st_component git_offset_1st_component #endif +#ifndef is_valid_path +#define is_valid_path(path) 1 +#endif + #ifndef find_last_dir_sep static inline char *git_find_last_dir_sep(const char *path) { @@ -900,9 +904,11 @@ static inline char *xstrdup_or_null(const char *str) static inline size_t xsize_t(off_t len) { - if (len > (size_t) len) + size_t size = (size_t) len; + + if (len != (off_t) size) die("Cannot handle files this big"); - return (size_t)len; + return size; } __attribute__((format (printf, 3, 4))) @@ -978,6 +984,23 @@ static inline int sane_iscase(int x, int is_lower) return (x & 0x20) == 0; } +/* + * Like skip_prefix, but compare case-insensitively. Note that the comparison + * is done via tolower(), so it is strictly ASCII (no multi-byte characters or + * locale-specific conversions). + */ +static inline int skip_iprefix(const char *str, const char *prefix, + const char **out) +{ + do { + if (!*prefix) { + *out = str; + return 1; + } + } while (tolower(*str++) == tolower(*prefix++)); + return 0; +} + static inline int strtoul_ui(char const *s, int base, unsigned int *result) { unsigned long ul;