mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-06 02:22:56 +00:00
Skip whitespace for grammars
This commit is contained in:
parent
01c0c6948f
commit
2cf81f9dfc
@ -200,6 +200,7 @@ static int get_next_speech_channel_number(void);
|
|||||||
#define FILE_ID "file://"
|
#define FILE_ID "file://"
|
||||||
#define INLINE_ID "inline:"
|
#define INLINE_ID "inline:"
|
||||||
static int text_starts_with(const char *text, const char *match);
|
static int text_starts_with(const char *text, const char *match);
|
||||||
|
static const char *skip_initial_whitespace(const char *text);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UniMRCP parameter ID container
|
* UniMRCP parameter ID container
|
||||||
@ -531,13 +532,9 @@ static int text_starts_with(const char *text, const char *match)
|
|||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
|
text = skip_initial_whitespace(text);
|
||||||
if (!zstr(text)) {
|
if (!zstr(text)) {
|
||||||
size_t textlen, matchlen;
|
size_t textlen, matchlen;
|
||||||
|
|
||||||
/* find first non-space character */
|
|
||||||
while (switch_isspace(*text)) {
|
|
||||||
text++;
|
|
||||||
}
|
|
||||||
textlen = strlen(text);
|
textlen = strlen(text);
|
||||||
matchlen = strlen(match);
|
matchlen = strlen(match);
|
||||||
/* is there a match? */
|
/* is there a match? */
|
||||||
@ -547,6 +544,21 @@ static int text_starts_with(const char *text, const char *match)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the first non-whitespace text character in text
|
||||||
|
* @param text the text to scan
|
||||||
|
* @return pointer to the first non-whitespace char in text or the empty string if none
|
||||||
|
*/
|
||||||
|
static const char *skip_initial_whitespace(const char *text)
|
||||||
|
{
|
||||||
|
if (!zstr(text)) {
|
||||||
|
while(switch_isspace(*text)) {
|
||||||
|
text++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the audio queue
|
* Create the audio queue
|
||||||
*
|
*
|
||||||
@ -2766,6 +2778,7 @@ static switch_status_t recog_asr_load_grammar(switch_asr_handle_t *ah, const cha
|
|||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) grammar = %s, name = %s\n", schannel->name, grammar, name);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) grammar = %s, name = %s\n", schannel->name, grammar, name);
|
||||||
|
|
||||||
|
grammar = skip_initial_whitespace(grammar);
|
||||||
if (zstr(grammar)) {
|
if (zstr(grammar)) {
|
||||||
status = SWITCH_STATUS_FALSE;
|
status = SWITCH_STATUS_FALSE;
|
||||||
goto done;
|
goto done;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user