mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-30 14:22:29 +00:00
Make espeak-ng use strncpy0, etc. from libespeak-ng.
This removes the implementation of those functions from espeak-ng and use the versions in libespeak-ng. NOTE: This is needed to cross-compile to Windows.
This commit is contained in:
+3
-58
@@ -31,9 +31,9 @@
|
||||
#include "speak_lib.h"
|
||||
#include "espeak_ng.h"
|
||||
|
||||
#ifndef S_ISDIR
|
||||
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
extern void strncpy0(char *to,const char *from, int size);
|
||||
extern int utf8_in(int *c, const char *buf);
|
||||
extern int GetFileLength(const char *filename);
|
||||
|
||||
// This version of the command-line speak program uses the
|
||||
// libespeak.so.1 library
|
||||
@@ -117,61 +117,6 @@ char filetype[5];
|
||||
char wavefile[200];
|
||||
|
||||
|
||||
int GetFileLength(const char *filename)
|
||||
{
|
||||
struct stat statbuf;
|
||||
|
||||
if(stat(filename,&statbuf) != 0)
|
||||
return(0);
|
||||
|
||||
if(S_ISDIR(statbuf.st_mode))
|
||||
return(-2); // a directory
|
||||
|
||||
return(statbuf.st_size);
|
||||
}
|
||||
|
||||
|
||||
void strncpy0(char *dest, const char *source, int size)
|
||||
{
|
||||
if(source!=NULL)
|
||||
{
|
||||
strncpy(dest,source,size);
|
||||
dest[size-1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int utf8_in(int *c, const char *buf)
|
||||
{
|
||||
// Read a unicode characater from a UTF8 string
|
||||
// Returns the number of UTF8 bytes used.
|
||||
// backwards: set if we are moving backwards through the UTF8 string
|
||||
int c1;
|
||||
int n_bytes;
|
||||
int ix;
|
||||
static const unsigned char mask[4] = {0xff,0x1f,0x0f,0x07};
|
||||
|
||||
n_bytes = 0;
|
||||
|
||||
if((c1 = *buf++) & 0x80)
|
||||
{
|
||||
if((c1 & 0xe0) == 0xc0)
|
||||
n_bytes = 1;
|
||||
else if((c1 & 0xf0) == 0xe0)
|
||||
n_bytes = 2;
|
||||
else if((c1 & 0xf8) == 0xf0)
|
||||
n_bytes = 3;
|
||||
|
||||
c1 &= mask[n_bytes];
|
||||
for(ix=0; ix<n_bytes; ix++)
|
||||
{
|
||||
c1 = (c1 << 6) + (*buf++ & 0x3f);
|
||||
}
|
||||
}
|
||||
*c = c1;
|
||||
return(n_bytes+1);
|
||||
}
|
||||
|
||||
|
||||
void DisplayVoices(FILE *f_out, char *language)
|
||||
{
|
||||
int ix;
|
||||
|
||||
@@ -84,12 +84,14 @@ static unsigned char remove_accent[N_REMOVE_ACCENT] = {
|
||||
|
||||
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
void strncpy0(char *to,const char *from, int size)
|
||||
{
|
||||
// strcpy with limit, ensures a zero terminator
|
||||
strncpy(to,from,size);
|
||||
to[size-1] = 0;
|
||||
}
|
||||
#pragma GCC visibility pop
|
||||
|
||||
|
||||
int Reverse4Bytes(int word)
|
||||
|
||||
@@ -297,6 +297,7 @@ static void select_output(espeak_AUDIO_OUTPUT output_type)
|
||||
|
||||
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
int GetFileLength(const char *filename)
|
||||
{
|
||||
struct stat statbuf;
|
||||
@@ -309,6 +310,7 @@ int GetFileLength(const char *filename)
|
||||
|
||||
return(statbuf.st_size);
|
||||
}
|
||||
#pragma GCC visibility pop
|
||||
|
||||
|
||||
char *Alloc(int size)
|
||||
|
||||
@@ -599,12 +599,14 @@ int utf8_in2(int *c, const char *buf, int backwards)
|
||||
}
|
||||
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
int utf8_in(int *c, const char *buf)
|
||||
{
|
||||
// Read a unicode characater from a UTF8 string
|
||||
// Returns the number of UTF8 bytes used.
|
||||
return(utf8_in2(c,buf,0));
|
||||
}
|
||||
#pragma GCC visibility pop
|
||||
|
||||
|
||||
char *strchr_w(const char *s, int c)
|
||||
|
||||
Reference in New Issue
Block a user