From 47fe0517fcb7ac2dfd3727eb2c4fb7c9b8f50897 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 1 Apr 2004 23:44:38 +0000 Subject: [PATCH] Fix some portability issues (reliance on gcc-isms). --- contrib/tsearch2/dict.c | 14 ++++++++++---- contrib/tsearch2/ispell/spell.c | 5 ++++- contrib/tsearch2/rank.c | 4 +++- contrib/tsearch2/snmap.c | 5 ++++- contrib/tsearch2/ts_cfg.c | 16 ++++++++++++---- contrib/tsearch2/wparser.c | 15 ++++++++++----- contrib/tsearch2/wparser_def.c | 4 +++- 7 files changed, 46 insertions(+), 17 deletions(-) diff --git a/contrib/tsearch2/dict.c b/contrib/tsearch2/dict.c index 9ceb78ffb8..8bfeb96de2 100644 --- a/contrib/tsearch2/dict.c +++ b/contrib/tsearch2/dict.c @@ -24,11 +24,14 @@ static void *plan_getdict = NULL; void init_dict(Oid id, DictInfo * dict) { - Oid arg[1] = {OIDOID}; + Oid arg[1]; bool isnull; - Datum pars[1] = {ObjectIdGetDatum(id)}; + Datum pars[1]; int stat; + arg[0] = OIDOID; + pars[0] = ObjectIdGetDatum(id); + memset(dict, 0, sizeof(DictInfo)); SPI_connect(); if (!plan_getdict) @@ -135,12 +138,15 @@ static void *plan_name2id = NULL; Oid name2id_dict(text *name) { - Oid arg[1] = {TEXTOID}; + Oid arg[1]; bool isnull; - Datum pars[1] = {PointerGetDatum(name)}; + Datum pars[1]; int stat; Oid id = findSNMap_t(&(DList.name2id_map), name); + arg[0] = TEXTOID; + pars[0] = PointerGetDatum(name); + if (id) return id; diff --git a/contrib/tsearch2/ispell/spell.c b/contrib/tsearch2/ispell/spell.c index 4f4b332933..838d995702 100644 --- a/contrib/tsearch2/ispell/spell.c +++ b/contrib/tsearch2/ispell/spell.c @@ -796,8 +796,9 @@ SplitToVariants( IspellDict * Conf, SPNode *snode, SplitVar * orig, char *word, int level=(snode) ? minpos : startpos; /* recursive minpos==level*/ int lenaff; CMPDAffix *caff; - char notprobed[wordlen]; + char *notprobed; + notprobed = (char *) palloc(wordlen); memset(notprobed,1,wordlen); var = CopyVar(orig,1); @@ -869,6 +870,7 @@ SplitToVariants( IspellDict * Conf, SPNode *snode, SplitVar * orig, char *word, /* well, it was last word */ var->stem[ var->nstem ] = strnduplicate(word + startpos, wordlen - startpos); var->nstem++; + pfree(notprobed); return var; } else { /* then we will search more big word at the same point */ @@ -892,6 +894,7 @@ SplitToVariants( IspellDict * Conf, SPNode *snode, SplitVar * orig, char *word, var->stem[ var->nstem ] = strnduplicate(word + startpos, wordlen - startpos); var->nstem++; + pfree(notprobed); return var; } diff --git a/contrib/tsearch2/rank.c b/contrib/tsearch2/rank.c index 5b62c9810b..a79444250d 100644 --- a/contrib/tsearch2/rank.c +++ b/contrib/tsearch2/rank.c @@ -433,8 +433,10 @@ Cover(DocRepresentation * doc, int len, QUERYTYPE * query, int *pos, int *p, int if (*p <= *q) { - ChkDocR ch = {f, (doc + lastpos) - f + 1}; + ChkDocR ch; + ch.doc = f; + ch.len = (doc + lastpos) - f + 1; *pos = f - doc + 1; if (TS_execute(GETQUERY(query), &ch, false, checkcondition_DR)) { diff --git a/contrib/tsearch2/snmap.c b/contrib/tsearch2/snmap.c index 2cd3f53e49..ec7ef69a79 100644 --- a/contrib/tsearch2/snmap.c +++ b/contrib/tsearch2/snmap.c @@ -56,7 +56,10 @@ Oid findSNMap(SNMap * map, char *key) { SNMapEntry *ptr; - SNMapEntry ks = {key, 0}; + SNMapEntry ks; + + ks.key = key; + ks.value = 0; if (map->len == 0 || !map->list) return 0; diff --git a/contrib/tsearch2/ts_cfg.c b/contrib/tsearch2/ts_cfg.c index 0898b91924..fd5f7e1556 100644 --- a/contrib/tsearch2/ts_cfg.c +++ b/contrib/tsearch2/ts_cfg.c @@ -34,9 +34,9 @@ static Oid current_cfg_id = 0; void init_cfg(Oid id, TSCfgInfo * cfg) { - Oid arg[2] = {OIDOID, OIDOID}; + Oid arg[2]; bool isnull; - Datum pars[2] = {ObjectIdGetDatum(id), ObjectIdGetDatum(id)}; + Datum pars[2]; int stat, i, j; @@ -44,6 +44,11 @@ init_cfg(Oid id, TSCfgInfo * cfg) text *prsname = NULL; MemoryContext oldcontext; + arg[0] = OIDOID; + arg[1] = OIDOID; + pars[0] = ObjectIdGetDatum(id); + pars[1] = ObjectIdGetDatum(id); + memset(cfg, 0, sizeof(TSCfgInfo)); SPI_connect(); if (!plan_getcfg) @@ -225,12 +230,15 @@ findcfg(Oid id) Oid name2id_cfg(text *name) { - Oid arg[1] = {TEXTOID}; + Oid arg[1]; bool isnull; - Datum pars[1] = {PointerGetDatum(name)}; + Datum pars[1]; int stat; Oid id = findSNMap_t(&(CList.name2id_map), name); + arg[0] = TEXTOID; + pars[0] = PointerGetDatum(name); + if (id) return id; diff --git a/contrib/tsearch2/wparser.c b/contrib/tsearch2/wparser.c index 9c3c443048..b97b158ca7 100644 --- a/contrib/tsearch2/wparser.c +++ b/contrib/tsearch2/wparser.c @@ -27,11 +27,14 @@ static Oid current_parser_id = InvalidOid; void init_prs(Oid id, WParserInfo * prs) { - Oid arg[1] = {OIDOID}; + Oid arg[1]; bool isnull; - Datum pars[1] = {ObjectIdGetDatum(id)}; + Datum pars[1]; int stat; + arg[0] = OIDOID; + pars[0] = ObjectIdGetDatum(id); + memset(prs, 0, sizeof(WParserInfo)); SPI_connect(); if (!plan_getparser) @@ -132,16 +135,18 @@ static void *plan_name2id = NULL; Oid name2id_prs(text *name) { - Oid arg[1] = {TEXTOID}; + Oid arg[1]; bool isnull; - Datum pars[1] = {PointerGetDatum(name)}; + Datum pars[1]; int stat; Oid id = findSNMap_t(&(PList.name2id_map), name); + arg[0] = TEXTOID; + pars[0] = PointerGetDatum(name); + if (id) return id; - SPI_connect(); if (!plan_name2id) { diff --git a/contrib/tsearch2/wparser_def.c b/contrib/tsearch2/wparser_def.c index 6e8775063a..99b47196e9 100644 --- a/contrib/tsearch2/wparser_def.c +++ b/contrib/tsearch2/wparser_def.c @@ -156,8 +156,10 @@ hlCover(HLPRSTEXT * prs, QUERYTYPE * query, int *p, int *q) if (*p <= *q) { - hlCheck ch = {&(prs->words[*p]), *q - *p + 1}; + hlCheck ch; + ch.words = &(prs->words[*p]); + ch.len = *q - *p + 1; if (TS_execute(GETQUERY(query), &ch, false, checkcondition_HL)) return true; else -- 2.40.0