build: fix compilation with --disable-browser --disable-tabcomp

While doing that, move the affected function to the utils.c file
and tweak it a bit.

This fixes https://savannah.gnu.org/bugs/?52468.
master
Benno Schulenberg 2017-11-20 19:33:23 +01:00
parent bacb0f717d
commit 8165b20fc1
3 changed files with 17 additions and 14 deletions

View File

@ -2348,19 +2348,6 @@ int diralphasort(const void *va, const void *vb)
* have to use multibyte strcasecmp() instead. */
return mbstrcasecmp(a, b);
}
/* Free the memory allocated for array, which should contain len
* elements. */
void free_chararray(char **array, size_t len)
{
if (array == NULL)
return;
for (; len > 0; len--)
free(array[len - 1]);
free(array);
}
#endif
#ifdef ENABLE_TABCOMP

View File

@ -315,7 +315,6 @@ void do_savefile(void);
char *real_dir_from_tilde(const char *buf);
#if defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
int diralphasort(const void *va, const void *vb);
void free_chararray(char **array, size_t len);
#endif
#ifdef ENABLE_TABCOMP
char *input_tab(char *buf, bool allow_files, size_t *place,
@ -591,6 +590,9 @@ void snuggly_fit(char **str);
void null_at(char **data, size_t index);
void unsunder(char *str, size_t true_len);
void sunder(char *str);
#if !defined(ENABLE_TINY) || defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
void free_chararray(char **array, size_t len);
#endif
const char *fixbounds(const char *r);
#ifdef ENABLE_SPELLER
bool is_separate_word(size_t position, size_t length, const char *buf);

View File

@ -193,6 +193,20 @@ void sunder(char *str)
}
}
#if !defined(ENABLE_TINY) || defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
/* Free the memory of the given array, which should contain len elements. */
void free_chararray(char **array, size_t len)
{
if (array == NULL)
return;
while (len > 0)
free(array[--len]);
free(array);
}
#endif
/* Fix the regex if we're on platforms which require an adjustment
* from GNU-style to BSD-style word boundaries. */
const char *fixbounds(const char *r)