History

updating sprintf() functions to snprintf(); additional changes for type casting consistency

Ge Wang committed 3 years ago

Commit 725e88b1 parent 452dff937 files · +282 −257Browse files

Showing the changes to src/core/ulib_std.cpp (1 of 37 files). Show all

Unified · Split

src/core/ulib_std.cpp+15−14
@@ -318,8 +318,9 @@ DLL_QUERY libstd_query( Chuck_DL_Query * QUERY ) · 317 unmodified lines
318318 // finish class
319319 QUERY->end_class( QUERY );
320320
321− // seed the rand
322− srand( time( NULL ) );
321+ // seed rand()
322+ // (NOTE: ck_srandom(time(NULL)) is invoked in ulib_math.cpp)
323+ srand( (unsigned)time( NULL ) );
323324
324325 Chuck_DL_Func * func = NULL;
325326
@@ -574,17 +575,17 @@ error: · 248 unmodified lines
574575 }
575576
576577
577−#define RAND_INV_RANGE(r) (RAND_MAX / (r))
578−
579−int irand_exclusive ( int max ) {
580− int x = ::rand();
581−
582− while (x >= max * RAND_INV_RANGE (max))
583− x = ::rand();
584−
585− x /= RAND_INV_RANGE (max);
586− return x;
587−}
578+//#define RAND_INV_RANGE(r) (RAND_MAX / (r))
579+//
580+//int irand_exclusive ( int max ) {
581+// int x = ::rand();
582+//
583+// while (x >= max * RAND_INV_RANGE (max))
584+// x = ::rand();
585+//
586+// x /= RAND_INV_RANGE (max);
587+// return x;
588+//}
588589
589590
590591 // abs
@@ -651,7 +652,7 @@ CK_DLL_SFUN( rand2_impl ) // inclusive. · 60 unmodified lines
651652 CK_DLL_SFUN( srand_impl )
652653 {
653654 t_CKINT seed = GET_CK_INT(ARGS);
654− ::srand( seed );
655+ srand( (unsigned)seed );
655656 }
656657
657658 // sgn

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t