pike.git/
src/
builtin_functions.c
Branch:
Tag:
Non-build tags
All tags
No tags
2015-10-14
2015-10-14 17:54:42 by Martin Nilsson <nilsson@opera.com>
8fc72e2c5f697566fed7e763b873d017d2b4605c (
22
lines) (+
15
/-
7
)
[
Show
|
Annotate
]
Branch:
8.0
Fixed warning.
809:
PMOD_EXPORT void f_random_string(INT32 args) { struct pike_string *ret;
-
INT_TYPE len, e;
+
INT_TYPE len, e
= 0
;
+
unsigned INT32 *str;
get_all_args("random_string",args,"%+",&len); ret = begin_shared_string(len); /* Note: Assumes pike_string->str is aligned on a 4 byte boundary * (it is, currently) */
-
len
-
=
sizeof
(INT32)-
1
;
-
for
(
e=0;e<len;
e+=sizeof(INT32))
-
((unsigned
INT32
*)(ret->str+e))
[0] = DO_NOT_WARN(my_rand());
-
len
+=
sizeof(INT32)-1
;
-
for(;e<len;e++)
+
str
= (
unsigned
INT32
*
)
ret
-
>str
;
+
+
while
(
(
e+=sizeof(INT32))
<=
len
)
+
{
+
str
[0] = DO_NOT_WARN(my_rand());
+
str++
;
+
}
+
+
for(
e-=sizeof(INT32)
;e<len;e++)
+
{
ret->str[e] = DO_NOT_WARN((char)my_rand());
-
+
}
pop_n_elems(args); push_string(end_shared_string(ret));