|
PostgreSQL Source Code git master
|
#include "postgres.h"#include "catalog/pg_collation.h"#include "miscadmin.h"#include "tsearch/dicts/spell.h"#include "tsearch/ts_locale.h"#include "utils/formatting.h"#include "utils/memutils.h"
Go to the source code of this file.
Data Structures | |
| struct | SplitVar |
Macros | |
| #define | tmpalloc(sz) MemoryContextAlloc(Conf->buildCxt, (sz)) |
| #define | tmpalloc0(sz) MemoryContextAllocZero(Conf->buildCxt, (sz)) |
| #define | COMPACT_ALLOC_CHUNK 8192 /* amount to get from palloc at once */ |
| #define | COMPACT_MAX_REQ 1024 /* must be < COMPACT_ALLOC_CHUNK */ |
| #define | cpalloc(size) compact_palloc0(Conf, size) |
| #define | cpalloc0(size) compact_palloc0(Conf, size) |
| #define | MAX_NORM 1024 |
| #define | MAXNORMLEN 256 |
| #define | STRNCMP(s, p) strncmp( (s), (p), strlen(p) ) |
| #define | GETWCHAR(W, L, N, T) ( ((const uint8*)(W))[ ((T)==FF_PREFIX) ? (N) : ( (L) - 1 - (N) ) ] ) |
| #define | GETCHAR(A, N, T) GETWCHAR( (A)->repl, (A)->replen, N, T ) |
| #define | PAE_WAIT_MASK 0 |
| #define | PAE_INMASK 1 |
| #define | PAE_WAIT_FIND 2 |
| #define | PAE_INFIND 3 |
| #define | PAE_WAIT_REPL 4 |
| #define | PAE_INREPL 5 |
| #define | PAE_WAIT_TYPE 6 |
| #define | PAE_WAIT_FLAG 7 |
Typedefs | |
| typedef struct SplitVar | SplitVar |
Variables | |
| static const char * | VoidString = "" |
| #define COMPACT_MAX_REQ 1024 /* must be < COMPACT_ALLOC_CHUNK */ |
| #define cpalloc | ( | size | ) | compact_palloc0(Conf, size) |
| #define cpalloc0 | ( | size | ) | compact_palloc0(Conf, size) |
| #define tmpalloc | ( | sz | ) | MemoryContextAlloc(Conf->buildCxt, (sz)) |
| #define tmpalloc0 | ( | sz | ) | MemoryContextAllocZero(Conf->buildCxt, (sz)) |
Definition at line 1076 of file spell.c.
References ereport, errcode(), errmsg, ERROR, fb(), pg_mblen_cstr(), repalloc(), setCompoundAffixFlagValue(), tmpalloc, ts_copychar_with_len(), and val.
Referenced by NIImportAffixes(), and NIImportOOAffixes().
|
static |
Definition at line 2571 of file spell.c.
References fb(), MAX_NORM, palloc_array, and word().
Referenced by NINormalizeWord().
Definition at line 2408 of file spell.c.
References SplitVar::lenstem, SplitVar::nstem, repalloc(), SplitVar::stem, and word().
Referenced by SplitToVariants().
|
static |
Definition at line 2103 of file spell.c.
References Assert, data, fb(), FF_COMPOUNDBEGIN, FF_COMPOUNDFORBIDFLAG, FF_COMPOUNDLAST, FF_COMPOUNDMIDDLE, FF_COMPOUNDONLY, FF_PREFIX, FF_SUFFIX, aff_struct::find, aff_struct::flagflags, aff_struct::isregis, aff_struct::issimple, len, MAXNORMLEN, memcpy(), palloc_array, pfree(), pg_mb2wchar_with_len(), pg_regexec(), aff_struct::pregex, aff_struct::reg, REG_OKAY, aff_struct::regis, aff_struct::replen, RS_execute(), aff_struct::type, and word().
Referenced by NormalizeSubWord().
|
static |
Definition at line 2341 of file spell.c.
References fb(), len, and word().
Referenced by SplitToVariants().
Definition at line 211 of file spell.c.
References Assert, f1, f2, fb(), and FM_NUM.
Referenced by getCompoundAffixFlagValue(), and NIImportOOAffixes().
|
static |
Definition at line 131 of file spell.c.
References Assert, COMPACT_ALLOC_CHUNK, COMPACT_MAX_REQ, fb(), MAXALIGN, palloc0(), and result.
Definition at line 2383 of file spell.c.
References fb(), i, SplitVar::lenstem, SplitVar::next, SplitVar::nstem, palloc_array, palloc_object, pstrdup(), and SplitVar::stem.
Referenced by SplitToVariants().
|
static |
Definition at line 163 of file spell.c.
References cpalloc, fb(), and str.
Referenced by NIAddAffix(), NIAddSpell(), NIImportOOAffixes(), NISortDictionary(), and setCompoundAffixFlagValue().
|
static |
Definition at line 2040 of file spell.c.
References AffixNode::data, fb(), GETWCHAR, AffixNode::isvoid, AffixNode::length, AffixNodeData::naff, AffixNodeData::node, type, and word().
Referenced by NormalizeSubWord().
Definition at line 230 of file spell.c.
References fb(), pg_mblen_cstr(), str, and t_iseq.
Referenced by NIImportDictionary().
|
static |
Definition at line 605 of file spell.c.
References SPNode::data, fb(), FF_COMPOUNDFLAGMASK, FF_COMPOUNDONLY, flag(), IsAffixFlagInUse(), SPNode::length, and word().
Referenced by NormalizeSubWord().
Definition at line 794 of file spell.c.
References fb(), next, PAE_INMASK, PAE_WAIT_MASK, pg_mblen_cstr(), str, t_iseq, and ts_copychar_with_len().
Referenced by parse_ooaffentry().
|
static |
Definition at line 1170 of file spell.c.
References ereport, errcode(), errmsg, ERROR, fb(), and VoidString.
Referenced by NIImportOOAffixes().
|
static |
Definition at line 1134 of file spell.c.
References cmpcmdflag(), fb(), flag(), getNextFlagFromString(), setCompoundAffixFlagValue(), and CompoundAffixFlag::value.
Referenced by makeCompoundFlags(), and NIImportOOAffixes().
|
static |
Definition at line 350 of file spell.c.
References elog, ereport, errcode(), errmsg, ERROR, fb(), FLAGNUM_MAXSIZE, FM_CHAR, FM_LONG, FM_NUM, next, pg_mblen_cstr(), sprintf, t_iseq, and ts_copychar_cstr().
Referenced by getCompoundAffixFlagValue(), and IsAffixFlagInUse().
Definition at line 457 of file spell.c.
References Assert, fb(), flag(), and getNextFlagFromString().
Referenced by FindWord(), and isAffixInUse().
|
static |
Definition at line 1973 of file spell.c.
References fb(), i, and IsAffixFlagInUse().
Referenced by NISortAffixes().
|
static |
Definition at line 176 of file spell.c.
References fb(), MemoryContextSwitchTo(), and str_tolower().
Referenced by NIImportDictionary(), and NIImportOOAffixes().
|
static |
Definition at line 1634 of file spell.c.
References Assert, fb(), FF_COMPOUNDFLAGMASK, and getCompoundAffixFlagValue().
Referenced by mkSPNode().
|
static |
Definition at line 1583 of file spell.c.
References a1, a2, Assert, cpalloc, fb(), FM_NUM, repalloc(), and sprintf.
Referenced by mkSPNode().
Definition at line 1842 of file spell.c.
References ANHRDSZ, cpalloc, cpalloc0, AffixNode::data, data, fb(), GETCHAR, i, AffixNode::length, memcpy(), mkANode(), AffixNodeData::node, pfree(), tmpalloc, and type.
Referenced by mkANode(), and NISortAffixes().
Definition at line 1651 of file spell.c.
References cpalloc0, SPNode::data, data, fb(), FF_COMPOUNDFLAG, FF_COMPOUNDONLY, i, SPNode::length, makeCompoundFlags(), MergeAffix(), mkSPNode(), SPNodeData::node, and SPNHDRSZ.
Referenced by mkSPNode(), and NISortDictionary().
|
static |
Definition at line 1919 of file spell.c.
References AffixNodeData::aff, ANHRDSZ, cpalloc, AffixNode::data, fb(), i, AffixNode::isvoid, AffixNode::length, AffixNodeData::naff, AffixNodeData::node, palloc0(), and start.
Referenced by NISortAffixes().
|
static |
Definition at line 680 of file spell.c.
References cpstrdup(), ereport, err(), errcode(), errmsg, ERROR, fb(), FF_COMPOUNDFLAG, FF_COMPOUNDONLY, FF_COMPOUNDPERMITFLAG, FF_SUFFIX, find(), aff_struct::find, aff_struct::flag, flag(), aff_struct::flagflags, aff_struct::isregis, aff_struct::issimple, palloc_array, palloc_object, pg_mb2wchar_with_len(), pg_regcomp(), pg_regerror(), aff_struct::pregex, aff_struct::reg, REG_ADVANCED, REG_NOSUB, regex_t, aff_struct::regis, repalloc(), aff_struct::repl, aff_struct::replen, RS_compile(), RS_isRegis(), sprintf, tmpalloc, type, aff_struct::type, and VoidString.
Referenced by NIImportAffixes(), and NIImportOOAffixes().
Definition at line 489 of file spell.c.
References cpstrdup(), fb(), flag(), repalloc(), SPELLHDRSZ, tmpalloc, VoidString, and word().
Referenced by NIImportDictionary().
| void NIFinishBuild | ( | IspellDict * | Conf | ) |
Definition at line 104 of file spell.c.
References fb(), and MemoryContextDelete().
Referenced by dispell_init().
| void NIImportAffixes | ( | IspellDict * | Conf, |
| const char * | filename | ||
| ) |
Definition at line 1437 of file spell.c.
References addCompoundAffixFlagValue(), ereport, errcode(), errmsg, ERROR, fb(), FF_COMPOUNDFLAG, FF_COMPOUNDONLY, FF_CROSSPRODUCT, FF_PREFIX, FF_SUFFIX, filename, find(), findchar2(), flag(), FM_CHAR, NIAddAffix(), NIImportOOAffixes(), parse_affentry(), pfree(), pg_mblen_cstr(), prefixes(), str_tolower(), STRNCMP, tsearch_readline(), tsearch_readline_begin(), and tsearch_readline_end().
Referenced by dispell_init().
| void NIImportDictionary | ( | IspellDict * | Conf, |
| const char * | filename | ||
| ) |
Definition at line 520 of file spell.c.
References ereport, errcode(), errmsg, ERROR, fb(), filename, findchar(), flag(), lowerstr_ctx(), NIAddSpell(), pfree(), pg_mblen_cstr(), tsearch_readline(), tsearch_readline_begin(), and tsearch_readline_end().
Referenced by dispell_init().
|
static |
Definition at line 1208 of file spell.c.
References addCompoundAffixFlagValue(), cmpcmdflag(), cpstrdup(), ereport, errcode(), errmsg, ERROR, fb(), FF_COMPOUNDBEGIN, FF_COMPOUNDFLAG, FF_COMPOUNDFORBIDFLAG, FF_COMPOUNDLAST, FF_COMPOUNDMIDDLE, FF_COMPOUNDONLY, FF_COMPOUNDPERMITFLAG, FF_CROSSPRODUCT, FF_PREFIX, FF_SUFFIX, filename, find(), FM_CHAR, FM_LONG, FM_NUM, getAffixFlagSet(), getCompoundAffixFlagValue(), lowerstr_ctx(), NIAddAffix(), palloc0_array, parse_ooaffentry(), pfree(), pg_mblen_cstr(), qsort, STRNCMP, t_iseq, tsearch_readline(), tsearch_readline_begin(), tsearch_readline_end(), type, and VoidString.
Referenced by NIImportAffixes().
| TSLexeme * NINormalizeWord | ( | IspellDict * | Conf, |
| const char * | word | ||
| ) |
Definition at line 2587 of file spell.c.
References addNorm(), fb(), FF_COMPOUNDLAST, i, MAX_NORM, SplitVar::next, NormalizeSubWord(), SplitVar::nstem, pfree(), pstrdup(), SplitToVariants(), SplitVar::stem, and word().
Referenced by dispell_lexize().
| void NISortAffixes | ( | IspellDict * | Conf | ) |
Definition at line 1988 of file spell.c.
References CMPDAffix::affix, cmpaffix(), fb(), FF_COMPOUNDFLAG, FF_PREFIX, FF_SUFFIX, aff_struct::flag, aff_struct::flagflags, i, isAffixInUse(), CMPDAffix::issuffix, CMPDAffix::len, mkANode(), mkVoidAffix(), palloc_array, qsort, repalloc(), aff_struct::repl, aff_struct::replen, strbncmp(), and aff_struct::type.
Referenced by dispell_init().
| void NISortDictionary | ( | IspellDict * | Conf | ) |
Definition at line 1733 of file spell.c.
References Assert, cmpspell(), cmpspellaffix(), cpstrdup(), ereport, errcode(), errmsg, ERROR, fb(), i, mkSPNode(), palloc0_array, and qsort.
Referenced by dispell_init().
| void NIStartBuild | ( | IspellDict * | Conf | ) |
Definition at line 89 of file spell.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, CurTransactionContext, and fb().
Referenced by dispell_init().
Definition at line 2223 of file spell.c.
References addToResult(), AffixNodeData::aff, CheckAffix(), cur, fb(), FF_CROSSPRODUCT, FF_PREFIX, FF_SUFFIX, FindAffixes(), FindWord(), aff_struct::flag, flag(), aff_struct::flagflags, i, j, MAX_NORM, MAXNORMLEN, AffixNodeData::naff, AffixNodeData::node, palloc_array, pfree(), pstrdup(), VoidString, and word().
Referenced by NINormalizeWord(), and SplitToVariants().
Definition at line 917 of file spell.c.
References elog, ereport, errcode(), errmsg, ERROR, fb(), find(), PAE_INFIND, PAE_INMASK, PAE_INREPL, PAE_WAIT_FIND, PAE_WAIT_MASK, PAE_WAIT_REPL, pg_mblen_cstr(), str, t_iseq, and ts_copychar_with_len().
Referenced by NIImportAffixes().
|
static |
Definition at line 858 of file spell.c.
References elog, ERROR, fb(), find(), flag(), get_nextfield(), PAE_WAIT_FIND, PAE_WAIT_FLAG, PAE_WAIT_MASK, PAE_WAIT_REPL, PAE_WAIT_TYPE, str, and type.
Referenced by NIImportOOAffixes().
|
static |
Definition at line 1040 of file spell.c.
References cpstrdup(), ereport, errcode(), errmsg, ERROR, fb(), CompoundAffixFlag::flag, CompoundAffixFlag::flagMode, FLAGNUM_MAXSIZE, FM_NUM, i, CompoundAffixFlag::i, next, CompoundAffixFlag::s, val, and CompoundAffixFlag::value.
Referenced by addCompoundAffixFlagValue(), and getCompoundAffixFlagValue().
|
static |
Definition at line 2421 of file spell.c.
References AddStem(), buf, check_stack_depth(), CheckCompoundAffixes(), CopyVar(), SPNode::data, fb(), FF_COMPOUNDBEGIN, FF_COMPOUNDLAST, FF_COMPOUNDMIDDLE, SPNode::length, MAXNORMLEN, memcpy(), SplitVar::next, NormalizeSubWord(), palloc(), pfree(), pnstrdup(), SplitToVariants(), startpos, and word().
Referenced by NINormalizeWord(), and SplitToVariants().
Definition at line 258 of file spell.c.
Referenced by cmpaffix().
Definition at line 281 of file spell.c.
Referenced by NISortAffixes().
Definition at line 195 of file spell.c.
Referenced by getAffixFlagSet(), NIAddAffix(), NIAddSpell(), NIImportOOAffixes(), and NormalizeSubWord().