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
318 // finish class318 // finish class
319 QUERY->end_class( QUERY );319 QUERY->end_class( QUERY );
320 320
321 // seed the rand321 // seed rand()
322 srand( time( NULL ) );322 // (NOTE: ck_srandom(time(NULL)) is invoked in ulib_math.cpp)
323 srand( (unsigned)time( NULL ) );
323 324
324 Chuck_DL_Func * func = NULL;325 Chuck_DL_Func * func = NULL;
325 326
@@ -574,17 +575,17 @@ error: · 248 unmodified lines
574}575}
575 576
576 577
577#define RAND_INV_RANGE(r) (RAND_MAX / (r))578//#define RAND_INV_RANGE(r) (RAND_MAX / (r))
578 579//
579int irand_exclusive ( int max ) {580//int irand_exclusive ( int max ) {
580 int x = ::rand();581// int x = ::rand();
581 582//
582 while (x >= max * RAND_INV_RANGE (max))583// while (x >= max * RAND_INV_RANGE (max))
583 x = ::rand();584// x = ::rand();
584 585//
585 x /= RAND_INV_RANGE (max);586// x /= RAND_INV_RANGE (max);
586 return x;587// return x;
587}588//}
588 589
589 590
590// abs591// abs
@@ -651,7 +652,7 @@ CK_DLL_SFUN( rand2_impl ) // inclusive. · 60 unmodified lines
651CK_DLL_SFUN( srand_impl )652CK_DLL_SFUN( srand_impl )
652{653{
653 t_CKINT seed = GET_CK_INT(ARGS);654 t_CKINT seed = GET_CK_INT(ARGS);
654 ::srand( seed );655 srand( (unsigned)seed );
655}656}
656 657
657// sgn658// 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