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

Commit58640f3

Browse files
committed
Remove useless character-length checks in contrib/ltree.
The t_iseq() macro does not need to be guarded by a characterlength check (at least when the comparison value is an ASCIIcharacter, as its documentation requires). Some portions ofcontrib/ltree hadn't read that memo, so simplify them.The last change in gettoken_query,- else if (charlen == 1 && !t_iseq(state->buf, ' '))+ else if (!t_iseq(state->buf, ' '))looks like it's actually a bug fix: I doubt that the intentionwas to silently ignore multibyte characters as if they werewhitespace. I'm not tempted to back-patch though, because thiswill have the effect of tightening what is allowed in ltxtquerystrings.Discussion:https://postgr.es/m/2548310.1664999615@sss.pgh.pa.us
1 parentca71131 commit58640f3

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

‎contrib/ltree/lquery_op.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,16 @@ static char *
2525
getlexeme(char*start,char*end,int*len)
2626
{
2727
char*ptr;
28-
intcharlen;
2928

30-
while (start<end&&(charlen=pg_mblen(start))==1&&t_iseq(start,'_'))
31-
start+=charlen;
29+
while (start<end&&t_iseq(start,'_'))
30+
start+=pg_mblen(start);
3231

3332
ptr=start;
3433
if (ptr >=end)
3534
returnNULL;
3635

37-
while (ptr<end&& !((charlen=pg_mblen(ptr))==1&&t_iseq(ptr,'_')))
38-
ptr+=charlen;
36+
while (ptr<end&& !t_iseq(ptr,'_'))
37+
ptr+=pg_mblen(ptr);
3938

4039
*len=ptr-start;
4140
returnstart;

‎contrib/ltree/ltree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ typedef struct
126126

127127
#defineLQUERY_HASNOT0x01
128128

129-
#defineISALNUM(x)( t_isalnum(x) ||( pg_mblen(x) == 1 &&t_iseq((x), '_')) )
129+
#defineISALNUM(x)( t_isalnum(x) || t_iseq(x, '_') )
130130

131131
/* full text query */
132132

‎contrib/ltree/ltxtquery_io.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ gettoken_query(QPRS_STATE *state, int32 *val, int32 *lenval, char **strval, uint
6464
switch (state->state)
6565
{
6666
caseWAITOPERAND:
67-
if (charlen==1&&t_iseq(state->buf,'!'))
67+
if (t_iseq(state->buf,'!'))
6868
{
6969
(state->buf)++;
7070
*val= (int32)'!';
7171
returnOPR;
7272
}
73-
elseif (charlen==1&&t_iseq(state->buf,'('))
73+
elseif (t_iseq(state->buf,'('))
7474
{
7575
state->count++;
7676
(state->buf)++;
@@ -97,11 +97,11 @@ gettoken_query(QPRS_STATE *state, int32 *val, int32 *lenval, char **strval, uint
9797
errmsg("modifiers syntax error")));
9898
*lenval+=charlen;
9999
}
100-
elseif (charlen==1&&t_iseq(state->buf,'%'))
100+
elseif (t_iseq(state->buf,'%'))
101101
*flag |=LVAR_SUBLEXEME;
102-
elseif (charlen==1&&t_iseq(state->buf,'@'))
102+
elseif (t_iseq(state->buf,'@'))
103103
*flag |=LVAR_INCASE;
104-
elseif (charlen==1&&t_iseq(state->buf,'*'))
104+
elseif (t_iseq(state->buf,'*'))
105105
*flag |=LVAR_ANYEND;
106106
else
107107
{
@@ -110,22 +110,22 @@ gettoken_query(QPRS_STATE *state, int32 *val, int32 *lenval, char **strval, uint
110110
}
111111
break;
112112
caseWAITOPERATOR:
113-
if (charlen==1&& (t_iseq(state->buf,'&')||t_iseq(state->buf,'|')))
113+
if (t_iseq(state->buf,'&')||t_iseq(state->buf,'|'))
114114
{
115115
state->state=WAITOPERAND;
116116
*val= (int32)*(state->buf);
117117
(state->buf)++;
118118
returnOPR;
119119
}
120-
elseif (charlen==1&&t_iseq(state->buf,')'))
120+
elseif (t_iseq(state->buf,')'))
121121
{
122122
(state->buf)++;
123123
state->count--;
124124
return (state->count<0) ?ERR :CLOSE;
125125
}
126126
elseif (*(state->buf)=='\0')
127127
return (state->count) ?ERR :END;
128-
elseif (charlen==1&&!t_iseq(state->buf,' '))
128+
elseif (!t_iseq(state->buf,' '))
129129
returnERR;
130130
break;
131131
default:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp