Alejandro Colomar wrote:
> I've added the following text in strcspn(3):
>
> It is equivalent to
>
> (strpbrk(s, reject) ?: strnul(s)) ‐ s
It's a useful addition, because some (many?) programmers grasp formulas more
easily that they grasp words.
> $ MANWIDTH=64 diffman-git 6c600ed9a9bc HEAD | grep -v ^-
> +++ HEAD:man/man3/stpcpy.3
> @@ -24,18 +24,10 @@ DESCRIPTION
> stpcpy() is similar to strcpy(3), but returns a pointer to
> the terminating null byte in dst.
>
> + It is equivalent to both of the following expressions:
>
> + memset(mempcpy(dst, src, strlen(src)), '\0', 1);
> + strcpy(dst, src) + strlen(dst)
The latter formula depends on the (undefined) order of evaluation.
Better write it as
strcpy(dst, src) + strlen(src)
> +++ HEAD:man/man3/stpncpy.3
> @@ -36,23 +36,16 @@ DESCRIPTION
> ter sequence is truncated. For the difference between the
> two functions, see RETURN VALUE.
>
> + strncpy()
> + It is equivalent to
>
> + stpncpy(dst, src, dsize), dst
>
> + stpncpy()
> + It is equivalent to
>
> + memset(mempcpy(dst, src, strnlen(src, dsize)), '\0',
> + dsize - strnlen(src, dsize))
>
> RETURN VALUE
> strncpy()
This is correct. But it's redundant with the already existing section
"An implementation of these functions might be: ..."
Bruno