Skip to content

Commit 7c30ae1

Browse files
committed
reformat, stage 2
1 parent c0a7ab0 commit 7c30ae1

File tree

3 files changed

+110
-76
lines changed

3 files changed

+110
-76
lines changed

src/backend/tsearch/wparser_def.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2054,7 +2054,7 @@ checkcondition_HL(void *opaque, QueryOperand *val, ExecPhraseData *data)
20542054
}
20552055
}
20562056

2057-
if ( data && data->npos > 0 )
2057+
if (data && data->npos > 0)
20582058
return true;
20592059

20602060
return false;

src/backend/utils/adt/tsquery.c

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -107,24 +107,24 @@ static char *
107107
get_phrase_distance(char *buf, int16 *distance)
108108
{
109109
char *ptr = buf;
110-
long l;
111110
char *endptr;
111+
long l;
112112

113113
*distance = 1;
114114

115-
while( ptr && t_isspace(ptr) )
115+
while (ptr && t_isspace(ptr))
116116
ptr += pg_mblen(ptr);
117117

118-
if ( !t_iseq(ptr, '[') )
118+
if (!t_iseq(ptr, '['))
119119
return buf;
120120
ptr++;
121121

122-
while( *ptr && t_isspace(ptr) )
122+
while (*ptr && t_isspace(ptr))
123123
ptr += pg_mblen(ptr);
124124

125125
l = strtol(ptr, &endptr, 10);
126126

127-
if ( ptr == endptr )
127+
if (ptr == endptr)
128128
return buf;
129129

130130
if (errno == ERANGE || l < 0 || l > MAXENTRYPOS)
@@ -135,14 +135,14 @@ get_phrase_distance(char *buf, int16 *distance)
135135

136136
ptr = endptr;
137137

138-
while( *ptr && t_isspace(ptr) )
138+
while (*ptr && t_isspace(ptr))
139139
ptr += pg_mblen(ptr);
140140

141-
if ( !t_iseq(ptr, ']') )
141+
if (!t_iseq(ptr, ']'))
142142
return buf;
143143
ptr++;
144144

145-
*distance = (int16)l;
145+
*distance = (int16) l;
146146
return ptr;
147147
}
148148

@@ -243,7 +243,8 @@ gettoken_query(TSQueryParserState state,
243243
state->state = WAITOPERAND;
244244
*operator = OP_PHRASE;
245245
(state->buf)++;
246-
state->buf = get_phrase_distance(state->buf, weight /* use as storage for distance */);
246+
state->buf = get_phrase_distance(state->buf,
247+
weight); /* use as storage for distance */
247248
return PT_OPR;
248249
}
249250
else if (t_iseq(state->buf, ')'))
@@ -281,7 +282,7 @@ pushOperator(TSQueryParserState state, int8 oper, int16 distance)
281282
{
282283
QueryOperator *tmp;
283284

284-
Assert(oper == OP_NOT || oper == OP_AND || oper == OP_OR || oper == OP_PHRASE );
285+
Assert(oper == OP_NOT || oper == OP_AND || oper == OP_OR || oper == OP_PHRASE);
285286

286287
tmp = (QueryOperator *) palloc0(sizeof(QueryOperator));
287288
tmp->type = QI_OPR;
@@ -413,7 +414,9 @@ makepol(TSQueryParserState state,
413414
opstack[lenstack - 1].op == OP_NOT))
414415
{
415416
lenstack--;
416-
pushOperator(state, opstack[lenstack].op, opstack[lenstack].distance);
417+
pushOperator(state,
418+
opstack[lenstack].op,
419+
opstack[lenstack].distance);
417420
}
418421
break;
419422
case PT_OPR:
@@ -436,14 +439,18 @@ makepol(TSQueryParserState state,
436439
opstack[lenstack - 1].op == OP_NOT))
437440
{
438441
lenstack--;
439-
pushOperator(state, opstack[lenstack].op, opstack[lenstack].distance);
442+
pushOperator(state,
443+
opstack[lenstack].op,
444+
opstack[lenstack].distance);
440445
}
441446
break;
442447
case PT_CLOSE:
443448
while (lenstack)
444449
{
445450
lenstack--;
446-
pushOperator(state, opstack[lenstack].op, opstack[lenstack].distance);
451+
pushOperator(state,
452+
opstack[lenstack].op,
453+
opstack[lenstack].distance);
447454
};
448455
return;
449456
case PT_ERR:
@@ -457,7 +464,9 @@ makepol(TSQueryParserState state,
457464
while (lenstack)
458465
{
459466
lenstack--;
460-
pushOperator(state, opstack[lenstack].op, opstack[lenstack].distance);
467+
pushOperator(state,
468+
opstack[lenstack].op,
469+
opstack[lenstack].distance);
461470
}
462471
}
463472

