Indent C code in flex and bison files

In the style of pgindent, done semi-manually.

Discussion: https://www.postgresql.org/message-id/flat/7d062ecc-7444-23ec-a159-acd8adf9b586%40enterprisedb.com
This commit is contained in:
Peter Eisentraut 2022-05-13 07:17:29 +02:00
parent 0cf16cb8ca
commit 30ed71e423
12 changed files with 1955 additions and 1167 deletions

View File

@ -38,13 +38,15 @@ static char strbuf[25] = {
%expect 0 %expect 0
%name-prefix="seg_yy" %name-prefix="seg_yy"
%union { %union
struct BND { {
struct BND
{
float val; float val;
char ext; char ext;
char sigd; char sigd;
} bnd; } bnd;
char * text; char *text;
} }
%token <text> SEGFLOAT %token <text> SEGFLOAT
%token <text> RANGE %token <text> RANGE

View File

@ -401,6 +401,7 @@ boot_index_param:
boot_ident boot_ident boot_ident boot_ident
{ {
IndexElem *n = makeNode(IndexElem); IndexElem *n = makeNode(IndexElem);
n->name = $1; n->name = $1;
n->expr = NULL; n->expr = NULL;
n->indexcolname = NULL; n->indexcolname = NULL;

File diff suppressed because it is too large Load Diff

View File

@ -42,11 +42,11 @@ Node *replication_parse_result;
%expect 0 %expect 0
%name-prefix="replication_yy" %name-prefix="replication_yy"
%union { %union
{
char *str; char *str;
bool boolval; bool boolval;
uint32 uintval; uint32 uintval;
XLogRecPtr recptr; XLogRecPtr recptr;
Node *node; Node *node;
List *list; List *list;
@ -215,27 +215,27 @@ create_slot_legacy_opt:
K_EXPORT_SNAPSHOT K_EXPORT_SNAPSHOT
{ {
$$ = makeDefElem("snapshot", $$ = makeDefElem("snapshot",
(Node *)makeString("export"), -1); (Node *) makeString("export"), -1);
} }
| K_NOEXPORT_SNAPSHOT | K_NOEXPORT_SNAPSHOT
{ {
$$ = makeDefElem("snapshot", $$ = makeDefElem("snapshot",
(Node *)makeString("nothing"), -1); (Node *) makeString("nothing"), -1);
} }
| K_USE_SNAPSHOT | K_USE_SNAPSHOT
{ {
$$ = makeDefElem("snapshot", $$ = makeDefElem("snapshot",
(Node *)makeString("use"), -1); (Node *) makeString("use"), -1);
} }
| K_RESERVE_WAL | K_RESERVE_WAL
{ {
$$ = makeDefElem("reserve_wal", $$ = makeDefElem("reserve_wal",
(Node *)makeBoolean(true), -1); (Node *) makeBoolean(true), -1);
} }
| K_TWO_PHASE | K_TWO_PHASE
{ {
$$ = makeDefElem("two_phase", $$ = makeDefElem("two_phase",
(Node *)makeBoolean(true), -1); (Node *) makeBoolean(true), -1);
} }
; ;

View File

@ -170,6 +170,7 @@ WAIT { return K_WAIT; }
<xd>{xdstop} { <xd>{xdstop} {
int len; int len;
yyless(1); yyless(1);
BEGIN(INITIAL); BEGIN(INITIAL);
yylval.str = litbufdup(); yylval.str = litbufdup();

View File

@ -77,7 +77,8 @@ static JsonPathParseItem *makeItemLikeRegex(JsonPathParseItem *expr,
%error-verbose %error-verbose
%parse-param {JsonPathParseResult **result} %parse-param {JsonPathParseResult **result}
%union { %union
{
JsonPathString str; JsonPathString str;
List *elems; /* list of JsonPathParseItem */ List *elems; /* list of JsonPathParseItem */
List *indexs; /* list of integers */ List *indexs; /* list of integers */

View File

@ -1031,7 +1031,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
char* endptr; char* endptr;
errno = 0; errno = 0;
base_yylval.ival = strtoul((char *)yytext,&endptr,16); base_yylval.ival = strtoul((char *) yytext, &endptr, 16);
if (*endptr != '\0' || errno == ERANGE) if (*endptr != '\0' || errno == ERANGE)
{ {
errno = 0; errno = 0;
@ -1166,7 +1166,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
*/ */
for (i = strlen(yytext)-2; for (i = strlen(yytext)-2;
i > 0 && ecpg_isspace(yytext[i]); i > 0 && ecpg_isspace(yytext[i]);
i-- ) i--)
; ;
yytext[i+1] = '\0'; yytext[i+1] = '\0';
@ -1290,7 +1290,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
} }
<C,xskip>{exec_sql}{else}{space}*";" { /* only exec sql endif pops the stack, so take care of duplicated 'else' */ <C,xskip>{exec_sql}{else}{space}*";" { /* only exec sql endif pops the stack, so take care of duplicated 'else' */
if ( preproc_tos == 0 ) if (preproc_tos == 0)
mmfatal(PARSE_ERROR, "missing matching \"EXEC SQL IFDEF\" / \"EXEC SQL IFNDEF\""); mmfatal(PARSE_ERROR, "missing matching \"EXEC SQL IFDEF\" / \"EXEC SQL IFNDEF\"");
else if (stacked_if_value[preproc_tos].else_branch) else if (stacked_if_value[preproc_tos].else_branch)
mmfatal(PARSE_ERROR, "more than one EXEC SQL ELSE"); mmfatal(PARSE_ERROR, "more than one EXEC SQL ELSE");
@ -1312,7 +1312,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
/* are we simulating Informix? */ /* are we simulating Informix? */
if (INFORMIX_MODE) if (INFORMIX_MODE)
{ {
if ( preproc_tos == 0 ) if (preproc_tos == 0)
mmfatal(PARSE_ERROR, "missing matching \"EXEC SQL IFDEF\" / \"EXEC SQL IFNDEF\""); mmfatal(PARSE_ERROR, "missing matching \"EXEC SQL IFDEF\" / \"EXEC SQL IFNDEF\"");
else if (stacked_if_value[preproc_tos].else_branch) else if (stacked_if_value[preproc_tos].else_branch)
mmfatal(PARSE_ERROR, "more than one EXEC SQL ELSE"); mmfatal(PARSE_ERROR, "more than one EXEC SQL ELSE");
@ -1382,7 +1382,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
*/ */
for (i = strlen(yytext)-2; for (i = strlen(yytext)-2;
i > 0 && ecpg_isspace(yytext[i]); i > 0 && ecpg_isspace(yytext[i]);
i-- ) i--)
; ;
yytext[i+1] = '\0'; yytext[i+1] = '\0';
@ -1456,7 +1456,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
<<EOF>> { <<EOF>> {
if (yy_buffer == NULL) if (yy_buffer == NULL)
{ {
if ( preproc_tos > 0 ) if (preproc_tos > 0)
{ {
preproc_tos = 0; preproc_tos = 0;
mmfatal(PARSE_ERROR, "missing \"EXEC SQL ENDIF;\""); mmfatal(PARSE_ERROR, "missing \"EXEC SQL ENDIF;\"");
@ -1479,7 +1479,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
if (yyin != NULL) if (yyin != NULL)
fclose(yyin); fclose(yyin);
yy_delete_buffer( YY_CURRENT_BUFFER ); yy_delete_buffer(YY_CURRENT_BUFFER);
yy_switch_to_buffer(yy_buffer->buffer); yy_switch_to_buffer(yy_buffer->buffer);
yylineno = yy_buffer->lineno; yylineno = yy_buffer->lineno;
@ -1661,7 +1661,7 @@ parse_include(void)
if (strcmp(inc_file + strlen(inc_file) - 2, ".h") != 0) if (strcmp(inc_file + strlen(inc_file) - 2, ".h") != 0)
{ {
strcat(inc_file, ".h"); strcat(inc_file, ".h");
yyin = fopen( inc_file, "r" ); yyin = fopen(inc_file, "r");
} }
} }
/* if the command was "include_next" we have to disregard the first hit */ /* if the command was "include_next" we have to disregard the first hit */
@ -1677,7 +1677,7 @@ parse_include(void)
mmfatal(NO_INCLUDE_FILE, "could not open include file \"%s\" on line %d", yytext, yylineno); mmfatal(NO_INCLUDE_FILE, "could not open include file \"%s\" on line %d", yytext, yylineno);
input_filename = mm_strdup(inc_file); input_filename = mm_strdup(inc_file);
yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE )); yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE));
yylineno = 1; yylineno = 1;
output_line_number(); output_line_number();

View File

@ -116,7 +116,8 @@ static void check_raise_parameters(PLpgSQL_stmt_raise *stmt);
%name-prefix="plpgsql_yy" %name-prefix="plpgsql_yy"
%locations %locations
%union { %union
{
core_YYSTYPE core_yystype; core_YYSTYPE core_yystype;
/* these fields must match core_YYSTYPE: */ /* these fields must match core_YYSTYPE: */
int ival; int ival;
@ -425,7 +426,7 @@ pl_block : decl_sect K_BEGIN proc_sect exception_sect K_END opt_label
check_labels($1.label, $6, @6); check_labels($1.label, $6, @6);
plpgsql_ns_pop(); plpgsql_ns_pop();
$$ = (PLpgSQL_stmt *)new; $$ = (PLpgSQL_stmt *) new;
} }
; ;
@ -932,7 +933,7 @@ stmt_perform : K_PERFORM
check_sql_expr(new->expr->query, new->expr->parseMode, check_sql_expr(new->expr->query, new->expr->parseMode,
startloc + 1); startloc + 1);
$$ = (PLpgSQL_stmt *)new; $$ = (PLpgSQL_stmt *) new;
} }
; ;
@ -951,7 +952,7 @@ stmt_call : K_CALL
/* Remember we may need a procedure resource owner */ /* Remember we may need a procedure resource owner */
plpgsql_curr_compile->requires_procedure_resowner = true; plpgsql_curr_compile->requires_procedure_resowner = true;
$$ = (PLpgSQL_stmt *)new; $$ = (PLpgSQL_stmt *) new;
} }
| K_DO | K_DO
@ -970,7 +971,7 @@ stmt_call : K_CALL
/* Remember we may need a procedure resource owner */ /* Remember we may need a procedure resource owner */
plpgsql_curr_compile->requires_procedure_resowner = true; plpgsql_curr_compile->requires_procedure_resowner = true;
$$ = (PLpgSQL_stmt *)new; $$ = (PLpgSQL_stmt *) new;
} }
; ;
@ -1010,7 +1011,7 @@ stmt_assign : T_DATUM
false, true, true, false, true, true,
NULL, NULL); NULL, NULL);
$$ = (PLpgSQL_stmt *)new; $$ = (PLpgSQL_stmt *) new;
} }
; ;
@ -1072,7 +1073,7 @@ stmt_getdiag : K_GET getdiag_area_opt K_DIAGNOSTICS getdiag_list ';'
} }
} }
$$ = (PLpgSQL_stmt *)new; $$ = (PLpgSQL_stmt *) new;
} }
; ;
@ -1200,7 +1201,7 @@ stmt_if : K_IF expr_until_then proc_sect stmt_elsifs stmt_else K_END K_IF ';'
new->elsif_list = $4; new->elsif_list = $4;
new->else_body = $5; new->else_body = $5;
$$ = (PLpgSQL_stmt *)new; $$ = (PLpgSQL_stmt *) new;
} }
; ;
@ -1306,7 +1307,7 @@ stmt_loop : opt_loop_label K_LOOP loop_body
check_labels($1, $3.end_label, $3.end_label_location); check_labels($1, $3.end_label, $3.end_label_location);
plpgsql_ns_pop(); plpgsql_ns_pop();
$$ = (PLpgSQL_stmt *)new; $$ = (PLpgSQL_stmt *) new;
} }
; ;
@ -1325,7 +1326,7 @@ stmt_while : opt_loop_label K_WHILE expr_until_loop loop_body
check_labels($1, $4.end_label, $4.end_label_location); check_labels($1, $4.end_label, $4.end_label_location);
plpgsql_ns_pop(); plpgsql_ns_pop();
$$ = (PLpgSQL_stmt *)new; $$ = (PLpgSQL_stmt *) new;
} }
; ;
@ -1766,7 +1767,7 @@ stmt_exit : exit_type opt_label opt_exitcond
parser_errposition(@1))); parser_errposition(@1)));
} }
$$ = (PLpgSQL_stmt *)new; $$ = (PLpgSQL_stmt *) new;
} }
; ;
@ -1947,7 +1948,7 @@ stmt_raise : K_RAISE
check_raise_parameters(new); check_raise_parameters(new);
$$ = (PLpgSQL_stmt *)new; $$ = (PLpgSQL_stmt *) new;
} }
; ;
@ -2088,7 +2089,7 @@ stmt_dynexecute : K_EXECUTE
yyerror("syntax error"); yyerror("syntax error");
} }
$$ = (PLpgSQL_stmt *)new; $$ = (PLpgSQL_stmt *) new;
} }
; ;
@ -2167,7 +2168,7 @@ stmt_open : K_OPEN cursor_variable
new->argquery = read_cursor_args($2, ';'); new->argquery = read_cursor_args($2, ';');
} }
$$ = (PLpgSQL_stmt *)new; $$ = (PLpgSQL_stmt *) new;
} }
; ;
@ -2197,7 +2198,7 @@ stmt_fetch : K_FETCH opt_fetch_direction cursor_variable K_INTO
fetch->curvar = $3->dno; fetch->curvar = $3->dno;
fetch->is_move = false; fetch->is_move = false;
$$ = (PLpgSQL_stmt *)fetch; $$ = (PLpgSQL_stmt *) fetch;
} }
; ;
@ -2209,7 +2210,7 @@ stmt_move : K_MOVE opt_fetch_direction cursor_variable ';'
fetch->curvar = $3->dno; fetch->curvar = $3->dno;
fetch->is_move = true; fetch->is_move = true;
$$ = (PLpgSQL_stmt *)fetch; $$ = (PLpgSQL_stmt *) fetch;
} }
; ;
@ -2229,7 +2230,7 @@ stmt_close : K_CLOSE cursor_variable ';'
new->stmtid = ++plpgsql_curr_compile->nstatements; new->stmtid = ++plpgsql_curr_compile->nstatements;
new->curvar = $2->dno; new->curvar = $2->dno;
$$ = (PLpgSQL_stmt *)new; $$ = (PLpgSQL_stmt *) new;
} }
; ;
@ -2250,7 +2251,7 @@ stmt_commit : K_COMMIT opt_transaction_chain ';'
new->stmtid = ++plpgsql_curr_compile->nstatements; new->stmtid = ++plpgsql_curr_compile->nstatements;
new->chain = $2; new->chain = $2;
$$ = (PLpgSQL_stmt *)new; $$ = (PLpgSQL_stmt *) new;
} }
; ;
@ -2264,7 +2265,7 @@ stmt_rollback : K_ROLLBACK opt_transaction_chain ';'
new->stmtid = ++plpgsql_curr_compile->nstatements; new->stmtid = ++plpgsql_curr_compile->nstatements;
new->chain = $2; new->chain = $2;
$$ = (PLpgSQL_stmt *)new; $$ = (PLpgSQL_stmt *) new;
} }
; ;
@ -3587,7 +3588,7 @@ read_into_scalar_list(char *initial_name,
row->varnos[nfields] = varnos[nfields]; row->varnos[nfields] = varnos[nfields];
} }
plpgsql_adddatum((PLpgSQL_datum *)row); plpgsql_adddatum((PLpgSQL_datum *) row);
return row; return row;
} }
@ -3619,7 +3620,7 @@ make_scalar_list1(char *initial_name,
row->fieldnames[0] = initial_name; row->fieldnames[0] = initial_name;
row->varnos[0] = initial_datum->dno; row->varnos[0] = initial_datum->dno;
plpgsql_adddatum((PLpgSQL_datum *)row); plpgsql_adddatum((PLpgSQL_datum *) row);
return row; return row;
} }