]> granicus.if.org Git - postgresql/blobdiff - src/backend/tsearch/dict_ispell.c
Remove cvs keywords from all files.
[postgresql] / src / backend / tsearch / dict_ispell.c
index f7cee1073005f1303c481a889437a10cf61a1acc..95bf8d46324adb961c8dbe130df867eb94b04f80 100644 (file)
@@ -3,16 +3,17 @@
  * dict_ispell.c
  *             Ispell dictionary interface
  *
- * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/tsearch/dict_ispell.c,v 1.1 2007/08/21 01:11:18 tgl Exp $
+ *       src/backend/tsearch/dict_ispell.c
  *
  *-------------------------------------------------------------------------
  */
 #include "postgres.h"
 
+#include "commands/defrem.h"
 #include "tsearch/dicts/spell.h"
 #include "tsearch/ts_locale.h"
 #include "tsearch/ts_public.h"
@@ -30,74 +31,58 @@ typedef struct
 Datum
 dispell_init(PG_FUNCTION_ARGS)
 {
+       List       *dictoptions = (List *) PG_GETARG_POINTER(0);
        DictISpell *d;
-       Map                *cfg,
-                          *pcfg;
        bool            affloaded = false,
                                dictloaded = false,
                                stoploaded = false;
-       text       *in;
-
-       /* init functions must defend against NULLs for themselves */
-       if (PG_ARGISNULL(0) || PG_GETARG_POINTER(0) == NULL)
-               ereport(ERROR,
-                               (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                                errmsg("NULL config not allowed for ISpell")));
-       in = PG_GETARG_TEXT_P(0);
-
-       parse_keyvalpairs(in, &cfg);
-       PG_FREE_IF_COPY(in, 0);
+       ListCell   *l;
 
        d = (DictISpell *) palloc0(sizeof(DictISpell));
-       d->stoplist.wordop = recode_and_lowerstr;
 
-       pcfg = cfg;
-       while (pcfg->key)
+       foreach(l, dictoptions)
        {
-               if (pg_strcasecmp("DictFile", pcfg->key) == 0)
+               DefElem    *defel = (DefElem *) lfirst(l);
+
+               if (pg_strcasecmp(defel->defname, "DictFile") == 0)
                {
                        if (dictloaded)
                                ereport(ERROR,
                                                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                                 errmsg("multiple DictFile parameters")));
                        NIImportDictionary(&(d->obj),
-                                                          get_tsearch_config_filename(pcfg->value,
-                                                                                                                  "dict"));
+                                                        get_tsearch_config_filename(defGetString(defel),
+                                                                                                                "dict"));
                        dictloaded = true;
                }
-               else if (pg_strcasecmp("AffFile", pcfg->key) == 0)
+               else if (pg_strcasecmp(defel->defname, "AffFile") == 0)
                {
                        if (affloaded)
                                ereport(ERROR,
                                                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                                 errmsg("multiple AffFile parameters")));
                        NIImportAffixes(&(d->obj),
-                                                       get_tsearch_config_filename(pcfg->value,
+                                                       get_tsearch_config_filename(defGetString(defel),
                                                                                                                "affix"));
                        affloaded = true;
                }
-               else if (pg_strcasecmp("StopWords", pcfg->key) == 0)
+               else if (pg_strcasecmp(defel->defname, "StopWords") == 0)
                {
                        if (stoploaded)
                                ereport(ERROR,
                                                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                                 errmsg("multiple StopWords parameters")));
-                       readstoplist(pcfg->value, &(d->stoplist));
-                       sortstoplist(&(d->stoplist));
+                       readstoplist(defGetString(defel), &(d->stoplist), lowerstr);
                        stoploaded = true;
                }
                else
                {
                        ereport(ERROR,
                                        (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                                        errmsg("unrecognized ISpell parameter: \"%s\"",
-                                                       pcfg->key)));
+                                        errmsg("unrecognized Ispell parameter: \"%s\"",
+                                                       defel->defname)));
                }
-               pfree(pcfg->key);
-               pfree(pcfg->value);
-               pcfg++;
        }
-       pfree(cfg);
 
        if (affloaded && dictloaded)
        {
@@ -127,7 +112,7 @@ dispell_lexize(PG_FUNCTION_ARGS)
 {
        DictISpell *d = (DictISpell *) PG_GETARG_POINTER(0);
        char       *in = (char *) PG_GETARG_POINTER(1);
-       int32      len = PG_GETARG_INT32(2);
+       int32           len = PG_GETARG_INT32(2);
        char       *txt;
        TSLexeme   *res;
        TSLexeme   *ptr,