@@ -494,7 +503,9 @@ findoprnd_recurse(QueryItem *ptr, uint32 *pos, int nnodes, bool *needcleanup)
494503
QueryOperator *curitem = &ptr[*pos].qoperator;
495504
int tmp = *pos;
496505

497-
Assert(curitem->oper == OP_AND || curitem->oper == OP_OR || curitem->oper == OP_PHRASE );
506+
Assert(curitem->oper == OP_AND ||
507+
curitem->oper == OP_OR ||
508+
curitem->oper == OP_PHRASE);
498509

499510
if ( curitem->oper == OP_PHRASE )
500511
*needcleanup = true;
@@ -751,7 +762,7 @@ infix(INFIX *in, int parentPriority)
751762
}
752763
else if (in->curpol->qoperator.oper == OP_NOT)
753764
{
754-
int priority = PRINT_PRIORITY(in->curpol);
765+
int priority = PRINT_PRIORITY(in->curpol);
755766

756767
if (priority < parentPriority)
757768
{
@@ -783,9 +794,9 @@ infix(INFIX *in, int parentPriority)
783794

784795
in->curpol++;
785796
if (priority < parentPriority ||
786-
( op == OP_PHRASE &&
787-
( priority == parentPriority /* phrase are not commutative! */ ||
788-
parentPriority == OP_PRIORITY(OP_AND) )))
797+
(op == OP_PHRASE &&
798+
(priority == parentPriority || /* phrases are not commutative! */
799+
parentPriority == OP_PRIORITY(OP_AND))))
789800
{
790801
needParenthesis = true;
791802
RESIZEBUF(in, 2);
@@ -806,7 +817,7 @@ infix(INFIX *in, int parentPriority)
806817
infix(in, priority);
807818

808819
/* print operator & right operand */
809-
RESIZEBUF(in, 3 + ( 2 + 10 /*distance */ ) + (nrm.cur - nrm.buf));
820+
RESIZEBUF(in, 3 + (2 + 10 /* distance */) + (nrm.cur - nrm.buf));
810821
switch (op)
811822
{
812823
case OP_OR:
@@ -816,7 +827,7 @@ infix(INFIX *in, int parentPriority)
816827
sprintf(in->cur, " & %s", nrm.buf);
817828
break;
818829
case OP_PHRASE:
819-
if ( distance != 1 )
830+
if (distance != 1)
820831
sprintf(in->cur, " ?[%d] %s", distance, nrm.buf);
821832
else
822833
sprintf(in->cur, " ? %s", nrm.buf);
@@ -903,7 +914,7 @@ tsquerysend(PG_FUNCTION_ARGS)
903914
break;
904915
case QI_OPR:
905916
pq_sendint(&buf, item->qoperator.oper, sizeof(item->qoperator.oper));
906-
if ( item->qoperator.oper == OP_PHRASE )
917+
if (item->qoperator.oper == OP_PHRASE)
907918
pq_sendint(&buf, item->qoperator.distance, sizeof(item->qoperator.distance));
908919
break;
909920
default:
@@ -920,16 +931,16 @@ tsquerysend(PG_FUNCTION_ARGS)
920931
Datum
921932
tsqueryrecv(PG_FUNCTION_ARGS)
922933
{
923-
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
924-
TSQuery query;
925-
int i,
926-
len;
927-
QueryItem *item;
928-
int datalen;
929-
char *ptr;
930-
uint32 size;
931-
const char **operands;
932-
bool needcleanup;
934+
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
935+
TSQuery query;
936+
int i,
937+
len;
938+
QueryItem *item;
939+
int datalen;
940+
char *ptr;
941+
uint32 size;
942+
const char **operands;
943+
bool needcleanup;
933944

934945
size = pq_getmsgint(buf, sizeof(uint32));
935946
if (size > (MaxAllocSize / sizeof(QueryItem)))
@@ -1006,7 +1017,7 @@ tsqueryrecv(PG_FUNCTION_ARGS)
10061017

10071018
item->qoperator.oper = oper;
10081019
if (oper == OP_PHRASE)
1009-
item->qoperator.distance = (int16)pq_getmsgint(buf, sizeof(int16));
1020+
item->qoperator.distance = (int16) pq_getmsgint(buf, sizeof(int16));
10101021
}
10111022
else
10121023
elog(ERROR, "unrecognized tsquery node type: %d", item->type);

0 commit comments

Comments
 (0)