git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool
commit8277dbe9872205be1588ddfbf01d5439847db1d9
authorRené Scharfe <l.s.r@web.de>
Sat, 16 Dec 2023 10:47:21 +0000 (16 11:47 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 18 Dec 2023 17:08:24 +0000 (18 09:08 -0800)
tree806109035da172b3a01c729d778c9899c990d4a3
parent564d0252ca632e0264ed670534a51d18a689ef5d
git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool

Use the data type bool and its values true and false to document the
binary return value of skip_prefix() and friends more explicitly.

This first use of stdbool.h, introduced with C99, is meant to check
whether there are platforms that claim support for C99, as tested by
7bc341e21b (git-compat-util: add a test balloon for C99 support,
2021-12-01), but still lack that header for some reason.

A fallback based on a wider type, e.g. int, would have to deal with
comparisons somehow to emulate that any non-zero value is true:

   bool b1 = 1;
   bool b2 = 2;
   if (b1 == b2) puts("This is true.");

   int i1 = 1;
   int i2 = 2;
   if (i1 == i2) puts("Not printed.");
   #define BOOLEQ(a, b) (!(a) == !(b))
   if (BOOLEQ(i1, i2)) puts("This is true.");

So we'd be better off using bool everywhere without a fallback, if
possible.  That's why this patch doesn't include any.

Signed-off-by: René Scharfe <l.s.r@web.de>
Acked-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-compat-util.h