msvc: Do not use `isspace` Locale-aware bullshit bitting my ass again yo
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
diff --git a/src/attr_file.c b/src/attr_file.c
index ab320a6..4409d74 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 0785b53..2ecb088 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 4ccec2b..cbc48bc 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 56efd48..aa0220f 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 ea96737..886de58 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 20a627e..9fd5f28 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 a768001..6321e21 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__ */