Commit 0f49200c by Vicent Martí

msvc: Do not use `isspace`

Locale-aware bullshit bitting my ass again yo
parent e65752bb
......@@ -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) {
......
......@@ -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--;
......
......@@ -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)) {
......
......@@ -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--;
}
......
......@@ -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);
}
......
......@@ -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++;
/*
......
......@@ -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__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment