groff-commit
[Top][All Lists]
Advanced

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

[groff] 14/51: [pic]: Emit deprecation warning for 'rand(x)'.


From: G. Branden Robinson
Subject: [groff] 14/51: [pic]: Emit deprecation warning for 'rand(x)'.
Date: Sun, 11 Sep 2022 08:15:50 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 9e482c952edb70d3c0ff3d5b3fecc65d640f2875
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Sep 3 23:08:32 2022 -0500

    [pic]: Emit deprecation warning for 'rand(x)'.
    
    * src/preproc/pic/pic.ypp (not_lower_than): Emit deprecation warning for
      use of 'rand()' with a (non-empty) argument.  The man page has
      declared it thus for over 30 years, at least since groff 1.02 (June
      1991).
---
 ChangeLog               | 7 +++++++
 src/preproc/pic/pic.ypp | 7 ++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 97d20a978..8bf964e3b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2022-09-03  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/preproc/pic/pic.ypp (not_lower_than): Emit deprecation
+       warning for use of 'rand()' with a (non-empty) argument.  The
+       man page has declared it thus for over 30 years, at least since
+       groff 1.02 (June 1991).
+
 2022-09-03  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/preproc/pic/pic.ypp (object_spec): Emit deprecation
diff --git a/src/preproc/pic/pic.ypp b/src/preproc/pic/pic.ypp
index 0fd4cfceb..99cdd6082 100644
--- a/src/preproc/pic/pic.ypp
+++ b/src/preproc/pic/pic.ypp
@@ -1650,7 +1650,12 @@ expr_not_lower_than:
        | INT '(' any_expr ')'
                { $$ = $3 < 0 ? -floor(-$3) : floor($3); }
        | RAND '(' any_expr ')'
-               { $$ = 1.0 + floor(((rand()&0x7fff)/double(0x7fff))*$3); }
+               {
+                 lex_error("use of 'rand' with an argument is"
+                           " deprecated; shift and scale 'rand()' with"
+                           " arithmetic instead");
+                 $$ = 1.0 + floor(((rand()&0x7fff)/double(0x7fff))*$3);
+               }
        | RAND '(' ')'
                {
                  /* return a random number in the range [0,1) */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]