Browse Source

Perform case insensitive comparisons for matching voice names.

master
Reece H. Dunn 9 years ago
parent
commit
211f103a69
2 changed files with 34 additions and 3 deletions
  1. 30
    0
      src/include/compat/strings.h
  2. 4
    3
      src/libespeak-ng/voices.c

+ 30
- 0
src/include/compat/strings.h View File

/* Compatibility shim for <strings.h>
*
* Copyright (C) 2016 Reece H. Dunn
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see: <http://www.gnu.org/licenses/>.
*/

#ifndef STRINGS_H_COMPAT_SHIM
#define STRINGS_H_COMPAT_SHIM

#ifdef _MSC_VER

#include <string.h>

#define strcasecmp stricmp

#endif

#endif

+ 4
- 3
src/libespeak-ng/voices.c View File

#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <strings.h>
#include <wctype.h> #include <wctype.h>


#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
last_part_len = strlen(last_part); last_part_len = strlen(last_part);


for (ix = 0; voices[ix] != NULL; ix++) { for (ix = 0; voices[ix] != NULL; ix++) {
if (strcmp(name, voices[ix]->name) == 0) {
if (strcasecmp(name, voices[ix]->name) == 0) {
match_name = ix; // found matching voice name match_name = ix; // found matching voice name
break; break;
} else { } else {
id = voices[ix]->identifier; id = voices[ix]->identifier;
if (strcmp(name, id) == 0)
if (strcasecmp(name, id) == 0)
match_fname = ix; // matching identifier, use this if no matching name match_fname = ix; // matching identifier, use this if no matching name
else if (strcmp(last_part, &id[strlen(id)-last_part_len]) == 0)
else if (strcasecmp(last_part, &id[strlen(id)-last_part_len]) == 0)
match_fname2 = ix; match_fname2 = ix;
} }
} }

Loading…
Cancel
Save