summaryrefslogtreecommitdiff
path: root/contrib/fuzzystrmatch
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2005-10-15 02:49:52 +0000
committerBruce Momjian <bruce@momjian.us>2005-10-15 02:49:52 +0000
commit1dc34982511d91ef8a2b71bdcb870f067c1b3da9 (patch)
tree1046adab1d4b964e0c38afeec0ee6546f61d9a8a /contrib/fuzzystrmatch
parent790c01d28099587bbe2c623d4389b62ee49b1dee (diff)
downloadpostgresql-1dc34982511d91ef8a2b71bdcb870f067c1b3da9.tar.gz
Standard pgindent run for 8.1.
Diffstat (limited to 'contrib/fuzzystrmatch')
-rw-r--r--contrib/fuzzystrmatch/dmetaphone.c71
-rw-r--r--contrib/fuzzystrmatch/fuzzystrmatch.c73
2 files changed, 71 insertions, 73 deletions
diff --git a/contrib/fuzzystrmatch/dmetaphone.c b/contrib/fuzzystrmatch/dmetaphone.c
index c8d9c8979b..216f39b7a7 100644
--- a/contrib/fuzzystrmatch/dmetaphone.c
+++ b/contrib/fuzzystrmatch/dmetaphone.c
@@ -48,8 +48,8 @@
/*
- * $Revision: 1.5 $
- * $Id: dmetaphone.c,v 1.5 2005/09/30 22:38:44 momjian Exp $
+ * $Revision: 1.6 $
+ * $Id: dmetaphone.c,v 1.6 2005/10/15 02:49:05 momjian Exp $
*/
@@ -154,10 +154,10 @@ dmetaphone(PG_FUNCTION_ARGS)
alen = VARSIZE(arg) - VARHDRSZ;
/*
- * Postgres' string values might not have trailing nuls. The VARSIZE
- * will not include the nul in any case so we copy things out and add
- * a trailing nul. When we copy back we ignore the nul (and we don't
- * make space for it).
+ * Postgres' string values might not have trailing nuls. The VARSIZE will
+ * not include the nul in any case so we copy things out and add a
+ * trailing nul. When we copy back we ignore the nul (and we don't make
+ * space for it).
*/
aptr = palloc(alen + 1);
@@ -236,7 +236,6 @@ dmetaphone_alt(PG_FUNCTION_ARGS)
*/
#define META_FREE(x) /* pfree((x)) */
-
#else /* not defined DMETAPHONE_MAIN */
/* use the standard malloc library when not running in PostgreSQL */
@@ -512,8 +511,8 @@ DoubleMetaphone(char *str, char **codes)
&& StringAt(original, (current - 1), 3, "ACH", "")
&& ((GetAt(original, current + 2) != 'I')
&& ((GetAt(original, current + 2) != 'E')
- || StringAt(original, (current - 2), 6, "BACHER",
- "MACHER", ""))))
+ || StringAt(original, (current - 2), 6, "BACHER",
+ "MACHER", ""))))
{
MetaphAdd(primary, "K");
MetaphAdd(secondary, "K");
@@ -582,9 +581,9 @@ DoubleMetaphone(char *str, char **codes)
/*
* e.g., 'wachtler', 'wechsler', but not 'tichner'
*/
- && StringAt(original, (current + 2), 1, "L", "R",
- "N", "M", "B", "H", "F", "V", "W",
- " ", "")))
+ && StringAt(original, (current + 2), 1, "L", "R",
+ "N", "M", "B", "H", "F", "V", "W",
+ " ", "")))
{
MetaphAdd(primary, "K");
MetaphAdd(secondary, "K");
@@ -639,14 +638,14 @@ DoubleMetaphone(char *str, char **codes)
{
/* 'bellocchio' but not 'bacchus' */
if (StringAt(original, (current + 2), 1, "I", "E", "H", "")
- && !StringAt(original, (current + 2), 2, "HU", ""))
+ && !StringAt(original, (current + 2), 2, "HU", ""))
{
/* 'accident', 'accede' 'succeed' */
if (
((current == 1)
&& (GetAt(original, current - 1) == 'A'))
- || StringAt(original, (current - 1), 5, "UCCEE",
- "UCCES", ""))
+ || StringAt(original, (current - 1), 5, "UCCEE",
+ "UCCES", ""))
{
MetaphAdd(primary, "KS");
MetaphAdd(secondary, "KS");
@@ -787,8 +786,8 @@ DoubleMetaphone(char *str, char **codes)
}
/*
- * Parker's rule (with some further refinements) -
- * e.g., 'hugh'
+ * Parker's rule (with some further refinements) - e.g.,
+ * 'hugh'
*/
if (
((current > 1)
@@ -873,9 +872,9 @@ DoubleMetaphone(char *str, char **codes)
/* -ges-,-gep-,-gel-, -gie- at beginning */
if ((current == 0)
&& ((GetAt(original, current + 1) == 'Y')
- || StringAt(original, (current + 1), 2, "ES", "EP",
- "EB", "EL", "EY", "IB", "IL", "IN", "IE",
- "EI", "ER", "")))
+ || StringAt(original, (current + 1), 2, "ES", "EP",
+ "EB", "EL", "EY", "IB", "IL", "IN", "IE",
+ "EI", "ER", "")))
{
MetaphAdd(primary, "K");
MetaphAdd(secondary, "J");
@@ -1002,7 +1001,7 @@ DoubleMetaphone(char *str, char **codes)
else
{
if (!StringAt(original, (current + 1), 1, "L", "T",
- "K", "S", "N", "M", "B", "Z", "")
+ "K", "S", "N", "M", "B", "Z", "")
&& !StringAt(original, (current - 1), 1,
"S", "K", "L", ""))
{
@@ -1035,10 +1034,10 @@ DoubleMetaphone(char *str, char **codes)
if (((current == (length - 3))
&& StringAt(original, (current - 1), 4, "ILLO",
"ILLA", "ALLE", ""))
- || ((StringAt(original, (last - 1), 2, "AS", "OS", "")
- || StringAt(original, last, 1, "A", "O", ""))
- && StringAt(original, (current - 1), 4,
- "ALLE", "")))
+ || ((StringAt(original, (last - 1), 2, "AS", "OS", "")
+ || StringAt(original, last, 1, "A", "O", ""))
+ && StringAt(original, (current - 1), 4,
+ "ALLE", "")))
{
MetaphAdd(primary, "L");
MetaphAdd(secondary, "");
@@ -1056,7 +1055,7 @@ DoubleMetaphone(char *str, char **codes)
case 'M':
if ((StringAt(original, (current - 1), 3, "UMB", "")
&& (((current + 1) == last)
- || StringAt(original, (current + 2), 2, "ER", "")))
+ || StringAt(original, (current + 2), 2, "ER", "")))
/* 'dumb','thumb' */
|| (GetAt(original, current + 1) == 'M'))
current += 2;
@@ -1113,7 +1112,7 @@ DoubleMetaphone(char *str, char **codes)
if ((current == last)
&& !SlavoGermanic(original)
&& StringAt(original, (current - 2), 2, "IE", "")
- && !StringAt(original, (current - 4), 2, "ME", "MA", ""))
+ && !StringAt(original, (current - 4), 2, "ME", "MA", ""))
{
MetaphAdd(primary, "");
MetaphAdd(secondary, "R");
@@ -1152,8 +1151,8 @@ DoubleMetaphone(char *str, char **codes)
{
/* germanic */
if (StringAt
- (original, (current + 1), 4, "HEIM", "HOEK", "HOLM",
- "HOLZ", ""))
+ (original, (current + 1), 4, "HEIM", "HOEK", "HOLM",
+ "HOLZ", ""))
{
MetaphAdd(primary, "S");
MetaphAdd(secondary, "S");
@@ -1187,8 +1186,8 @@ DoubleMetaphone(char *str, char **codes)
/*
* german & anglicisations, e.g. 'smith' match 'schmidt',
- * 'snider' match 'schneider' also, -sz- in slavic
- * language although in hungarian it is pronounced 's'
+ * 'snider' match 'schneider' also, -sz- in slavic language
+ * although in hungarian it is pronounced 's'
*/
if (((current == 0)
&& StringAt(original, (current + 1), 1,
@@ -1264,7 +1263,7 @@ DoubleMetaphone(char *str, char **codes)
/* french e.g. 'resnais', 'artois' */
if ((current == last)
- && StringAt(original, (current - 2), 2, "AI", "OI", ""))
+ && StringAt(original, (current - 2), 2, "AI", "OI", ""))
{
MetaphAdd(primary, "");
MetaphAdd(secondary, "S");
@@ -1365,8 +1364,8 @@ DoubleMetaphone(char *str, char **codes)
/* Arnow should match Arnoff */
if (((current == last) && IsVowel(original, current - 1))
- || StringAt(original, (current - 1), 5, "EWSKI", "EWSKY",
- "OWSKI", "OWSKY", "")
+ || StringAt(original, (current - 1), 5, "EWSKI", "EWSKY",
+ "OWSKI", "OWSKY", "")
|| StringAt(original, 0, 3, "SCH", ""))
{
MetaphAdd(primary, "");
@@ -1442,8 +1441,8 @@ DoubleMetaphone(char *str, char **codes)
}
/*
- * printf("PRIMARY: %s\n", primary->str); printf("SECONDARY:
- * %s\n", secondary->str);
+ * printf("PRIMARY: %s\n", primary->str); printf("SECONDARY: %s\n",
+ * secondary->str);
*/
}
diff --git a/contrib/fuzzystrmatch/fuzzystrmatch.c b/contrib/fuzzystrmatch/fuzzystrmatch.c
index 8ffc02ffa3..e76e5038c2 100644
--- a/contrib/fuzzystrmatch/fuzzystrmatch.c
+++ b/contrib/fuzzystrmatch/fuzzystrmatch.c
@@ -65,10 +65,10 @@ levenshtein(PG_FUNCTION_ARGS)
int j;
/*
- * Fetch the arguments. str_s is referred to as the "source" cols =
- * length of source + 1 to allow for the initialization column str_t
- * is referred to as the "target", rows = length of target + 1 rows =
- * length of target + 1 to allow for the initialization row
+ * Fetch the arguments. str_s is referred to as the "source" cols = length
+ * of source + 1 to allow for the initialization column str_t is referred
+ * to as the "target", rows = length of target + 1 rows = length of target
+ * + 1 to allow for the initialization row
*/
str_s = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(PG_GETARG_TEXT_P(0))));
str_t = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(PG_GETARG_TEXT_P(1))));
@@ -78,10 +78,9 @@ levenshtein(PG_FUNCTION_ARGS)
/*
* Restrict the length of the strings being compared to something
- * reasonable because we will have to perform rows * cols
- * calculations. If longer strings need to be compared, increase
- * MAX_LEVENSHTEIN_STRLEN to suit (but within your tolerance for speed
- * and memory usage).
+ * reasonable because we will have to perform rows * cols calculations. If
+ * longer strings need to be compared, increase MAX_LEVENSHTEIN_STRLEN to
+ * suit (but within your tolerance for speed and memory usage).
*/
if ((cols > MAX_LEVENSHTEIN_STRLEN + 1) || (rows > MAX_LEVENSHTEIN_STRLEN + 1))
ereport(ERROR,
@@ -90,9 +89,9 @@ levenshtein(PG_FUNCTION_ARGS)
MAX_LEVENSHTEIN_STRLEN)));
/*
- * If either rows or cols is 0, the answer is the other value. This
- * makes sense since it would take that many insertions the build a
- * matching string
+ * If either rows or cols is 0, the answer is the other value. This makes
+ * sense since it would take that many insertions the build a matching
+ * string
*/
if (cols == 0)
@@ -102,9 +101,8 @@ levenshtein(PG_FUNCTION_ARGS)
PG_RETURN_INT32(cols);
/*
- * Allocate two vectors of integers. One will be used for the "upper"
- * row, the other for the "lower" row. Initialize the "upper" row to
- * 0..cols
+ * Allocate two vectors of integers. One will be used for the "upper" row,
+ * the other for the "lower" row. Initialize the "upper" row to 0..cols
*/
u_cells = palloc(sizeof(int) * cols);
for (i = 0; i < cols; i++)
@@ -119,14 +117,13 @@ levenshtein(PG_FUNCTION_ARGS)
str_s0 = str_s;
/*
- * Loop through the rows, starting at row 1. Row 0 is used for the
- * initial "upper" row.
+ * Loop through the rows, starting at row 1. Row 0 is used for the initial
+ * "upper" row.
*/
for (j = 1; j < rows; j++)
{
/*
- * We'll always start with col 1, and initialize lower row col 0
- * to j
+ * We'll always start with col 1, and initialize lower row col 0 to j
*/
l_cells[0] = j;
@@ -140,8 +137,7 @@ levenshtein(PG_FUNCTION_ARGS)
/*
* The "cost" value is 0 if the character at the current col
* position in the source string, matches the character at the
- * current row position in the target string; cost is 1
- * otherwise.
+ * current row position in the target string; cost is 1 otherwise.
*/
c = ((CHAREQ(str_s, str_t)) ? 0 : 1);
@@ -172,8 +168,8 @@ levenshtein(PG_FUNCTION_ARGS)
}
/*
- * Lower row now becomes the upper row, and the upper row gets
- * reused as the new lower row.
+ * Lower row now becomes the upper row, and the upper row gets reused
+ * as the new lower row.
*/
tmp = u_cells;
u_cells = l_cells;
@@ -301,8 +297,8 @@ Lookahead(char *word, int how_far)
for (idx = 0; word[idx] != '\0' && idx < how_far; idx++);
/* Edge forward in the string... */
- letter_ahead = word[idx]; /* idx will be either == to how_far or at
- * the end of the string */
+ letter_ahead = word[idx]; /* idx will be either == to how_far or at the
+ * end of the string */
return letter_ahead;
}
@@ -453,11 +449,11 @@ _metaphone(
/*
- * THOUGHT: It would be nice if, rather than having things
- * like... well, SCI. For SCI you encode the S, then have to
- * remember to skip the C. So the phonome SCI invades both S and
- * C. It would be better, IMHO, to skip the C from the S part of
- * the encoding. Hell, I'm trying it.
+ * THOUGHT: It would be nice if, rather than having things like...
+ * well, SCI. For SCI you encode the S, then have to remember to skip
+ * the C. So the phonome SCI invades both S and C. It would be
+ * better, IMHO, to skip the C from the S part of the encoding. Hell,
+ * I'm trying it.
*/
/* Ignore non-alphas */
@@ -478,9 +474,9 @@ _metaphone(
break;
/*
- * 'sh' if -CIA- or -CH, but not SCH, except SCHW. (SCHW
- * is handled in S) S if -CI-, -CE- or -CY- dropped if
- * -SCI-, SCE-, -SCY- (handed in S) else K
+ * 'sh' if -CIA- or -CH, but not SCH, except SCHW. (SCHW is
+ * handled in S) S if -CI-, -CE- or -CY- dropped if -SCI-,
+ * SCE-, -SCY- (handed in S) else K
*/
case 'C':
if (MAKESOFT(Next_Letter))
@@ -534,8 +530,8 @@ _metaphone(
/*
* F if in -GH and not B--GH, D--GH, -H--GH, -H---GH else
* dropped if -GNED, -GN, else dropped if -DGE-, -DGI- or
- * -DGY- (handled in D) else J if in -GE-, -GI, -GY and
- * not GG else K
+ * -DGY- (handled in D) else J if in -GE-, -GI, -GY and not GG
+ * else K
*/
case 'G':
if (Next_Letter == 'H')
@@ -761,14 +757,17 @@ PG_FUNCTION_INFO_V1(difference);
Datum
difference(PG_FUNCTION_ARGS)
{
- char sndx1[SOUNDEX_LEN+1], sndx2[SOUNDEX_LEN+1];
- int i, result;
+ char sndx1[SOUNDEX_LEN + 1],
+ sndx2[SOUNDEX_LEN + 1];
+ int i,
+ result;
_soundex(_textout(PG_GETARG_TEXT_P(0)), sndx1);
_soundex(_textout(PG_GETARG_TEXT_P(1)), sndx2);
result = 0;
- for (i=0; i<SOUNDEX_LEN; i++) {
+ for (i = 0; i < SOUNDEX_LEN; i++)
+ {
if (sndx1[i] == sndx2[i])
result++;
}