You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by fd...@apache.org on 2012/01/23 00:43:13 UTC
[17/50] git commit: Use enif_is_number on OTP R15B or higher
Use enif_is_number on OTP R15B or higher
The NIF API in OTP R15B introduced the enif_is_number function.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/fcd7f804
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/fcd7f804
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/fcd7f804
Branch: refs/heads/COUCHDB-1342
Commit: fcd7f804a7cf903aebaebd2793cada278ae59995
Parents: bcd5039
Author: Filipe David Borba Manana <fd...@apache.org>
Authored: Sun Jan 8 13:18:15 2012 +0000
Committer: Filipe David Borba Manana <fd...@apache.org>
Committed: Sun Jan 8 13:18:15 2012 +0000
----------------------------------------------------------------------
.../priv/couch_ejson_compare/couch_ejson_compare.c | 21 ++++++++-------
1 files changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/fcd7f804/src/couchdb/priv/couch_ejson_compare/couch_ejson_compare.c
----------------------------------------------------------------------
diff --git a/src/couchdb/priv/couch_ejson_compare/couch_ejson_compare.c b/src/couchdb/priv/couch_ejson_compare/couch_ejson_compare.c
index e696961..df68c2a 100644
--- a/src/couchdb/priv/couch_ejson_compare/couch_ejson_compare.c
+++ b/src/couchdb/priv/couch_ejson_compare/couch_ejson_compare.c
@@ -20,6 +20,17 @@
#define MAX_DEPTH 10
+#if (ERL_NIF_MAJOR_VERSION > 2) || \
+ (ERL_NIF_MAJOR_VERSION == 2 && ERL_NIF_MINOR_VERSION >= 3)
+/* OTP R15B or higher */
+#define term_is_number(env, t) enif_is_number(env, t)
+#else
+#define term_is_number(env, t) \
+ (!enif_is_binary(env, t) && \
+ !enif_is_list(env, t) && \
+ !enif_is_tuple(env, t))
+#endif
+
static ERL_NIF_TERM ATOM_TRUE;
static ERL_NIF_TERM ATOM_FALSE;
static ERL_NIF_TERM ATOM_NULL;
@@ -43,7 +54,6 @@ static __inline int atom_sort_order(ErlNifEnv*, ERL_NIF_TERM);
static __inline int compare_strings(ctx_t*, ErlNifBinary, ErlNifBinary);
static __inline int compare_lists(int, ctx_t*, ERL_NIF_TERM, ERL_NIF_TERM);
static __inline int compare_props(int, ctx_t*, ERL_NIF_TERM, ERL_NIF_TERM);
-static __inline int term_is_number(ErlNifEnv*, ERL_NIF_TERM);
static __inline void reserve_coll(ctx_t*);
static __inline void release_coll(ctx_t*);
@@ -237,15 +247,6 @@ atom_sort_order(ErlNifEnv* env, ERL_NIF_TERM a)
int
-term_is_number(ErlNifEnv* env, ERL_NIF_TERM t)
-{
- /* Determination by exclusion of parts. To be used only inside less_json! */
- return !enif_is_binary(env, t) && !enif_is_list(env, t) &&
- !enif_is_tuple(env, t);
-}
-
-
-int
compare_lists(int depth, ctx_t* ctx, ERL_NIF_TERM a, ERL_NIF_TERM b)
{
ERL_NIF_TERM headA, tailA;