From cea1737bd218aa84bf41637deee25bd199fb128d Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Mon, 12 Sep 2016 11:22:16 +0200 Subject: Let strtoi with NULL endptr require no invalid characters If the caller is not interested in checking its end, then it probably wants a valid number only if the string contains a valid number. Add a shortcut for this. Change-Id: I39701bd445e29fb2606720b18ca3764c74a7255b Reviewed-on: https://code.wireshark.org/review/17658 Petri-Dish: Dario Lombardo Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris Reviewed-by: Dario Lombardo --- wsutil/strtoi.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'wsutil/strtoi.h') diff --git a/wsutil/strtoi.h b/wsutil/strtoi.h index ed48b52aac..3361da8fc3 100644 --- a/wsutil/strtoi.h +++ b/wsutil/strtoi.h @@ -32,10 +32,12 @@ /* * \brief Convert a string to a signed/unsigned int, with error checks. * \param str The string to convert - * \param endptr NULL or pointer to a pointer set to point to the - * character after the last character of the number + * \param endptr A pointer that will store a pointer to the first invalid + * character in str, allowing a number to be parsed even if there is trailing + * whitespace. If NULL, then the string is assumed to contain only valid + * characters (or it will error out). * \param cint The converted integer - * \return TRUE if the conversion suceeds, FALSE otherwise. + * \return TRUE if the conversion succeeds, FALSE otherwise. * On error, errno is set to EINVAL for unrecognized input and ERANGE * if the resulting number does not fit in the type. */ -- cgit v1.2.1