summaryrefslogtreecommitdiff
path: root/contrib/dict_xsyn
diff options
context:
space:
mode:
authorBruce Momjian2007-11-15 21:14:46 +0000
committerBruce Momjian2007-11-15 21:14:46 +0000
commitfdf5a5efb7b28c13085fe7313658de8d7b9914f6 (patch)
treea75cf1422fa1eef4e801cf502b148d8ce1b5dfe7 /contrib/dict_xsyn
parent3adc760fb92eab1a8720337a8bf9b66486609eb3 (diff)
pgindent run for 8.3.
Diffstat (limited to 'contrib/dict_xsyn')
-rw-r--r--contrib/dict_xsyn/dict_xsyn.c79
1 files changed, 40 insertions, 39 deletions
diff --git a/contrib/dict_xsyn/dict_xsyn.c b/contrib/dict_xsyn/dict_xsyn.c
index 1cd53a26bd1..753886117da 100644
--- a/contrib/dict_xsyn/dict_xsyn.c
+++ b/contrib/dict_xsyn/dict_xsyn.c
@@ -6,7 +6,7 @@
* Copyright (c) 2007, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/contrib/dict_xsyn/dict_xsyn.c,v 1.1 2007/10/15 21:36:50 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/dict_xsyn/dict_xsyn.c,v 1.2 2007/11/15 21:14:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -24,29 +24,30 @@ PG_MODULE_MAGIC;
typedef struct
{
- char *key; /* Word */
- char *value; /* Unparsed list of synonyms, including the word itself */
+ char *key; /* Word */
+ char *value; /* Unparsed list of synonyms, including the
+ * word itself */
} Syn;
typedef struct
{
- int len;
- Syn *syn;
+ int len;
+ Syn *syn;
- bool keeporig;
+ bool keeporig;
} DictSyn;
PG_FUNCTION_INFO_V1(dxsyn_init);
-Datum dxsyn_init(PG_FUNCTION_ARGS);
+Datum dxsyn_init(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(dxsyn_lexize);
-Datum dxsyn_lexize(PG_FUNCTION_ARGS);
+Datum dxsyn_lexize(PG_FUNCTION_ARGS);
static char *
find_word(char *in, char **end)
{
- char *start;
+ char *start;
*end = NULL;
while (*in && t_isspace(in))
@@ -71,12 +72,12 @@ compare_syn(const void *a, const void *b)
}
static void
-read_dictionary(DictSyn *d, char *filename)
+read_dictionary(DictSyn * d, char *filename)
{
- char *real_filename = get_tsearch_config_filename(filename, "rules");
- FILE *fin;
- char *line;
- int cur = 0;
+ char *real_filename = get_tsearch_config_filename(filename, "rules");
+ FILE *fin;
+ char *line;
+ int cur = 0;
if ((fin = AllocateFile(real_filename, "r")) == NULL)
ereport(ERROR,
@@ -86,9 +87,9 @@ read_dictionary(DictSyn *d, char *filename)
while ((line = t_readline(fin)) != NULL)
{
- char *value;
- char *key;
- char *end = NULL;
+ char *value;
+ char *key;
+ char *end = NULL;
if (*line == '\0')
continue;
@@ -130,9 +131,9 @@ read_dictionary(DictSyn *d, char *filename)
Datum
dxsyn_init(PG_FUNCTION_ARGS)
{
- List *dictoptions = (List *) PG_GETARG_POINTER(0);
- DictSyn *d;
- ListCell *l;
+ List *dictoptions = (List *) PG_GETARG_POINTER(0);
+ DictSyn *d;
+ ListCell *l;
d = (DictSyn *) palloc0(sizeof(DictSyn));
d->len = 0;
@@ -141,7 +142,7 @@ dxsyn_init(PG_FUNCTION_ARGS)
foreach(l, dictoptions)
{
- DefElem *defel = (DefElem *) lfirst(l);
+ DefElem *defel = (DefElem *) lfirst(l);
if (pg_strcasecmp(defel->defname, "KEEPORIG") == 0)
{
@@ -166,19 +167,19 @@ dxsyn_init(PG_FUNCTION_ARGS)
Datum
dxsyn_lexize(PG_FUNCTION_ARGS)
{
- DictSyn *d = (DictSyn *) PG_GETARG_POINTER(0);
- char *in = (char *) PG_GETARG_POINTER(1);
- int length = PG_GETARG_INT32(2);
- Syn word;
- Syn *found;
- TSLexeme *res = NULL;
+ DictSyn *d = (DictSyn *) PG_GETARG_POINTER(0);
+ char *in = (char *) PG_GETARG_POINTER(1);
+ int length = PG_GETARG_INT32(2);
+ Syn word;
+ Syn *found;
+ TSLexeme *res = NULL;
if (!length || d->len == 0)
PG_RETURN_POINTER(NULL);
/* Create search pattern */
{
- char *temp = pnstrdup(in, length);
+ char *temp = pnstrdup(in, length);
word.key = lowerstr(temp);
pfree(temp);
@@ -186,7 +187,7 @@ dxsyn_lexize(PG_FUNCTION_ARGS)
}
/* Look for matching syn */
- found = (Syn *)bsearch(&word, d->syn, d->len, sizeof(Syn), compare_syn);
+ found = (Syn *) bsearch(&word, d->syn, d->len, sizeof(Syn), compare_syn);
pfree(word.key);
if (!found)
@@ -194,28 +195,28 @@ dxsyn_lexize(PG_FUNCTION_ARGS)
/* Parse string of synonyms and return array of words */
{
- char *value = pstrdup(found->value);
- int value_length = strlen(value);
- char *pos = value;
- int nsyns = 0;
- bool is_first = true;
+ char *value = pstrdup(found->value);
+ int value_length = strlen(value);
+ char *pos = value;
+ int nsyns = 0;
+ bool is_first = true;
res = palloc(0);
- while(pos < value + value_length)
+ while (pos < value + value_length)
{
- char *end;
- char *syn = find_word(pos, &end);
+ char *end;
+ char *syn = find_word(pos, &end);
if (!syn)
break;
*end = '\0';
- res = repalloc(res, sizeof(TSLexeme)*(nsyns + 2));
+ res = repalloc(res, sizeof(TSLexeme) * (nsyns + 2));
res[nsyns].lexeme = NULL;
/* first word is added to result only if KEEPORIG flag is set */
- if(d->keeporig || !is_first)
+ if (d->keeporig || !is_first)
{
res[nsyns].lexeme = pstrdup(syn);
res[nsyns + 1].lexeme = NULL;