summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-07-28 11:01:51 +0100
committerNicholas Clark <nick@ccl4.org>2010-07-28 11:01:51 +0100
commitda1010ecc50c91387eed9bcc349e6960909a3484 (patch)
tree64250a5517609b41345cd9ca147facb1be24dfd2 /pp.c
parent1c761d95ce3e122676f2110e57e721b7689cd4c2 (diff)
downloadperl-da1010ecc50c91387eed9bcc349e6960909a3484.tar.gz
Make srand() return "0 but true" for 0, for backwards compatible behaviour.
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/pp.c b/pp.c
index ec585ab933..2dfca4cbc2 100644
--- a/pp.c
+++ b/pp.c
@@ -2954,7 +2954,14 @@ PP(pp_srand)
const UV anum = (MAXARG < 1) ? seed() : POPu;
(void)seedDrand01((Rand_seed_t)anum);
PL_srand_called = TRUE;
- XPUSHu(anum);
+ if (anum)
+ XPUSHu(anum);
+ else {
+ /* Historically srand always returned true. We can avoid breaking
+ that like this: */
+ sv_setpvs(TARG, "0 but true");
+ XPUSHTARG;
+ }
RETURN;
}