8000 Fix some portability issues (reliance on gcc-isms). · postgrespro/postgres_cluster@47fe051 · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 47fe051

Browse files
committed
Fix some portability issues (reliance on gcc-isms).
1 parent 51d1a12 commit 47fe051

File tree

7 files changed

+46
-17
lines changed

7 files changed

+46
-17
lines changed

contrib/tsearch2/dict.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ static void *plan_getdict = NULL;
2424
void
2525
init_dict(Oid id, DictInfo * dict)
2626
{
27-
Oid arg[1] = {OIDOID};
27+
Oid arg[1];
2828
bool isnull;
29-
Datum pars[1] = {ObjectIdGetDatum(id)};
29+
Datum pars[1];
3030
int stat;
3131

32+
arg[0] = OIDOID;
33+
pars[0] = ObjectIdGetDatum(id);
34+
3235
memset(dict, 0, sizeof(DictInfo));
3336
SPI_connect();
3437
if (!plan_getdict)
@@ -135,12 +138,15 @@ static void *plan_name2id = NULL;
135138
Oid
136139
name2id_dict(text *name)
137140
{
138-
Oid arg[1] = {TEXTOID};
141+
Oid arg[1];
139142
bool isnull;
140-
Datum pars[1] = {PointerGetDatum(name)};
143+
Datum pars[1];
141144
int stat;
142145
Oid id = findSNMap_t(&(DList.name2id_map), name);
143146

147+
arg[0] = TEXTOID;
148+
pars[0] = PointerGetDatum(name);
149+
144150
if (id)
145151
return id;
146152

contrib/tsearch2/ispell/spell.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,8 +796,9 @@ SplitToVariants( IspellDict * Conf, SPNode *snode, SplitVar * orig, char *word,
796796
int level=(snode) ? minpos : startpos; /* recursive minpos==level*/
797797
int lenaff;
798798
CMPDAffix *caff;
799-
char notprobed[wordlen];
799+
char *notprobed;
800800

801+
notprobed = (char *) palloc(wordlen);
801802
memset(notprobed,1,wordlen);
802803
var = CopyVar(orig,1);
803804

@@ -869,6 +870,7 @@ SplitToVariants( IspellDict * Conf, SPNode *snode, SplitVar * orig, char *word,
869870
/* well, it was last word */
870871
var->stem[ var->nstem ] = strnduplicate(word + startpos, wordlen - startpos);
871872
var->nstem++;
873+
pfree(notprobed);
872874
return var;
873875
} else {
874876
/* then we will search more big word at the same point */
@@ -892,6 +894,7 @@ SplitToVariants( IspellDict * Conf, SPNode *snode, SplitVar * orig, char *word,
892894

893895
var->stem[ var->nstem ] = strnduplicate(word + startpos, wordlen - startpos);
894896
var->nstem++;
897+
pfree(notprobed);
895898
return var;
896899
}
897900

contrib/tsearch2/rank.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,10 @@ Cover(DocRepresentation * doc, int len, QUERYTYPE * query, int *pos, int *p, int
433433

434434
if (*p <= *q)
435435
{
436-
ChkDocR ch = {f, (doc + lastpos) - f + 1};
436+
ChkDocR ch;
437437

438+
ch.doc = f;
439+
ch.len = (doc + lastpos) - f + 1;
438440
*pos = f - doc + 1;
439441
if (TS_execute(GETQUERY(query), &ch, false, checkcondition_DR))
440442
{

contrib/tsearch2/snmap.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ Oid
5656
findSNMap(SNMap * map, char *key)
5757
{
5858
SNMapEntry *ptr;
59-
SNMapEntry ks = {key, 0};
59+
SNMapEntry ks;
60+
61+
ks.key = key;
62+
ks.value = 0;
6063

6164
if (map->len == 0 || !map->list)
6265
return 0;

contrib/tsearch2/ts_cfg.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,21 @@ static Oid current_cfg_id = 0;
3434
void
3535
init_cfg(Oid id, TSCfgInfo * cfg)
3636
{
37-
Oid arg[2] = {OIDOID, OIDOID};
37+
Oid arg[2];
3838
bool isnull;
39-
Datum pars[2] = {ObjectIdGetDatum(id), ObjectIdGetDatum(id)};
39+
Datum pars[2];
4040
int stat,
4141
i,
4242
j;
4343
text *ptr;
4444
text *prsname = NULL;
4545
MemoryContext oldcontext;
4646

47+
arg[0] = OIDOID;
48+
arg[1] = OIDOID;
49+
pars[0] = ObjectIdGetDatum(id);
50+
pars[1] = ObjectIdGetDatum(id);
51+
4752
memset(cfg, 0, sizeof(TSCfgInfo));
4853
SPI_connect();
4954
if (!plan_getcfg)
@@ -225,12 +230,15 @@ findcfg(Oid id)
225230
Oid
226231
name2id_cfg(text *name)
227232
{
228-
Oid arg[1] = {TEXTOID};
233+
Oid arg[1];
229234
bool isnull;
230-
Datum pars[1] = {PointerGetDatum(name)};
235+
Datum pars[1];
231236
int stat;
232237
Oid id = findSNMap_t(&(CList.name2id_map), name);
233238

239+
arg[0] = TEXTOID;
240+
pars[0] = PointerGetDatum(name);
241+
234242
if (id)
235243
return id;
236244

contrib/tsearch2/wparser.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@ static Oid current_parser_id = InvalidOid;
2727
void
2828
init_prs(Oid id, WParserInfo * prs)
2929
{
30-
Oid arg[1] = {OIDOID};
30+
Oid arg[1];
3131
bool isnull;
32-
Datum pars[1] = {ObjectIdGetDatum(id)};
32+
Datum pars[1];
3333
int stat;
3434

35+
arg[0] = OIDOID;
36+
pars[0] = ObjectIdGetDatum(id);
37+
3538
memset(prs, 0, sizeof(WParserInfo));
3639
SPI_connect();
3740
if (!plan_getparser)
@@ -132,16 +135,18 @@ static void *plan_name2id = NULL;
132135
Oid
133136
name2id_prs(text *name)
134137
{
135-
Oid arg[1] = {TEXTOID};
138+
Oid arg[1];
136139
bool isnull;
137-
Datum pars[1] = {PointerGetDatum(name)};
140+
Datum pars[1];
138141
int stat;
139142
Oid id = findSNMap_t(&(PList.name2id_map), name);
140143

144+
arg[0] = TEXTOID;
145+
pars[0] = PointerGetDatum(name);
146+
141147
if (id)
142148
return id;
143149

144-
145150
SPI_connect();
146151
if (!plan_name2id)
147152
{

contrib/tsearch2/wparser_def.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,10 @@ hlCover(HLPRSTEXT * prs, QUERYTYPE * query, int *p, int *q)
156156

157157
if (*p <= *q)
158158
{
159-
hlCheck ch = {&(prs->words[*p]), *q - *p + 1};
159+
hlCheck ch;
160160

161+
ch.words = &(prs->words[*p]);
162+
ch.len = *q - *p + 1;
161163
if (TS_execute(GETQUERY(query), &ch, false, checkcondition_HL))
162164
return true;
163165
else

0 commit comments

Comments
 (0)
0