summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Haszlakiewicz <erh+git@nimenees.com>2017-12-23 09:42:17 -0500
committerEric Haszlakiewicz <erh+git@nimenees.com>2017-12-23 09:42:17 -0500
commit0992aac61f8b087efd7094e9ac2b84fa9c040fcd (patch)
tree36b2a1c8344ad400843b85b29d44981520b5fedf
parentcfd09c87f0227b0a4c4a3666a7d6d744be9d5775 (diff)
downloadjson-c-0992aac61f8b087efd7094e9ac2b84fa9c040fcd.tar.gz
Remove the TRUE and FALSE defines.
-rw-r--r--ChangeLog1
-rw-r--r--json_object.c8
-rw-r--r--json_object.h16
-rw-r--r--linkhash.c4
-rw-r--r--tests/test_set_value.c12
5 files changed, 18 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index f5fee96..5dd29ab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,7 @@ Deprecated and removed features:
* bits.h has been removed
* lh_abort() has been removed
* lh_table_lookup() has been removed, use lh_table_lookup_ex() instead.
+* Remove TRUE and FALSE defines, use 1 and 0 instead.
0.13 (up to commit 5dae561, 2017/11/29)
diff --git a/json_object.c b/json_object.c
index da96f4c..4d6e2e7 100644
--- a/json_object.c
+++ b/json_object.c
@@ -537,7 +537,7 @@ json_bool json_object_object_get_ex(const struct json_object* jso, const char *k
*value = NULL;
if (NULL == jso)
- return FALSE;
+ return 0;
switch(jso->o_type)
{
@@ -547,7 +547,7 @@ json_bool json_object_object_get_ex(const struct json_object* jso, const char *k
default:
if (value != NULL)
*value = NULL;
- return FALSE;
+ return 0;
}
}
@@ -583,7 +583,7 @@ struct json_object* json_object_new_boolean(json_bool b)
json_bool json_object_get_boolean(const struct json_object *jso)
{
if (!jso)
- return FALSE;
+ return 0;
switch(jso->o_type)
{
case json_type_boolean:
@@ -595,7 +595,7 @@ json_bool json_object_get_boolean(const struct json_object *jso)
case json_type_string:
return (jso->o.c_string.len != 0);
default:
- return FALSE;
+ return 0;
}
}
diff --git a/json_object.h b/json_object.h
index 4b7a246..db63d22 100644
--- a/json_object.h
+++ b/json_object.h
@@ -118,12 +118,6 @@ extern "C" {
*/
#define JSON_C_OBJECT_KEY_IS_CONSTANT (1<<2)
-#undef FALSE
-#define FALSE ((json_bool)0)
-
-#undef TRUE
-#define TRUE ((json_bool)1)
-
/**
* Set the global value of an option, which will apply to all
* current and future threads that have not set a thread-local value.
@@ -654,7 +648,7 @@ JSON_EXPORT int json_object_array_del_idx(struct json_object *obj, size_t idx, s
/* json_bool type methods */
/** Create a new empty json_object of type json_type_boolean
- * @param b a json_bool TRUE or FALSE (1 or 0)
+ * @param b a json_bool 1 or 0
* @returns a json_object of type json_type_boolean
*/
JSON_EXPORT struct json_object* json_object_new_boolean(json_bool b);
@@ -662,10 +656,10 @@ JSON_EXPORT struct json_object* json_object_new_boolean(json_bool b);
/** Get the json_bool value of a json_object
*
* The type is coerced to a json_bool if the passed object is not a json_bool.
- * integer and double objects will return FALSE if there value is zero
- * or TRUE otherwise. If the passed object is a string it will return
- * TRUE if it has a non zero length. If any other object type is passed
- * TRUE will be returned if the object is not NULL.
+ * integer and double objects will return 0 if there value is zero
+ * or 1 otherwise. If the passed object is a string it will return
+ * 1 if it has a non zero length. If any other object type is passed
+ * 1 will be returned if the object is not NULL.
*
* @param obj the json_object instance
* @returns a json_bool
diff --git a/linkhash.c b/linkhash.c
index 7dddc36..b1223c4 100644
--- a/linkhash.c
+++ b/linkhash.c
@@ -626,10 +626,10 @@ json_bool lh_table_lookup_ex(struct lh_table* t, const void* k, void **v)
struct lh_entry *e = lh_table_lookup_entry(t, k);
if (e != NULL) {
if (v != NULL) *v = lh_entry_v(e);
- return TRUE; /* key found */
+ return 1; /* key found */
}
if (v != NULL) *v = NULL;
- return FALSE; /* key not found */
+ return 0; /* key not found */
}
int lh_table_delete_entry(struct lh_table *t, struct lh_entry *e)
diff --git a/tests/test_set_value.c b/tests/test_set_value.c
index 4c0a54a..1f80b0e 100644
--- a/tests/test_set_value.c
+++ b/tests/test_set_value.c
@@ -15,12 +15,12 @@ int main(int argc, char **argv)
assert (json_object_get_int64(tmp)==321321321);
json_object_put(tmp);
printf("INT64 PASSED\n");
- tmp=json_object_new_boolean(TRUE);
- assert (json_object_get_boolean(tmp)==TRUE);
- json_object_set_boolean(tmp,FALSE);
- assert (json_object_get_boolean(tmp)==FALSE);
- json_object_set_boolean(tmp,TRUE);
- assert (json_object_get_boolean(tmp)==TRUE);
+ tmp=json_object_new_boolean(1);
+ assert (json_object_get_boolean(tmp)==1);
+ json_object_set_boolean(tmp,0);
+ assert (json_object_get_boolean(tmp)==0);
+ json_object_set_boolean(tmp,1);
+ assert (json_object_get_boolean(tmp)==1);
json_object_put(tmp);
printf("BOOL PASSED\n");
tmp=json_object_new_double(12.34);