*end = NULL; while (*in && isspace((unsignedchar) *in))
in += pg_mblen_cstr(in);
if (!*in || *in == '#') return NULL;
start = in;
while (*in && !isspace((unsignedchar) *in))
in += pg_mblen_cstr(in);
*end = in;
return start;
}
staticint
compare_syn(constvoid *a, constvoid *b)
{ return strcmp(((const Syn *) a)->key, ((const Syn *) b)->key);
}
staticvoid
read_dictionary(DictSyn *d, constchar *filename)
{ char *real_filename = get_tsearch_config_filename(filename, "rules");
tsearch_readline_state trst; char *line; int cur = 0;
if (!tsearch_readline_begin(&trst, real_filename))
ereport(ERROR,
(errcode(ERRCODE_CONFIG_FILE_ERROR),
errmsg("could not open synonym file \"%s\": %m",
real_filename)));
value = str_tolower(line, strlen(line), DEFAULT_COLLATION_OID);
pfree(line);
pos = value; while ((key = find_word(pos, &end)) != NULL)
{ /* Enlarge syn structure if full */ if (cur == d->len)
{
d->len = (d->len > 0) ? 2 * d->len : 16; if (d->syn)
d->syn = (Syn *) repalloc(d->syn, sizeof(Syn) * d->len); else
d->syn = (Syn *) palloc(sizeof(Syn) * d->len);
}
/* Save first word only if we will match it */ if (pos != value || d->matchorig)
{
d->syn[cur].key = pnstrdup(key, end - key);
d->syn[cur].value = pstrdup(value);
cur++;
}
pos = end;
/* Don't bother scanning synonyms if we will not match them */ if (!d->matchsynonyms) break;
}
/* Look for matching syn */
found = (Syn *) bsearch(&word, d->syn, d->len, sizeof(Syn), compare_syn);
pfree(word.key);
if (!found)
PG_RETURN_POINTER(NULL);
/* Parse string of synonyms and return array of words */
{ char *value = found->value; char *syn; char *pos; char *end; int nsyns = 0;
res = palloc(sizeof(TSLexeme));
pos = value; while ((syn = find_word(pos, &end)) != NULL)
{
res = repalloc(res, sizeof(TSLexeme) * (nsyns + 2));
/* The first word is output only if keeporig=true */ if (pos != value || d->keeporig)
{
res[nsyns].lexeme = pnstrdup(syn, end - syn);
res[nsyns].nvariant = 0;
res[nsyns].flags = 0;
nsyns++;
}
pos = end;
/* Stop if we are not to output the synonyms */ if (!d->keepsynonyms) break;
}
res[nsyns].lexeme = NULL;
}
PG_RETURN_POINTER(res);
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet am 2026-08-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.