Commit 6de3fe3c authored by Teodor Sigaev's avatar Teodor Sigaev

Avoid conflict strndup with glibc

parent 461b71f2
...@@ -41,7 +41,7 @@ strlower(char *str) ...@@ -41,7 +41,7 @@ strlower(char *str)
} }
static char* static char*
strndup(char *s, int len) { strnduplicate(char *s, int len) {
char *d=(char*)palloc( len + 1 ); char *d=(char*)palloc( len + 1 );
memcpy(d, s, len ); memcpy(d, s, len );
d[len]='\0'; d[len]='\0';
...@@ -866,7 +866,7 @@ SplitToVariants( IspellDict * Conf, SPNode *snode, SplitVar * orig, char *word, ...@@ -866,7 +866,7 @@ SplitToVariants( IspellDict * Conf, SPNode *snode, SplitVar * orig, char *word,
/* and its length more than minimal */ /* and its length more than minimal */
if ( wordlen==level+1 ) { if ( wordlen==level+1 ) {
/* well, it was last word */ /* well, it was last word */
var->stem[ var->nstem ] = strndup(word + startpos, wordlen - startpos); var->stem[ var->nstem ] = strnduplicate(word + startpos, wordlen - startpos);
var->nstem++; var->nstem++;
return var; return var;
} else { } else {
...@@ -877,7 +877,7 @@ SplitToVariants( IspellDict * Conf, SPNode *snode, SplitVar * orig, char *word, ...@@ -877,7 +877,7 @@ SplitToVariants( IspellDict * Conf, SPNode *snode, SplitVar * orig, char *word,
ptr->next=SplitToVariants(Conf, node, var, word, wordlen, startpos, level); ptr->next=SplitToVariants(Conf, node, var, word, wordlen, startpos, level);
/* we can find next word */ /* we can find next word */
level++; level++;
var->stem[ var->nstem ] = strndup(word + startpos, level - startpos); var->stem[ var->nstem ] = strnduplicate(word + startpos, level - startpos);
var->nstem++; var->nstem++;
node = Conf->Dictionary; node = Conf->Dictionary;
startpos=level; startpos=level;
...@@ -889,7 +889,7 @@ SplitToVariants( IspellDict * Conf, SPNode *snode, SplitVar * orig, char *word, ...@@ -889,7 +889,7 @@ SplitToVariants( IspellDict * Conf, SPNode *snode, SplitVar * orig, char *word,
node=StopMiddle->node; node=StopMiddle->node;
} }
var->stem[ var->nstem ] = strndup(word + startpos, wordlen - startpos); var->stem[ var->nstem ] = strnduplicate(word + startpos, wordlen - startpos);
var->nstem++; var->nstem++;
return var; return var;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment