wsanchez 2002/07/24 13:29:38
Modified: . CHANGES configure.in
include apr.h.in apr_strings.h
strings apr_strings.c
Log:
Added apr_strtoll() and apr_atoll() to strings lib.
Submitted by: Shantonu Sen <[EMAIL PROTECTED]>
Revision Changes Path
1.311 +3 -0 apr/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apr/CHANGES,v
retrieving revision 1.310
retrieving revision 1.311
diff -u -r1.310 -r1.311
--- CHANGES 20 Jul 2002 21:28:50 -0000 1.310
+++ CHANGES 24 Jul 2002 20:29:37 -0000 1.311
@@ -1,5 +1,8 @@
Changes with APR b1
+ *) Added apr_strtoll() and apr_atoll() to strings lib.
+ [Shantonu Sen <[EMAIL PROTECTED]>, Wilfredo Sanchez]
+
*) Added a lightweight internal index to apr_table_t to speed up
table lookup operations [Brian Pane]
1.468 +2 -0 apr/configure.in
Index: configure.in
===================================================================
RCS file: /home/cvs/apr/configure.in,v
retrieving revision 1.467
retrieving revision 1.468
diff -u -r1.467 -r1.468
--- configure.in 24 Jul 2002 12:33:39 -0000 1.467
+++ configure.in 24 Jul 2002 20:29:37 -0000 1.468
@@ -1210,6 +1210,7 @@
AC_CHECK_FUNCS(strdup, have_strdup="1", have_strdup="0")
AC_CHECK_FUNCS(strstr, have_strstr="1", have_strstr="0")
AC_CHECK_FUNCS(memchr, have_memchr="1", have_memchr="0")
+AC_CHECK_FUNCS(strtoll, have_strtoll="1", have_strtoll="0")
AC_SUBST(have_strnicmp)
AC_SUBST(have_strncasecmp)
@@ -1218,6 +1219,7 @@
AC_SUBST(have_strdup)
AC_SUBST(have_strstr)
AC_SUBST(have_memchr)
+AC_SUBST(have_strtoll)
dnl #----------------------------- Checking for DSO support
echo $ac_n "${nl}Checking for DSO...${nl}"
1.114 +1 -0 apr/include/apr.h.in
Index: apr.h.in
===================================================================
RCS file: /home/cvs/apr/include/apr.h.in,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -r1.113 -r1.114
--- apr.h.in 19 Jul 2002 13:02:13 -0000 1.113
+++ apr.h.in 24 Jul 2002 20:29:38 -0000 1.114
@@ -115,6 +115,7 @@
#define APR_HAVE_STRNICMP @have_strnicmp@
#define APR_HAVE_STRSTR @have_strstr@
#define APR_HAVE_MEMCHR @have_memchr@
+#define APR_HAVE_STRTOLL @have_strtoll@
#define APR_HAVE_STRUCT_RLIMIT @struct_rlimit@
#define APR_HAVE_UNION_SEMUN @have_union_semun@
1.27 +24 -0 apr/include/apr_strings.h
Index: apr_strings.h
===================================================================
RCS file: /home/cvs/apr/include/apr_strings.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- apr_strings.h 28 Jun 2002 21:05:14 -0000 1.26
+++ apr_strings.h 24 Jul 2002 20:29:38 -0000 1.27
@@ -327,6 +327,30 @@
APR_DECLARE(char *) apr_off_t_toa(apr_pool_t *p, apr_off_t n);
/**
+ * parse a numeric string into a long long value
+ * @param buf The string to parse. It may contain optional whitespace,
+ * followed by an optional '+' (positive, default) or '-' (negative)
+ * character, followed by an optional '0x' prefix if base is 0 or 16,
+ * followed by numeric digits appropriate for base.
+ * @param end A pointer to the end of the valid character in buf. If
+ * not nil, it is set to the first invalid character in buf.
+ * @param base A numeric base in the range between 2 and 36 inclusive,
+ * or 0. If base is zero, buf will be treated as base ten unless its
+ * digits are prefixed with '0x', in which case it will be treated as
+ * base 16.
+ * @return The long long value of the string.
+ */
+APR_DECLARE(long long) apr_strtoll(char *buf, char **end, int base);
+
+/**
+ * parse a base-10 numeric string into a long long value.
+ * Equivalent to apr_strtoll(buf, (char**)NULL, 10).
+ * @param buf The string to parse
+ * @return The long long value of the string
+ */
+APR_DECLARE(long long) apr_atoll(char *buf);
+
+/**
* Format a binary size (magnitiudes are 2^10 rather than 10^3) from an
apr_off_t,
* as bytes, K, M, T, etc, to a four character compacted human readable
string.
* @param size The size to format
1.30 +19 -0 apr/strings/apr_strings.c
Index: apr_strings.c
===================================================================
RCS file: /home/cvs/apr/strings/apr_strings.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- apr_strings.c 10 Jul 2002 06:01:13 -0000 1.29
+++ apr_strings.c 24 Jul 2002 20:29:38 -0000 1.30
@@ -65,6 +65,10 @@
#include <stddef.h> /* NULL */
#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h> /* strtol and strtoll */
+#endif
+
/** this is used to cache lengths in apr_pstrcat */
#define MAX_SAVED_LENGTHS 6
@@ -228,6 +232,21 @@
return NULL;
}
#endif
+
+APR_DECLARE(long long) apr_strtoll(char *buf, char **end, int base)
+{
+#if (APR_HAVE_STRTOLL)
+ return strtoll(buf, NULL, 0);
+#else
+ /* best-effort function. If no strtoll, use strtol */
+ return (long long)strtol(buf, NULL, 0);
+#endif
+}
+
+APR_DECLARE(long long) apr_atoll(char *buf)
+{
+ return apr_strtoll(buf, NULL, 0);
+}
APR_DECLARE(char *) apr_itoa(apr_pool_t *p, int n)
{