Fixed buffer resizing, made string utilities more modular, and added several new utilities, some which do not require a null termination, potentially avoiding the need to copy a string. Also some substring utilities using the Rabin-Karp algorithm were added.
This commit is contained in:
parent
8b8ffe36a6
commit
595c024968
|
|
@ -98,8 +98,6 @@ inline char *copy_substring(const char *str, const char *end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Like scannum but *p_str is advanced past the number */
|
|
||||||
|
|
||||||
/* Try to identify an unsigned integer that begins a string. Stop when a
|
/* Try to identify an unsigned integer that begins a string. Stop when a
|
||||||
* non- numeric character is reached. There is no way to distinguish
|
* non- numeric character is reached. There is no way to distinguish
|
||||||
* between a value of 0 and a string that does not contain a numeric
|
* between a value of 0 and a string that does not contain a numeric
|
||||||
|
|
@ -114,7 +112,7 @@ inline int scannum(const char *str)
|
||||||
/* Determine whether sub is a substring of str. */
|
/* Determine whether sub is a substring of str. */
|
||||||
inline int substring(const char *sub, const char *str)
|
inline int substring(const char *sub, const char *str)
|
||||||
{
|
{
|
||||||
return strstr(sub, str) != (char *) NULL;
|
return strstr(str, sub) != (char *) NULL;
|
||||||
} /* end of function substring */
|
} /* end of function substring */
|
||||||
|
|
||||||
#ifdef CIDER
|
#ifdef CIDER
|
||||||
|
|
|
||||||
|
|
@ -236,7 +236,7 @@ int get_int_n(const char *str, size_t n, int *p_value)
|
||||||
|
|
||||||
/* Test for overflow.
|
/* Test for overflow.
|
||||||
* If negative, can be 1 greater (-2**n vs 2**n -1) */
|
* If negative, can be 1 greater (-2**n vs 2**n -1) */
|
||||||
if (value - f_neg > INT_MAX) {
|
if (value - f_neg > (unsigned int) INT_MAX) {
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue