Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1e844b3

Browse files
author
Nikita Glukhov
committed
Extract lex_peek_value()
1 parent4c51772 commit1e844b3

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

‎src/backend/utils/adt/json.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,22 @@ lex_peek(JsonLexContext *lex)
125125
returnlex->token_type;
126126
}
127127

128+
staticinlinechar*
129+
lex_peek_value(JsonLexContext*lex)
130+
{
131+
if (lex->token_type==JSON_TOKEN_STRING)
132+
returnlex->strval ?pstrdup(lex->strval->data) :NULL;
133+
else
134+
{
135+
intlen= (lex->token_terminator-lex->token_start);
136+
char*tokstr=palloc(len+1);
137+
138+
memcpy(tokstr,lex->token_start,len);
139+
tokstr[len]='\0';
140+
returntokstr;
141+
}
142+
}
143+
128144
/*
129145
* lex_accept
130146
*
@@ -140,22 +156,8 @@ lex_accept(JsonLexContext *lex, JsonTokenType token, char **lexeme)
140156
if (lex->token_type==token)
141157
{
142158
if (lexeme!=NULL)
143-
{
144-
if (lex->token_type==JSON_TOKEN_STRING)
145-
{
146-
if (lex->strval!=NULL)
147-
*lexeme=pstrdup(lex->strval->data);
148-
}
149-
else
150-
{
151-
intlen= (lex->token_terminator-lex->token_start);
152-
char*tokstr=palloc(len+1);
159+
*lexeme=lex_peek_value(lex);
153160

154-
memcpy(tokstr,lex->token_start,len);
155-
tokstr[len]='\0';
156-
*lexeme=tokstr;
157-
}
158-
}
159161
json_lex(lex);
160162
return true;
161163
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp