aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhilipp Stephani2017-12-20 18:36:35 +0100
committerPhilipp Stephani2017-12-20 18:36:35 +0100
commit615c5cf0a6ba64af1e66e39722bc01334d484dcc (patch)
tree278a627de99bfb71df533481e594725a94836b08 /src
parent4bb8e2879d31aa0e7ead0b384959c85b4ccc7c0c (diff)
downloademacs-615c5cf0a6ba64af1e66e39722bc01334d484dcc.tar.gz
emacs-615c5cf0a6ba64af1e66e39722bc01334d484dcc.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/json.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/json.c b/src/json.c
index 6d822224b21..48cf96a62b9 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/>. */
30#include "buffer.h" 30#include "buffer.h"
31#include "coding.h" 31#include "coding.h"
32 32
33#define JSON_HAS_ERROR_CODE (JANSSON_VERSION_HEX >= 0x020B00)
34
33#ifdef WINDOWSNT 35#ifdef WINDOWSNT
34# include <windows.h> 36# include <windows.h>
35# include "w32.h" 37# include "w32.h"
@@ -179,6 +181,8 @@ init_json (void)
179 json_set_alloc_funcs (json_malloc, json_free); 181 json_set_alloc_funcs (json_malloc, json_free);
180} 182}
181 183
184#if !JSON_HAS_ERROR_CODE
185
182/* Return whether STRING starts with PREFIX. */ 186/* Return whether STRING starts with PREFIX. */
183 187
184static bool 188static bool
@@ -200,6 +204,8 @@ json_has_suffix (const char *string, const char *suffix)
200 && memcmp (string + string_len - suffix_len, suffix, suffix_len) == 0; 204 && memcmp (string + string_len - suffix_len, suffix, suffix_len) == 0;
201} 205}
202 206
207#endif
208
203/* Create a multibyte Lisp string from the UTF-8 string in 209/* Create a multibyte Lisp string from the UTF-8 string in
204 [DATA, DATA + SIZE). If the range [DATA, DATA + SIZE) does not 210 [DATA, DATA + SIZE). If the range [DATA, DATA + SIZE) does not
205 contain a valid UTF-8 string, an unspecified string is 211 contain a valid UTF-8 string, an unspecified string is
@@ -249,7 +255,7 @@ static _Noreturn void
249json_parse_error (const json_error_t *error) 255json_parse_error (const json_error_t *error)
250{ 256{
251 Lisp_Object symbol; 257 Lisp_Object symbol;
252#if JANSSON_VERSION_HEX >= 0x020B00 258#if JSON_HAS_ERROR_CODE
253 switch (json_error_code (error)) 259 switch (json_error_code (error))
254 { 260 {
255 case json_error_premature_end_of_input: 261 case json_error_premature_end_of_input: