X-Git-Url: https://git.datadissipation.net/libcext/blobdiff_plain/576f1e91efe7bbb49a5682903b23d6d37b6b6725..HEAD:/strtonum.h?ds=inline diff --git a/strtonum.h b/strtonum.h index 471aea8..f192630 100644 --- a/strtonum.h +++ b/strtonum.h @@ -16,28 +16,28 @@ */ /* https://git.datadissipation.net */ -#ifndef STRTONUM_H_ - #define STRTONUM_H_ 1 +#ifndef LCE_STRTONUM_H + #define LCE_STRTONUM_H 1 - #ifdef STRTONUM_INCLUDE_LIBC + #ifdef LCE_STRTONUM_INCLUDE_LIBC #include #include #include - #endif /* STRTONUM_INCLUDE_LIBC */ + #endif /* LCE_STRTONUM_INCLUDE_LIBC */ #ifndef HAVE_STRTONUM - #define strtonum i_strtonum_ -long long i_strtonum_(const char *numstr, long long minval, long long maxval, + #define strtonum lce_strtonum_ +long long lce_strtonum_(const char *numstr, long long minval, long long maxval, const char **errstrp); #endif /* !HAVE_STRTONUM */ - #ifdef STRTONUM_IMPLEMENTATION - #define I_INVALID_ 1 - #define I_TOOSMALL_ 2 - #define I_TOOLARGE_ 3 + #ifdef LCE_STRTONUM_IMPLEMENTATION + #define LCE_INVALID_ 1 + #define LCE_TOOSMALL_ 2 + #define LCE_TOOLARGE_ 3 long long -i_strtonum_(const char *numstr, long long minval, long long maxval, +lce_strtonum_(const char *numstr, long long minval, long long maxval, const char **errstrp) { long long ll = 0; @@ -56,15 +56,15 @@ i_strtonum_(const char *numstr, long long minval, long long maxval, ev[0].err = errno; errno = 0; if (minval > maxval) { - error = I_INVALID_; + error = LCE_INVALID_; } else { ll = strtoll(numstr, &ep, 10); if (numstr == ep || *ep != '\0') - error = I_INVALID_; + error = LCE_INVALID_; else if ((ll == LLONG_MIN && errno == ERANGE) || ll < minval) - error = I_TOOSMALL_; + error = LCE_TOOSMALL_; else if ((ll == LLONG_MAX && errno == ERANGE) || ll > maxval) - error = I_TOOLARGE_; + error = LCE_TOOLARGE_; } if (errstrp != NULL) *errstrp = ev[error].errstr; @@ -74,5 +74,5 @@ i_strtonum_(const char *numstr, long long minval, long long maxval, return (ll); } - #endif /* STRTONUM_IMPLEMENTATION */ -#endif /* !STRTONUM_H_ */ + #endif /* LCE_STRTONUM_IMPLEMENTATION */ +#endif /* !LCE_STRTONUM_H */