Content-Length: 281957 | pFad | http://github.com/postgrespro/postgres/commit/463aaad8a611d4b324a1ae5c428914540cf4435c

EB Extract lex_peek_value() · postgrespro/postgres@463aaad · GitHub
Skip to content

Commit 463aaad

Browse files
author
Nikita Glukhov
committed
Extract lex_peek_value()
1 parent 05ca48f commit 463aaad

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/common/jsonapi.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,22 @@ lex_peek(JsonLexContext *lex)
8383
return lex->token_type;
8484
}
8585

86+
static inline char *
87+
lex_peek_value(JsonLexContext *lex)
88+
{
89+
if (lex->token_type == JSON_TOKEN_STRING)
90+
return lex->strval ? pstrdup(lex->strval->data) : NULL;
91+
else
92+
{
93+
int len = (lex->token_terminator - lex->token_start);
94+
char *tokstr = palloc(len + 1);
95+
96+
memcpy(tokstr, lex->token_start, len);
97+
tokstr[len] = '\0';
98+
return tokstr;
99+
}
100+
}
101+
86102
/*
87103
* lex_expect
88104
*

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/463aaad8a611d4b324a1ae5c428914540cf4435c

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy