Skip to content

Commit

Permalink
Add missing gettext triggers
Browse files Browse the repository at this point in the history
Commit d660701 moved all the jsonapi.c error messages into
token_error().  This needs to be added to the various nls.mk files
that use this.  Since that makes token_error() effectively a globally
known symbol, the name seems a bit too general, so rename to
json_token_error() for more clarity.
  • Loading branch information
petere committed May 14, 2024
1 parent 9eb54a2 commit 3ddbac3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/backend/nls.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ GETTEXT_TRIGGERS = $(BACKEND_COMMON_GETTEXT_TRIGGERS) \
syncrep_yyerror \
report_invalid_record:2 \
ereport_startup_progress \
json_token_error:2 \
json_manifest_parse_failure:2 \
error_cb:2
GETTEXT_FLAGS = $(BACKEND_COMMON_GETTEXT_FLAGS) \
Expand All @@ -23,6 +24,7 @@ GETTEXT_FLAGS = $(BACKEND_COMMON_GETTEXT_FLAGS) \
write_stderr:1:c-format \
report_invalid_record:2:c-format \
ereport_startup_progress:1:c-format \
json_token_error:2:c-format \
error_cb:2:c-format

gettext-files: generated-parser-sources generated-headers
Expand Down
2 changes: 2 additions & 0 deletions src/bin/pg_combinebackup/nls.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) \
../../common/jsonapi.c \
../../common/parse_manifest.c
GETTEXT_TRIGGERS = $(FRONTEND_COMMON_GETTEXT_TRIGGERS) \
json_token_error:2 \
json_manifest_parse_failure:2 \
error_cb:2
GETTEXT_FLAGS = $(FRONTEND_COMMON_GETTEXT_FLAGS) \
json_token_error:2:c-format \
error_cb:2:c-format
2 changes: 2 additions & 0 deletions src/bin/pg_verifybackup/nls.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) \
../../common/jsonapi.c \
../../common/parse_manifest.c
GETTEXT_TRIGGERS = $(FRONTEND_COMMON_GETTEXT_TRIGGERS) \
json_token_error:2 \
json_manifest_parse_failure:2 \
error_cb:2 \
report_backup_error:2 \
report_fatal_error
GETTEXT_FLAGS = $(FRONTEND_COMMON_GETTEXT_FLAGS) \
json_token_error:2:c-format \
error_cb:2:c-format \
report_backup_error:2:c-format \
report_fatal_error:1:c-format
24 changes: 12 additions & 12 deletions src/common/jsonapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2105,7 +2105,7 @@ json_errdetail(JsonParseErrorType error, JsonLexContext *lex)
* A helper for error messages that should print the current token. The
* format must contain exactly one %.*s specifier.
*/
#define token_error(lex, format) \
#define json_token_error(lex, format) \
appendStringInfo((lex)->errormsg, _(format), \
(int) ((lex)->token_terminator - (lex)->token_start), \
(lex)->token_start);
Expand All @@ -2124,41 +2124,41 @@ json_errdetail(JsonParseErrorType error, JsonLexContext *lex)
case JSON_NESTING_TOO_DEEP:
return (_("JSON nested too deep, maximum permitted depth is 6400"));
case JSON_ESCAPING_INVALID:
token_error(lex, "Escape sequence \"\\%.*s\" is invalid.");
json_token_error(lex, "Escape sequence \"\\%.*s\" is invalid.");
break;
case JSON_ESCAPING_REQUIRED:
appendStringInfo(lex->errormsg,
_("Character with value 0x%02x must be escaped."),
(unsigned char) *(lex->token_terminator));
break;
case JSON_EXPECTED_END:
token_error(lex, "Expected end of input, but found \"%.*s\".");
json_token_error(lex, "Expected end of input, but found \"%.*s\".");
break;
case JSON_EXPECTED_ARRAY_FIRST:
token_error(lex, "Expected array element or \"]\", but found \"%.*s\".");
json_token_error(lex, "Expected array element or \"]\", but found \"%.*s\".");
break;
case JSON_EXPECTED_ARRAY_NEXT:
token_error(lex, "Expected \",\" or \"]\", but found \"%.*s\".");
json_token_error(lex, "Expected \",\" or \"]\", but found \"%.*s\".");
break;
case JSON_EXPECTED_COLON:
token_error(lex, "Expected \":\", but found \"%.*s\".");
json_token_error(lex, "Expected \":\", but found \"%.*s\".");
break;
case JSON_EXPECTED_JSON:
token_error(lex, "Expected JSON value, but found \"%.*s\".");
json_token_error(lex, "Expected JSON value, but found \"%.*s\".");
break;
case JSON_EXPECTED_MORE:
return _("The input string ended unexpectedly.");
case JSON_EXPECTED_OBJECT_FIRST:
token_error(lex, "Expected string or \"}\", but found \"%.*s\".");
json_token_error(lex, "Expected string or \"}\", but found \"%.*s\".");
break;
case JSON_EXPECTED_OBJECT_NEXT:
token_error(lex, "Expected \",\" or \"}\", but found \"%.*s\".");
json_token_error(lex, "Expected \",\" or \"}\", but found \"%.*s\".");
break;
case JSON_EXPECTED_STRING:
token_error(lex, "Expected string, but found \"%.*s\".");
json_token_error(lex, "Expected string, but found \"%.*s\".");
break;
case JSON_INVALID_TOKEN:
token_error(lex, "Token \"%.*s\" is invalid.");
json_token_error(lex, "Token \"%.*s\" is invalid.");
break;
case JSON_UNICODE_CODE_POINT_ZERO:
return _("\\u0000 cannot be converted to text.");
Expand Down Expand Up @@ -2189,7 +2189,7 @@ json_errdetail(JsonParseErrorType error, JsonLexContext *lex)
/* fall through to the error code after switch */
break;
}
#undef token_error
#undef json_token_error

/*
* We don't use a default: case, so that the compiler will warn about
Expand Down

0 comments on commit 3ddbac3

Please sign in to comment.