#endif
/* Parse delimited vector string. If string starts with { then string
- is delimited by balenced parenthesis. Other string is delimited by
+ is delimited by balanced parenthesis. Other string is delimited by
white space. {} were chosen since they are special to the shell. */
static uword
unformat_string (unformat_input_t * input,
if (!token_chars)
token_chars = (u8 *) "a-zA-Z0-9_";
- memset (map, 0, sizeof (map));
+ clib_memset (map, 0, sizeof (map));
for (s = token_chars; *s;)
{
- /* Parse range. */
- if (s[0] < s[2] && s[1] == '-')
+ /*
+ * Parse range.
+ * The test order is important: s[1] is valid because s[0] != '\0' but
+ * s[2] might not if s[1] == '\0'
+ * Also, if s[1] == '-' but s[2] == '\0' the test s[0] < s[2] will
+ * (correctly) fail
+ */
+ if (s[1] == '-' && s[0] < s[2])
{
for (i = s[0]; i <= s[2]; i++)
map[i] = 1;
uword signs[2], sign_index = 0;
uword n_input = 0;
- memset (values, 0, sizeof (values));
- memset (n_digits, 0, sizeof (n_digits));
- memset (signs, 0, sizeof (signs));
+ clib_memset (values, 0, sizeof (values));
+ clib_memset (n_digits, 0, sizeof (n_digits));
+ clib_memset (signs, 0, sizeof (signs));
while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
{