diff options
author | Vicent Martà <tanoku@gmail.com> | 2012-05-09 04:37:02 +0200 |
---|---|---|
committer | Vicent Martà <tanoku@gmail.com> | 2012-05-09 04:37:02 +0200 |
commit | 0f49200c9a72f7d8144eb663dee2c684d52ef42a (patch) | |
tree | f0587f4a4ee07b4e96818cf28cb11c6ffe30727a /src | |
parent | e65752bb3251f9a308fd4f9cb3b294c4f7d90783 (diff) | |
download | libgit2-0f49200c9a72f7d8144eb663dee2c684d52ef42a.tar.gz |
msvc: Do not use `isspace`
Locale-aware bullshit bitting my ass again yo
Diffstat (limited to 'src')
-rw-r--r-- | src/attr_file.c | 12 | ||||
-rw-r--r-- | src/buffer.c | 2 | ||||
-rw-r--r-- | src/config_file.c | 16 | ||||
-rw-r--r-- | src/message.c | 2 | ||||
-rw-r--r-- | src/repository.c | 2 | ||||
-rw-r--r-- | src/util.c | 2 | ||||
-rw-r--r-- | src/util.h | 15 |
7 files changed, 33 insertions, 18 deletions
diff --git a/src/attr_file.c b/src/attr_file.c index ab320a6c4..4409d744a 100644 --- a/src/attr_file.c +++ b/src/attr_file.c @@ -344,7 +344,7 @@ int git_attr_fnmatch__parse( pattern = *base; - while (isspace(*pattern)) pattern++; + while (git__isspace(*pattern)) pattern++; if (!*pattern || *pattern == '#') { *base = git__next_line(pattern); return GIT_ENOTFOUND; @@ -368,7 +368,7 @@ int git_attr_fnmatch__parse( slash_count = 0; for (scan = pattern; *scan != '\0'; ++scan) { /* scan until (non-escaped) white space */ - if (isspace(*scan) && *(scan - 1) != '\\') + if (git__isspace(*scan) && *(scan - 1) != '\\') break; if (*scan == '/') { @@ -485,7 +485,7 @@ int git_attr_assignment__parse( const char *name_start, *value_start; /* skip leading blanks */ - while (isspace(*scan) && *scan != '\n') scan++; + while (git__isspace(*scan) && *scan != '\n') scan++; /* allocate assign if needed */ if (!assign) { @@ -509,7 +509,7 @@ int git_attr_assignment__parse( /* find the name */ name_start = scan; - while (*scan && !isspace(*scan) && *scan != '=') { + while (*scan && !git__isspace(*scan) && *scan != '=') { assign->name_hash = ((assign->name_hash << 5) + assign->name_hash) + *scan; scan++; @@ -518,7 +518,7 @@ int git_attr_assignment__parse( /* must have found lone prefix (" - ") or leading = ("=foo") * or end of buffer -- advance until whitespace and continue */ - while (*scan && !isspace(*scan)) scan++; + while (*scan && !git__isspace(*scan)) scan++; continue; } @@ -528,7 +528,7 @@ int git_attr_assignment__parse( /* if there is an equals sign, find the value */ if (*scan == '=') { - for (value_start = ++scan; *scan && !isspace(*scan); ++scan); + for (value_start = ++scan; *scan && !git__isspace(*scan); ++scan); /* if we found a value, allocate permanent storage for it */ if (scan > value_start) { diff --git a/src/buffer.c b/src/buffer.c index 0785b5399..2ecb088f8 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -400,7 +400,7 @@ int git_buf_join( void git_buf_rtrim(git_buf *buf) { while (buf->size > 0) { - if (!isspace(buf->ptr[buf->size - 1])) + if (!git__isspace(buf->ptr[buf->size - 1])) break; buf->size--; diff --git a/src/config_file.c b/src/config_file.c index 4ccec2bc1..cbc48bcd9 100644 --- a/src/config_file.c +++ b/src/config_file.c @@ -525,7 +525,7 @@ static int cfg_getchar(diskfile_backend *cfg_file, int flags) assert(cfg_file->reader.read_ptr); do c = cfg_getchar_raw(cfg_file); - while (skip_whitespace && isspace(c) && + while (skip_whitespace && git__isspace(c) && !cfg_file->reader.eof); if (skip_comments && (c == '#' || c == ';')) { @@ -573,7 +573,7 @@ static char *cfg_readline(diskfile_backend *cfg, bool skip_whitespace) if (skip_whitespace) { /* Skip empty empty lines */ - while (isspace(*line_src)) + while (git__isspace(*line_src)) ++line_src; } @@ -592,7 +592,7 @@ static char *cfg_readline(diskfile_backend *cfg, bool skip_whitespace) memcpy(line, line_src, line_len); do line[line_len] = '\0'; - while (line_len-- > 0 && isspace(line[line_len])); + while (line_len-- > 0 && git__isspace(line[line_len])); if (*line_end == '\n') line_end++; @@ -737,7 +737,7 @@ static int parse_section_header(diskfile_backend *cfg, char **section_out) c = line[pos++]; do { - if (isspace(c)){ + if (git__isspace(c)){ name[name_length] = '\0'; result = parse_section_header_ext(cfg, line, name, section_out); git__free(line); @@ -844,7 +844,7 @@ static int strip_comments(char *line, int in_quotes) } /* skip any space at the end */ - if (isspace(ptr[-1])) { + if (git__isspace(ptr[-1])) { ptr--; } ptr[0] = '\0'; @@ -1272,9 +1272,9 @@ static int parse_variable(diskfile_backend *cfg, char **var_name, char **var_val else value_start = var_end + 1; - if (isspace(var_end[-1])) { + if (git__isspace(var_end[-1])) { do var_end--; - while (isspace(var_end[0])); + while (git__isspace(var_end[0])); } *var_name = git__strndup(line, var_end - line + 1); @@ -1287,7 +1287,7 @@ static int parse_variable(diskfile_backend *cfg, char **var_name, char **var_val * Now, let's try to parse the value */ if (value_start != NULL) { - while (isspace(value_start[0])) + while (git__isspace(value_start[0])) value_start++; if (is_multiline_var(value_start)) { diff --git a/src/message.c b/src/message.c index 56efd487b..aa0220fd0 100644 --- a/src/message.c +++ b/src/message.c @@ -12,7 +12,7 @@ static size_t line_length_without_trailing_spaces(const char *line, size_t len) { while (len) { unsigned char c = line[len - 1]; - if (!isspace(c)) + if (!git__isspace(c)) break; len--; } diff --git a/src/repository.c b/src/repository.c index ea9673731..886de5806 100644 --- a/src/repository.c +++ b/src/repository.c @@ -246,7 +246,7 @@ static int read_gitfile(git_buf *path_out, const char *file_path) } else if ((error = git_path_dirname_r(path_out, file_path)) >= 0) { const char *gitlink = ((const char *)file.ptr) + prefix_len; - while (*gitlink && isspace(*gitlink)) gitlink++; + while (*gitlink && git__isspace(*gitlink)) gitlink++; error = git_path_prettify_dir(path_out, gitlink, path_out->ptr); } diff --git a/src/util.c b/src/util.c index 20a627ea8..9fd5f286c 100644 --- a/src/util.c +++ b/src/util.c @@ -75,7 +75,7 @@ int git__strtol64(int64_t *result, const char *nptr, const char **endptr, int ba /* * White space */ - while (isspace(*p)) + while (git__isspace(*p)) p++; /* diff --git a/src/util.h b/src/util.h index a76800141..6321e21f5 100644 --- a/src/util.h +++ b/src/util.h @@ -194,4 +194,19 @@ GIT_INLINE(size_t) git__size_t_powerof2(size_t v) return git__size_t_bitmask(v) + 1; } +GIT_INLINE(bool) git__isupper(int c) +{ + return (c >= 'A' && c <= 'Z'); +} + +GIT_INLINE(bool) git__isalpha(int c) +{ + return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); +} + +GIT_INLINE(bool) git__isspace(int c) +{ + return (c == ' ' || c == '\t' || c == '\n' || c == '\12'); +} + #endif /* INCLUDE_util_h__ */ |