Skip to content

Commit

Permalink
Merge branch 'bw/kwset-use-unsigned'
Browse files Browse the repository at this point in the history
The borrowed code in kwset API did not follow our usual convention
to use "unsigned char" to store values that range from 0-255.

* bw/kwset-use-unsigned:
  kwset: use unsigned char to store values with high-bit set
  • Loading branch information
gitster committed Mar 6, 2015
2 parents 36ab768 + 189c860 commit 52d5bf7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ctype.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion git-compat-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ static inline size_t xsize_t(off_t len)
}

/* 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
Expand Down
8 changes: 4 additions & 4 deletions kwset.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion kwset.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 52d5bf7

Please sign in to comment.