summaryrefslogtreecommitdiff
path: root/jsonpath.c
diff options
context:
space:
mode:
authorJoey Adams2010-07-24 00:19:26 +0000
committerJoey Adams2010-07-24 00:19:26 +0000
commitbc9e250d090da889a3e1e1eb82b5dfc0a32bc52e (patch)
tree9068b19215f90ca971d294b1fa4c60b353125acb /jsonpath.c
parent8a019e04b817ffca00ec9759f3d12c60c808e67f (diff)
* Migrated general-purpose functions to new files util.c/util.h
* A few various cleanups.
Diffstat (limited to 'jsonpath.c')
-rw-r--r--jsonpath.c45
1 files changed, 1 insertions, 44 deletions
diff --git a/jsonpath.c b/jsonpath.c
index 361c996..eaf5b7a 100644
--- a/jsonpath.c
+++ b/jsonpath.c
@@ -1,7 +1,7 @@
#include "jsonpath.h"
+#include "util.h"
#include <ctype.h>
-#include "mb/pg_wchar.h"
/* NB: These macros evaluate their argument multiple times. */
@@ -379,49 +379,6 @@ failed:
return NULL;
}
-static size_t
-utf8_substring(
- const char *src, size_t srcbytes,
- size_t start, size_t length,
- const char **out_start, size_t *out_bytes)
-{
- const char *e = src + srcbytes;
- const char *sub_start;
- const char *sub_end;
- size_t sub_length;
-
- sub_start = src;
- while (start > 0 && sub_start < e)
- {
- sub_start += pg_utf_mblen((const unsigned char *) sub_start);
- start--;
- }
-
- sub_end = sub_start;
- sub_length = 0;
- while (sub_length < length && sub_end < e)
- {
- sub_end += pg_utf_mblen((const unsigned char *) sub_end);
- sub_length++;
- }
-
- /* Make sure the input didn't have a clipped UTF-8 character */
- if (sub_start > e)
- {
- Assert(false);
- sub_start = sub_end = e;
- }
- else if (sub_end > e)
- {
- Assert(false);
- sub_end = e;
- }
-
- *out_start = sub_start;
- *out_bytes = sub_end - sub_start;
- return sub_length;
-}
-
/*
Currently, a lot of JPRef nodes are allocated just to pass json_node pointers
to match_recurse. If this becomes a memory/performance issue in the future,