Skip to content

Commit a7bef9e

Browse files
author
Nikita Glukhov
committed
Extract lex_peek_value()
1 parent 14daf4a commit a7bef9e

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
@@ -72,6 +72,22 @@ lex_peek(JsonLexContext *lex)
7272
return lex->token_type;
7373
}
7474

75+
static inline char *
76+
lex_peek_value(JsonLexContext *lex)
77+
{
78+
if (lex->token_type == JSON_TOKEN_STRING)
79+
return lex->strval ? pstrdup(lex->strval->data) : NULL;
80+
else
81+
{
82+
int len = (lex->token_terminator - lex->token_start);
83+
char *tokstr = palloc(len + 1);
84+
85+
memcpy(tokstr, lex->token_start, len);
86+
tokstr[len] = '\0';
87+
return tokstr;
88+
}
89+
}
90+
7591
/*
7692
* lex_expect
7793
*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy