Skip to content

Commit

Permalink
Use strchr() instead of deprecated index()
Browse files Browse the repository at this point in the history
Fixes build failures on Solaris with gcc 14 since the legacy index()
function is only defined in the legacy strings.h header, but these
files only include the standard string.h header which defines the
standard strchr() function.

Signed-off-by: Alan Coopersmith <[email protected]>
  • Loading branch information
alanc authored and sthibaul committed Sep 18, 2024
1 parent f598190 commit f5a3cf4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/clients/say/say.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ int main(int argc, char **argv)
printf("Invalid language!\n");
} else {
char *locale = strdup(setlocale(LC_MESSAGES, NULL));
char *dot = index(locale, '.');
char *dot = strchr(locale, '.');
if (dot)
*dot = 0;
char *at = index(locale, '@');
char *at = strchr(locale, '@');
if (at)
*at = 0;
char *underscore = index(locale, '_');
char *underscore = strchr(locale, '_');
if (underscore)
*underscore = '-';
if (spd_set_language(conn, locale))
Expand Down
2 changes: 1 addition & 1 deletion src/modules/espeak.c
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ static SPDVoice **espeak_list_synthesis_voices()

if (!strncmp(identifier, "mb/mb-", 6)) {
voicename = g_strdup(identifier + 6);
dash = index(voicename, '-');
dash = strchr(voicename, '-');
if (dash)
/* Ignore "-en" language specification */
*dash = 0;
Expand Down

0 comments on commit f5a3cf4

Please sign in to comment.