Browse Source

cleanup: remove duplicate StringToWord()

Found with pmd-cpd static analysis
master
Juho Hiltunen 2 years ago
parent
commit
d47d2d0a40

+ 19
- 0
src/libespeak-ng/common.c View File

return acc; return acc;
} }


unsigned int StringToWord(const char *string)
{
// Pack 4 characters into a word
int ix;
unsigned char c;
unsigned int word;

if (string == NULL)
return 0;

word = 0;
for (ix = 0; ix < 4; ix++) {
if (string[ix] == 0) break;
c = string[ix];
word |= (c << (ix*8));
}
return word;
}

int towlower2(unsigned int c, Translator *translator) int towlower2(unsigned int c, Translator *translator)
{ {
// check for non-standard upper to lower case conversions // check for non-standard upper to lower case conversions

+ 1
- 0
src/libespeak-ng/common.h View File

int isspace2(unsigned int c); int isspace2(unsigned int c);
int is_str_totally_null(const char* str, int size); // Tests if all bytes of str up to size are null int is_str_totally_null(const char* str, int size); // Tests if all bytes of str up to size are null
int Read4Bytes(FILE *f); int Read4Bytes(FILE *f);
unsigned int StringToWord(const char *string);
int towlower2(unsigned int c, Translator *translator); // Supports Turkish I int towlower2(unsigned int c, Translator *translator); // Supports Turkish I


ESPEAK_NG_API int utf8_in(int *c, const char *buf); ESPEAK_NG_API int utf8_in(int *c, const char *buf);

+ 1
- 20
src/libespeak-ng/compiledata.c View File

#include <espeak-ng/speak_lib.h> #include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h> #include <espeak-ng/encoding.h>


#include "common.h" // for GetFileLength, strncpy0, ...
#include "common.h" // for GetFileLength, strncpy0, ...c
#include "error.h" // for create_file_error_context #include "error.h" // for create_file_error_context
#include "mnemonics.h" // for LookupMnemName, MNEM_TAB #include "mnemonics.h" // for LookupMnemName, MNEM_TAB
#include "phoneme.h" // for PHONEME_TAB, PHONEME_TAB_LIST #include "phoneme.h" // for PHONEME_TAB, PHONEME_TAB_LIST
error("%s.", message); error("%s.", message);
} }


static unsigned int StringToWord(const char *string)
{
// Pack 4 characters into a word
int ix;
unsigned char c;
unsigned int word;

if (string == NULL)
return 0;

word = 0;
for (ix = 0; ix < 4; ix++) {
if (string[ix] == 0) break;
c = string[ix];
word |= (c << (ix*8));
}
return word;
}

static const MNEM_TAB reserved_phonemes[] = { static const MNEM_TAB reserved_phonemes[] = {
{ "_\001", phonCONTROL }, // NOT USED { "_\001", phonCONTROL }, // NOT USED
{ "%", phonSTRESS_U }, { "%", phonSTRESS_U },

+ 1
- 19
src/libespeak-ng/compilembrola.c View File

#include "mbrola.h" #include "mbrola.h"


#include "error.h" // for create_file_error_context #include "error.h" // for create_file_error_context
#include "common.h" // for StringToWord
#include "mbrola.h" // for MBROLA_TAB #include "mbrola.h" // for MBROLA_TAB
#include "phoneme.h" // for N_PHONEME_TAB #include "phoneme.h" // for N_PHONEME_TAB
#include "speech.h" // for path_home #include "speech.h" // for path_home
return current == filename ? current : current + 1; return current == filename ? current : current + 1;
} }


static unsigned int StringToWord(const char *string)
{
// Pack 4 characters into a word
int ix;
unsigned char c;
unsigned int word;

if (string == NULL)
return 0;

word = 0;
for (ix = 0; ix < 4; ix++) {
if (string[ix] == 0) break;
c = string[ix];
word |= (c << (ix*8));
}
return word;
}

#pragma GCC visibility push(default) #pragma GCC visibility push(default)
espeak_ng_STATUS espeak_ng_CompileMbrolaVoice(const char *filepath, FILE *log, espeak_ng_ERROR_CONTEXT *context) espeak_ng_STATUS espeak_ng_CompileMbrolaVoice(const char *filepath, FILE *log, espeak_ng_ERROR_CONTEXT *context)
{ {

Loading…
Cancel
Save