diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2010-11-23 22:27:50 +0200 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2010-11-23 22:34:55 +0200 |
commit | fc946c39aeacdff7df60c83fca6582985e8546c8 (patch) | |
tree | 866145f64c09c0673a4aa3d3a2f5647f0b7afc45 /src/backend/tsearch/wparser_def.c | |
parent | 44475e782f4674d257b9e5c1a3930218a4b4deea (diff) | |
download | postgresql-fc946c39aeacdff7df60c83fca6582985e8546c8.tar.gz |
Remove useless whitespace at end of lines
Diffstat (limited to 'src/backend/tsearch/wparser_def.c')
-rw-r--r-- | src/backend/tsearch/wparser_def.c | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/src/backend/tsearch/wparser_def.c b/src/backend/tsearch/wparser_def.c index ce0b7586c8..e10457797e 100644 --- a/src/backend/tsearch/wparser_def.c +++ b/src/backend/tsearch/wparser_def.c @@ -423,8 +423,8 @@ TParserCopyClose(TParser *prs) * Character-type support functions, equivalent to is* macros, but * working with any possible encodings and locales. Notes: * - with multibyte encoding and C-locale isw* function may fail - * or give wrong result. - * - multibyte encoding and C-locale often are used for + * or give wrong result. + * - multibyte encoding and C-locale often are used for * Asian languages. * - if locale is C the we use pgwstr instead of wstr */ @@ -761,8 +761,8 @@ p_isURLPath(TParser *prs) /* * returns true if current character has zero display length or * it's a special sign in several languages. Such characters - * aren't a word-breaker although they aren't an isalpha. - * In beginning of word they aren't a part of it. + * aren't a word-breaker although they aren't an isalpha. + * In beginning of word they aren't a part of it. */ static int p_isspecial(TParser *prs) @@ -2099,7 +2099,7 @@ hlCover(HeadlineParsedText *prs, TSQuery query, int *p, int *q) return false; } -static void +static void mark_fragment(HeadlineParsedText *prs, int highlight, int startpos, int endpos) { int i; @@ -2125,7 +2125,7 @@ mark_fragment(HeadlineParsedText *prs, int highlight, int startpos, int endpos) } } -typedef struct +typedef struct { int4 startpos; int4 endpos; @@ -2135,16 +2135,16 @@ typedef struct int2 excluded; } CoverPos; -static void +static void get_next_fragment(HeadlineParsedText *prs, int *startpos, int *endpos, int *curlen, int *poslen, int max_words) { int i; - /* Objective: Generate a fragment of words between startpos and endpos - * such that it has at most max_words and both ends has query words. - * If the startpos and endpos are the endpoints of the cover and the - * cover has fewer words than max_words, then this function should - * just return the cover + /* Objective: Generate a fragment of words between startpos and endpos + * such that it has at most max_words and both ends has query words. + * If the startpos and endpos are the endpoints of the cover and the + * cover has fewer words than max_words, then this function should + * just return the cover */ /* first move startpos to an item */ for(i = *startpos; i <= *endpos; i++) @@ -2156,14 +2156,14 @@ get_next_fragment(HeadlineParsedText *prs, int *startpos, int *endpos, /* cut endpos to have only max_words */ *curlen = 0; *poslen = 0; - for(i = *startpos; i <= *endpos && *curlen < max_words; i++) + for(i = *startpos; i <= *endpos && *curlen < max_words; i++) { if (!NONWORDTOKEN(prs->words[i].type)) *curlen += 1; if (prs->words[i].item && !prs->words[i].repeated) *poslen += 1; } - /* if the cover was cut then move back endpos to a query item */ + /* if the cover was cut then move back endpos to a query item */ if (*endpos > i) { *endpos = i; @@ -2174,31 +2174,31 @@ get_next_fragment(HeadlineParsedText *prs, int *startpos, int *endpos, break; if (!NONWORDTOKEN(prs->words[i].type)) *curlen -= 1; - } - } + } + } } static void mark_hl_fragments(HeadlineParsedText *prs, TSQuery query, int highlight, - int shortword, int min_words, + int shortword, int min_words, int max_words, int max_fragments) { int4 poslen, curlen, i, f, num_f = 0; int4 stretch, maxstretch, posmarker; - int4 startpos = 0, - endpos = 0, + int4 startpos = 0, + endpos = 0, p = 0, q = 0; - int4 numcovers = 0, + int4 numcovers = 0, maxcovers = 32; int4 minI, minwords, maxitems; CoverPos *covers; covers = palloc(maxcovers * sizeof(CoverPos)); - + /* get all covers */ while (hlCover(prs, query, &p, &q)) { @@ -2207,7 +2207,7 @@ mark_hl_fragments(HeadlineParsedText *prs, TSQuery query, int highlight, /* Break the cover into smaller fragments such that each fragment * has at most max_words. Also ensure that each end of the fragment - * is a query word. This will allow us to stretch the fragment in + * is a query word. This will allow us to stretch the fragment in * either direction */ @@ -2228,9 +2228,9 @@ mark_hl_fragments(HeadlineParsedText *prs, TSQuery query, int highlight, numcovers ++; startpos = endpos + 1; endpos = q; - } + } /* move p to generate the next cover */ - p++; + p++; } /* choose best covers */ @@ -2240,13 +2240,13 @@ mark_hl_fragments(HeadlineParsedText *prs, TSQuery query, int highlight, minwords = 0x7fffffff; minI = -1; /* Choose the cover that contains max items. - * In case of tie choose the one with smaller - * number of words. + * In case of tie choose the one with smaller + * number of words. */ for (i = 0; i < numcovers; i ++) { - if (!covers[i].in && !covers[i].excluded && - (maxitems < covers[i].poslen || (maxitems == covers[i].poslen + if (!covers[i].in && !covers[i].excluded && + (maxitems < covers[i].poslen || (maxitems == covers[i].poslen && minwords > covers[i].curlen))) { maxitems = covers[i].poslen; @@ -2263,15 +2263,15 @@ mark_hl_fragments(HeadlineParsedText *prs, TSQuery query, int highlight, endpos = covers[minI].endpos; curlen = covers[minI].curlen; /* stretch the cover if cover size is lower than max_words */ - if (curlen < max_words) + if (curlen < max_words) { /* divide the stretch on both sides of cover */ maxstretch = (max_words - curlen)/2; - /* first stretch the startpos - * stop stretching if - * 1. we hit the beginning of document - * 2. exceed maxstretch - * 3. we hit an already marked fragment + /* first stretch the startpos + * stop stretching if + * 1. we hit the beginning of document + * 2. exceed maxstretch + * 3. we hit an already marked fragment */ stretch = 0; posmarker = startpos; @@ -2297,7 +2297,7 @@ mark_hl_fragments(HeadlineParsedText *prs, TSQuery query, int highlight, { if (!NONWORDTOKEN(prs->words[i].type)) curlen ++; - posmarker = i; + posmarker = i; } /* cut back endpos till we find a non-short token */ for ( i = posmarker; i > endpos && (NOENDTOKEN(prs->words[i].type) || prs->words[i].len <= shortword); i--) @@ -2316,7 +2316,7 @@ mark_hl_fragments(HeadlineParsedText *prs, TSQuery query, int highlight, /* exclude overlapping covers */ for (i = 0; i < numcovers; i ++) { - if (i != minI && ( (covers[i].startpos >= covers[minI].startpos && covers[i].startpos <= covers[minI].endpos) || (covers[i].endpos >= covers[minI].startpos && covers[i].endpos <= covers[minI].endpos))) + if (i != minI && ( (covers[i].startpos >= covers[minI].startpos && covers[i].startpos <= covers[minI].endpos) || (covers[i].endpos >= covers[minI].startpos && covers[i].endpos <= covers[minI].endpos))) covers[i].excluded = 1; } } @@ -2340,7 +2340,7 @@ mark_hl_fragments(HeadlineParsedText *prs, TSQuery query, int highlight, } static void -mark_hl_words(HeadlineParsedText *prs, TSQuery query, int highlight, +mark_hl_words(HeadlineParsedText *prs, TSQuery query, int highlight, int shortword, int min_words, int max_words) { int p = 0, @@ -2552,7 +2552,7 @@ prsd_headline(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("MaxFragments should be >= 0"))); - } + } if (max_fragments == 0) /* call the default headline generator */ |