From b8aca433e32346c9293acc34a9e2242809ac5692 Mon Sep 17 00:00:00 2001 From: Wiimm Date: Fri, 23 Feb 2024 16:02:06 +0100 Subject: SZS v2.41b --- project/dclib/dclib-numeric.c | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'project/dclib/dclib-numeric.c') diff --git a/project/dclib/dclib-numeric.c b/project/dclib/dclib-numeric.c index 7c23129..cf3fe15 100644 --- a/project/dclib/dclib-numeric.c +++ b/project/dclib/dclib-numeric.c @@ -902,6 +902,41 @@ int CheckIndex2End ( int max, int * p_begin, int * p_end ) /////////////////////////////////////////////////////////////////////////////// +int CheckIndex2ex ( int max, int * p_begin, int * p_end ) +{ + DASSERT( max >= 0 ); + DASSERT(p_begin); + DASSERT(p_end); + + int begin = *p_begin; + if ( begin < 0 ) + { + begin += max; + if ( begin < 0 ) + begin = 0; + } + else if ( begin > max ) + begin = max; + + int end = *p_end; + if ( end <= 0 ) + { + end += max; + // don't check for 'end<0' here, because 'end max ) + end = max; + + if ( end < begin ) + end = begin; + + *p_begin = begin; + *p_end = end; + return end - begin; +} + +/////////////////////////////////////////////////////////////////////////////// + int CheckIndexC ( int max, int * p_begin, int count ) { DASSERT( max >= 0 ); @@ -9928,7 +9963,7 @@ char * PrintIP4ByMode void StartProgress ( progress_t *pr, u_msec_t interval_msec ) { - DASSERT(PR); + DASSERT(pr); ResetProgress(pr); pr->interval_msec = interval_msec; pr->start_msec = GetTimerMSec(); @@ -9938,7 +9973,7 @@ void StartProgress ( progress_t *pr, u_msec_t interval_msec ) bool CheckProgress ( progress_t *pr ) { - DASSERT(PR); + DASSERT(pr); if ( pr->interval_msec > 0 && pr->counter != pr->last_counter ) { const u_msec_t now = GetTimerMSec(); @@ -9956,7 +9991,7 @@ bool CheckProgress ( progress_t *pr ) bool FinalProgress ( progress_t *pr ) { - DASSERT(PR); + DASSERT(pr); if ( pr->interval_msec > 0 && pr->counter != pr->last_counter ) { pr->last_log_msec = GetTimerMSec(); -- cgit v1.3.1