Re: [patch] strfry.3: Remove incorrect reference to rand(3)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Keith,

On 11/9/18 1:20 AM, Keith Thompson wrote:
> The strfry(3) function does not use rand(). The original version from
> 1995 did, but it was
> changed to use a different PRNG in glibc commit
> 4770745624b7f7f25623f1f10d46a4c4d6aec25c,
> 1996-12-04.
> 
> This C program demonstrates the behavior. By not calling srand(), it
> gets the same values
> for successive calls to rand(), but strfry() returns a different value
> each time the program is run.
> If strfry() called srand(), it would alter the sequence of numbers
> return by rand().
> 
> #define _GNU_SOURCE
> #include <stdio.h>
> #include <string.h>
> #include <stdlib.h>
> int main(void) {
>     printf("%d\n", rand());
>     char alphabet[] = "abcdefghijklmnopqrstuvwxyz";
>     puts(strfry(alphabet));
>     printf("%d\n", rand());
> }

Thanks for the very detailed commit message! Patch applied.

Cheers,

Michael



> Patch follows:
> 
> commit e7be0424538b50d49817200ccafc56cf742813bf (HEAD -> kst-strfry)
> Author: Keith Thompson <Keith.S.Thompson@xxxxxxxxx>
> Date:   2018-11-08 16:09:06 -0800
> 
>     man3/strfry.3: Remove incorrect reference to rand(3)
> 
> diff --git man3/strfry.3 man3/strfry.3
> index a4c02435d..5beefa42c 100644
> --- man3/strfry.3
> +++ man3/strfry.3
> @@ -42,10 +42,7 @@ The
>  .BR strfry ()
>  function randomizes the contents of
>  .I string
> -by
> -using
> -.BR rand (3)
> -to randomly swap characters in the string.
> +by randomly swapping characters in the string.
>  The result is an anagram of
>  .IR string .
>  .SH RETURN VALUE
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux