Hello Bartosz,

2015-08-25 13:10 GMT+02:00 Bartosz Golaszewski <[email protected]>:
> +/*
> + * Return NULL if string is not suffixed with key. Return pointer to the
> + * beginning of prefix key in string. If key is an empty string return 
> pointer
> + * to the end of string.
> + */
> +char* FAST_FUNC is_suffixed_with(const char *string, const char *key)
> +{
> +       size_t str_len = strlen(string), key_len = strlen(key);
> +
> +       if (str_len >= key_len) {
> +               if (strcmp(string + str_len - key_len, key) == 0) {
> +                       return (char*)key;
> +               }
> +       }
> +
> +       return NULL;
> +}

Sorry to bug you again with this function, and I know it is too late,
but it doesn't do what the comment before the function says it does.

It says it returns a pointer to the beginning of prefix key *in
string*, but what returns is a pointer to *key*. It's a subtle change,
but as it is now the return value may not be as useful... (it's like
returning 1/0 but with key/NULL.)

Cheers,

Xabier Oneca_,,_
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to