]> git.ipfire.org Git - thirdparty/git.git/commitdiff
kwset: use unsigned char to store values with high-bit set
authorBen Walton <bdwalton@gmail.com>
Mon, 2 Mar 2015 19:22:31 +0000 (19:22 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 2 Mar 2015 20:32:24 +0000 (12:32 -0800)
Sun Studio on Solaris issues warnings about improper initialization
values being used when defining tolower_trans_tbl[] in ctype.c.  The
array wants to store values with high-bit set and treat them as
values between 128 to 255.  Unlike the rest of the Git codebase
where we explicitly specify 'unsigned char' for such variables and
arrays, however, kwset code we borrowed from elsewhere uses 'char'
for this and other variables.

Fix the declarations to explicitly use 'unsigned char' where
necessary to bring it in line with the rest of the Git.

Signed-off-by: Ben Walton <bdwalton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
ctype.c
git-compat-util.h
kwset.c
kwset.h

diff --git a/ctype.c b/ctype.c
index 0bfebb4e75866ba0e97713fab5394490290831c0..fc0225cebd1a4b43654772270826e06fd941a128 100644 (file)
--- a/ctype.c
+++ b/ctype.c
@@ -30,7 +30,7 @@ const unsigned char sane_ctype[256] = {
 };
 
 /* For case-insensitive kwset */
-const char tolower_trans_tbl[256] = {
+const unsigned char tolower_trans_tbl[256] = {
        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
index e6a4159a25ea2c4f98840b86994425e898cf134c..e96bec3a96af27acb4ccb238ba8afa7cc9444adc 100644 (file)
@@ -554,7 +554,7 @@ static inline int has_extension(const char *filename, const char *ext)
 }
 
 /* in ctype.c, for kwset users */
-extern const char tolower_trans_tbl[256];
+extern const unsigned char tolower_trans_tbl[256];
 
 /* Sane ctype - no locale, and works with signed chars */
 #undef isascii
diff --git a/kwset.c b/kwset.c
index a0f49b3aca934008465842dd37e52d11d099e23e..e6236a0359cb3661acb8b1e609be236f6fb9d4bf 100644 (file)
--- a/kwset.c
+++ b/kwset.c
@@ -80,13 +80,13 @@ struct kwset
   struct trie *next[NCHAR];    /* Table of children of the root. */
   char *target;                        /* Target string if there's only one. */
   int mind2;                   /* Used in Boyer-Moore search for one string. */
-  char const *trans;           /* Character translation table. */
+  unsigned char const *trans;  /* Character translation table. */
 };
 
 /* Allocate and initialize a keyword set object, returning an opaque
    pointer to it.  Return NULL if memory is not available. */
 kwset_t
-kwsalloc (char const *trans)
+kwsalloc (unsigned char const *trans)
 {
   struct kwset *kwset;
 
@@ -381,7 +381,7 @@ kwsprep (kwset_t kws)
   register struct kwset *kwset;
   register int i;
   register struct trie *curr;
-  register char const *trans;
+  register unsigned char const *trans;
   unsigned char delta[NCHAR];
 
   kwset = (struct kwset *) kws;
@@ -590,7 +590,7 @@ cwexec (kwset_t kws, char const *text, size_t len, struct kwsmatch *kwsmatch)
   register int d;
   register char const *end, *qlim;
   register struct tree const *tree;
-  register char const *trans;
+  register unsigned char const *trans;
 
   accept = NULL;
 
diff --git a/kwset.h b/kwset.h
index a21b2eadfdf9f760c170f10c069a06853105eee5..61a134f256cee951f726c9619861b614fb66f9d6 100644 (file)
--- a/kwset.h
+++ b/kwset.h
@@ -39,7 +39,7 @@ typedef struct kwset_t* kwset_t;
    if enough memory cannot be obtained.  The argument if non-NULL
    specifies a table of character translations to be applied to all
    pattern and search text. */
-extern kwset_t kwsalloc(char const *);
+extern kwset_t kwsalloc(unsigned char const *);
 
 /* Incrementally extend the keyword set to include the given string.
    Return NULL for success, or an error message.  Remember an index