31
31
#include "svn_props.h"
32
32
#include "svn_private_config.h"
34
#include "private/svn_dep_compat.h"
35
#include "private/svn_string_private.h"
35
38
svn_revnum_parse(svn_revnum_t *rev,
37
40
const char **endptr)
41
svn_revnum_t result = strtol(str, &end, 10);
44
svn_revnum_t result = (svn_revnum_t)svn__strtoul(str, &end);
50
return svn_error_createf
51
(SVN_ERR_REVNUM_PARSE_FAILURE, NULL,
52
*str == '-' ? _("Negative revision number found parsing '%s'")
53
: _("Invalid revision number found parsing '%s'"),
56
/* a revision number with more than 9 digits is suspicious.
57
Have a closer look at those. */
60
/* we support 32 bit revision numbers only. check for overflows */
62
return svn_error_createf
63
(SVN_ERR_REVNUM_PARSE_FAILURE, NULL,
64
_("Revision number longer than 10 digits '%s'"), str);
66
/* we support 32 bit revision numbers only. check for overflows */
67
if (*str > '2' || (apr_uint32_t)result > APR_INT32_MAX)
68
return svn_error_createf
69
(SVN_ERR_REVNUM_PARSE_FAILURE, NULL,
70
_("Revision number too large '%s'"), str);
47
return svn_error_createf(SVN_ERR_REVNUM_PARSE_FAILURE, NULL,
48
_("Invalid revision number found parsing '%s'"),
53
/* The end pointer from strtol() is valid, but a negative revision
54
number is invalid, so move the end pointer back to the
55
beginning of the string. */
59
return svn_error_createf(SVN_ERR_REVNUM_PARSE_FAILURE, NULL,
60
_("Negative revision number found parsing '%s'"),
66
78
return SVN_NO_ERROR;