Skip to content

Commit 189c860

Browse files
bdwaltongitster
authored andcommitted
kwset: use unsigned char to store values with high-bit set
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 282616c commit 189c860

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

Diff for: ctype.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const unsigned char sane_ctype[256] = {
3030
};
3131

3232
/* For case-insensitive kwset */
33-
const char tolower_trans_tbl[256] = {
33+
const unsigned char tolower_trans_tbl[256] = {
3434
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
3535
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
3636
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,

Diff for: git-compat-util.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ static inline int has_extension(const char *filename, const char *ext)
554554
}
555555

556556
/* in ctype.c, for kwset users */
557-
extern const char tolower_trans_tbl[256];
557+
extern const unsigned char tolower_trans_tbl[256];
558558

559559
/* Sane ctype - no locale, and works with signed chars */
560560
#undef isascii

Diff for: kwset.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ struct kwset
8080
struct trie *next[NCHAR]; /* Table of children of the root. */
8181
char *target; /* Target string if there's only one. */
8282
int mind2; /* Used in Boyer-Moore search for one string. */
83-
char const *trans; /* Character translation table. */
83+
unsigned char const *trans; /* Character translation table. */
8484
};
8585

8686
/* Allocate and initialize a keyword set object, returning an opaque
8787
pointer to it. Return NULL if memory is not available. */
8888
kwset_t
89-
kwsalloc (char const *trans)
89+
kwsalloc (unsigned char const *trans)
9090
{
9191
struct kwset *kwset;
9292

@@ -381,7 +381,7 @@ kwsprep (kwset_t kws)
381381
register struct kwset *kwset;
382382
register int i;
383383
register struct trie *curr;
384-
register char const *trans;
384+
register unsigned char const *trans;
385385
unsigned char delta[NCHAR];
386386

387387
kwset = (struct kwset *) kws;
@@ -590,7 +590,7 @@ cwexec (kwset_t kws, char const *text, size_t len, struct kwsmatch *kwsmatch)
590590
register int d;
591591
register char const *end, *qlim;
592592
register struct tree const *tree;
593-
register char const *trans;
593+
register unsigned char const *trans;
594594

595595
accept = NULL;
596596

Diff for: kwset.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ typedef struct kwset_t* kwset_t;
3939
if enough memory cannot be obtained. The argument if non-NULL
4040
specifies a table of character translations to be applied to all
4141
pattern and search text. */
42-
extern kwset_t kwsalloc(char const *);
42+
extern kwset_t kwsalloc(unsigned char const *);
4343

4444
/* Incrementally extend the keyword set to include the given string.
4545
Return NULL for success, or an error message. Remember an index

0 commit comments

Comments
 (0)