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

Commitb43fd16

Browse files
committed
I notice that contrib/fuzzystrmatch/dmetaphone.c doesn't compile cleanly
as it stands - it mixes declarations in code, C++-style. The attachedpatch shifts declarations to the tops of functions and enables this fileto compile cleanly as C.Richard Poole
1 parenta9ed747 commitb43fd16

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

‎contrib/fuzzystrmatch/dmetaphone.c

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848

4949

5050
/*
51-
* $Revision: 1.1 $
52-
* $Id: dmetaphone.c,v 1.1 2004/07/01 03:25:48 joe Exp $
51+
* $Revision: 1.2 $
52+
* $Id: dmetaphone.c,v 1.2 2004/08/20 19:48:14 momjian Exp $
5353
*/
5454

5555

@@ -138,12 +138,16 @@ PG_FUNCTION_INFO_V1(dmetaphone);
138138
Datum
139139
dmetaphone(PG_FUNCTION_ARGS)
140140
{
141+
text*arg,*result;
142+
intalen,rsize;
143+
char*aptr,*codes[2],*code,*rptr;
144+
141145
#ifdefDMETAPHONE_NOSTRICT
142146
if (PG_ARGISNULL(0))
143147
PG_RETURNNULL();
144148
#endif
145-
text*arg=PG_GETARG_TEXT_P(0);
146-
intalen=VARSIZE(arg)-VARHDRSZ;
149+
arg=PG_GETARG_TEXT_P(0);
150+
alen=VARSIZE(arg)-VARHDRSZ;
147151

148152
/*
149153
* Postgres' string values might not have trailing nuls.
@@ -153,18 +157,17 @@ dmetaphone(PG_FUNCTION_ARGS)
153157
* (and we don't make space for it).
154158
*/
155159

156-
char*aptr=palloc(alen+1);
160+
aptr=palloc(alen+1);
157161
memcpy(aptr,VARDATA(arg),alen);
158162
aptr[alen]=0;
159-
char*codes[2];
160163
DoubleMetaphone(aptr,codes);
161-
char*code=codes[0];
164+
code=codes[0];
162165
if (!code)
163166
code="";
164-
intrsize=VARHDRSZ+strlen(code) ;
165-
text*result= (text*)palloc(rsize);
167+
rsize=VARHDRSZ+strlen(code) ;
168+
result= (text*)palloc(rsize);
166169
memset(result,0,rsize);
167-
char*rptr=VARDATA(result);
170+
rptr=VARDATA(result);
168171
memcpy(rptr,code,strlen(code));
169172
VARATT_SIZEP(result)=rsize;
170173
PG_RETURN_TEXT_P(result);
@@ -180,24 +183,27 @@ PG_FUNCTION_INFO_V1(dmetaphone_alt);
180183
Datum
181184
dmetaphone_alt(PG_FUNCTION_ARGS)
182185
{
186+
text*arg,*result;
187+
intalen,rsize;
188+
char*aptr,*codes[2],*code,*rptr;
189+
183190
#ifdefDMETAPHONE_NOSTRICT
184191
if (PG_ARGISNULL(0))
185192
PG_RETURNNULL();
186193
#endif
187-
text*arg=PG_GETARG_TEXT_P(0);
188-
intalen=VARSIZE(arg)-VARHDRSZ;
189-
char*aptr=palloc(alen+1);
190-
memcpy(aptr,VARDATA(arg),alen);
194+
arg=PG_GETARG_TEXT_P(0);
195+
alen=VARSIZE(arg)-VARHDRSZ;
196+
aptr=palloc(alen+1);
197+
memcpy(aptr,VARDATA(arg),alen);
191198
aptr[alen]=0;
192-
char*codes[2];
193199
DoubleMetaphone(aptr,codes);
194-
char*code=codes[1];
200+
code=codes[1];
195201
if (!code)
196202
code="";
197-
intrsize=VARHDRSZ+strlen(code) ;
198-
text*result= (text*)palloc(rsize);
203+
rsize=VARHDRSZ+strlen(code) ;
204+
result= (text*)palloc(rsize);
199205
memset(result,0,rsize);
200-
char*rptr=VARDATA(result);
206+
rptr=VARDATA(result);
201207
memcpy(rptr,code,strlen(code));
202208
VARATT_SIZEP(result)=rsize;
203209
PG_RETURN_TEXT_P(result);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp