From: Junio C Hamano Date: Tue, 9 Jul 2019 22:25:41 +0000 (-0700) Subject: Merge branch 'js/gcc-8-and-9' X-Git-Tag: v2.23.0-rc0~72 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/7785f9ba030674671eb78ccfd2358f6903b632fb?ds=inline;hp=-c Merge branch 'js/gcc-8-and-9' Code clean-up for new compilers. * js/gcc-8-and-9: config: avoid calling `labs()` on too-large data type winansi: simplify loading the GetCurrentConsoleFontEx() function kwset: allow building with GCC 8 poll (mingw): allow compiling with GCC 8 and DEVELOPER=1 --- 7785f9ba030674671eb78ccfd2358f6903b632fb diff --combined config.c index ad4166e243,01c6e9df23..972d3c1033 --- a/config.c +++ b/config.c @@@ -19,7 -19,6 +19,7 @@@ #include "utf8.h" #include "dir.h" #include "color.h" +#include "refs.h" struct config_source { struct config_source *prev; @@@ -171,12 -170,6 +171,12 @@@ static int handle_path_include(const ch return ret; } +static void add_trailing_starstar_for_dir(struct strbuf *pat) +{ + if (pat->len && is_dir_sep(pat->buf[pat->len - 1])) + strbuf_addstr(pat, "**"); +} + static int prepare_include_condition_pattern(struct strbuf *pat) { struct strbuf path = STRBUF_INIT; @@@ -206,7 -199,8 +206,7 @@@ } else if (!is_absolute_path(pat->buf)) strbuf_insert(pat, 0, "**/", 3); - if (pat->len && is_dir_sep(pat->buf[pat->len - 1])) - strbuf_addstr(pat, "**"); + add_trailing_starstar_for_dir(pat); strbuf_release(&path); return prefix; @@@ -270,25 -264,6 +270,25 @@@ done return ret; } +static int include_by_branch(const char *cond, size_t cond_len) +{ + int flags; + int ret; + struct strbuf pattern = STRBUF_INIT; + const char *refname = resolve_ref_unsafe("HEAD", 0, NULL, &flags); + const char *shortname; + + if (!refname || !(flags & REF_ISSYMREF) || + !skip_prefix(refname, "refs/heads/", &shortname)) + return 0; + + strbuf_add(&pattern, cond, cond_len); + add_trailing_starstar_for_dir(&pattern); + ret = !wildmatch(pattern.buf, shortname, WM_PATHNAME); + strbuf_release(&pattern); + return ret; +} + static int include_condition_is_true(const struct config_options *opts, const char *cond, size_t cond_len) { @@@ -297,8 -272,6 +297,8 @@@ return include_by_gitdir(opts, cond, cond_len, 0); else if (skip_prefix_mem(cond, cond_len, "gitdir/i:", &cond, &cond_len)) return include_by_gitdir(opts, cond, cond_len, 1); + else if (skip_prefix_mem(cond, cond_len, "onbranch:", &cond, &cond_len)) + return include_by_branch(cond, cond_len); /* unknown conditionals are always false */ return 0; @@@ -896,9 -869,9 +896,9 @@@ static int git_parse_signed(const char errno = EINVAL; return 0; } - uval = labs(val); + uval = val < 0 ? -val : val; uval *= factor; - if (uval > max || labs(val) > uval) { + if (uval > max || (val < 0 ? -val : val) > uval) { errno = ERANGE; return 0; } diff --combined kwset.c index 090ffcafa2,efc2ff41bc..fc439e0667 --- a/kwset.c +++ b/kwset.c @@@ -38,7 -38,13 +38,13 @@@ #include "compat/obstack.h" #define NCHAR (UCHAR_MAX + 1) - #define obstack_chunk_alloc xmalloc + /* adapter for `xmalloc()`, which takes `size_t`, not `long` */ + static void *obstack_chunk_alloc(long size) + { + if (size < 0) + BUG("Cannot allocate a negative amount: %ld", size); + return xmalloc(size); + } #define obstack_chunk_free free #define U(c) ((unsigned char) (c)) @@@ -475,7 -481,7 +481,7 @@@ kwsprep (kwset_t kws for (i = 0; i < NCHAR; ++i) kwset->next[i] = next[U(trans[i])]; else - memcpy(kwset->next, next, NCHAR * sizeof(struct trie *)); + COPY_ARRAY(kwset->next, next, NCHAR); } /* Fix things up for any translation table. */