emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 615c5cf: Define helper functions only if needed


From: Philipp Stephani
Subject: [Emacs-diffs] master 615c5cf: Define helper functions only if needed
Date: Wed, 20 Dec 2017 12:37:14 -0500 (EST)

branch: master
commit 615c5cf0a6ba64af1e66e39722bc01334d484dcc
Author: Philipp Stephani <address@hidden>
Commit: Philipp Stephani <address@hidden>

    Define helper functions only if needed
    
    * src/json.c (JSON_HAS_ERROR_CODE): New define.
    (json_parse_error): Use it.
    (json_has_prefix, json_has_suffix): Define only if needed.
---
 src/json.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/json.c b/src/json.c
index 6d82222..48cf96a 100644
--- a/src/json.c
+++ b/src/json.c
@@ -30,6 +30,8 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "buffer.h"
 #include "coding.h"
 
+#define JSON_HAS_ERROR_CODE (JANSSON_VERSION_HEX >= 0x020B00)
+
 #ifdef WINDOWSNT
 # include <windows.h>
 # include "w32.h"
@@ -179,6 +181,8 @@ init_json (void)
   json_set_alloc_funcs (json_malloc, json_free);
 }
 
+#if !JSON_HAS_ERROR_CODE
+
 /* Return whether STRING starts with PREFIX.  */
 
 static bool
@@ -200,6 +204,8 @@ json_has_suffix (const char *string, const char *suffix)
     && memcmp (string + string_len - suffix_len, suffix, suffix_len) == 0;
 }
 
+#endif
+
 /* Create a multibyte Lisp string from the UTF-8 string in
    [DATA, DATA + SIZE).  If the range [DATA, DATA + SIZE) does not
    contain a valid UTF-8 string, an unspecified string is
@@ -249,7 +255,7 @@ static _Noreturn void
 json_parse_error (const json_error_t *error)
 {
   Lisp_Object symbol;
-#if JANSSON_VERSION_HEX >= 0x020B00
+#if JSON_HAS_ERROR_CODE
   switch (json_error_code (error))
     {
     case json_error_premature_end_of_input:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]