* updates for new mu_str escaping function, better error handling
This commit is contained in:
@ -216,7 +216,7 @@ cmd_from_string (const char *str)
|
|||||||
|
|
||||||
|
|
||||||
static Cmd
|
static Cmd
|
||||||
parse_line (const gchar *line, GSList **args)
|
parse_line (const gchar *line, GSList **args, GError **err)
|
||||||
{
|
{
|
||||||
Cmd cmd;
|
Cmd cmd;
|
||||||
GSList *lst;
|
GSList *lst;
|
||||||
@ -226,7 +226,7 @@ parse_line (const gchar *line, GSList **args)
|
|||||||
if (!line)
|
if (!line)
|
||||||
return CMD_IGNORE;
|
return CMD_IGNORE;
|
||||||
|
|
||||||
lst = mu_str_esc_to_list (line);
|
lst = mu_str_esc_to_list (line, err);
|
||||||
if (!lst)
|
if (!lst)
|
||||||
return CMD_INVALID;
|
return CMD_INVALID;
|
||||||
|
|
||||||
@ -1014,9 +1014,12 @@ mu_cmd_server (MuStore *store, MuConfig *opts, GError **err)
|
|||||||
GError *my_err;
|
GError *my_err;
|
||||||
|
|
||||||
line = my_readline (MU_PROMPT);
|
line = my_readline (MU_PROMPT);
|
||||||
cmd = parse_line (line, &args);
|
cmd = parse_line (line, &args, err);
|
||||||
g_free (line);
|
g_free (line);
|
||||||
|
|
||||||
|
if (cmd == CMD_INVALID)
|
||||||
|
|
||||||
|
|
||||||
my_err = NULL;
|
my_err = NULL;
|
||||||
if (!handle_command (cmd, store, query, args, &my_err))
|
if (!handle_command (cmd, store, query, args, &my_err))
|
||||||
g_clear_error (&my_err);
|
g_clear_error (&my_err);
|
||||||
|
|||||||
@ -194,7 +194,10 @@ get_query (MuQuery *mqx, const char* searchexpr, GError **err)
|
|||||||
Xapian::Query query;
|
Xapian::Query query;
|
||||||
char *preprocessed;
|
char *preprocessed;
|
||||||
|
|
||||||
preprocessed = mu_query_preprocess (searchexpr);
|
preprocessed = mu_query_preprocess (searchexpr, err);
|
||||||
|
if (!preprocessed)
|
||||||
|
throw std::runtime_error
|
||||||
|
("parse error while preprocessing query");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
query = mqx->query_parser().parse_query
|
query = mqx->query_parser().parse_query
|
||||||
@ -278,7 +281,7 @@ mu_query_destroy (MuQuery *self)
|
|||||||
|
|
||||||
/* preprocess a query to make them a bit more promiscuous */
|
/* preprocess a query to make them a bit more promiscuous */
|
||||||
char*
|
char*
|
||||||
mu_query_preprocess (const char *query)
|
mu_query_preprocess (const char *query, GError **err)
|
||||||
{
|
{
|
||||||
GSList *parts, *cur;
|
GSList *parts, *cur;
|
||||||
gchar *myquery;
|
gchar *myquery;
|
||||||
@ -287,7 +290,9 @@ mu_query_preprocess (const char *query)
|
|||||||
|
|
||||||
/* convert the query to a list of query terms, and escape them
|
/* convert the query to a list of query terms, and escape them
|
||||||
* separately */
|
* separately */
|
||||||
parts = mu_str_esc_to_list (query);
|
parts = mu_str_esc_to_list (query, err);
|
||||||
|
if (!parts)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
for (cur = parts; cur; cur = g_slist_next(cur)) {
|
for (cur = parts; cur; cur = g_slist_next(cur)) {
|
||||||
/* remove accents and turn to lower-case */
|
/* remove accents and turn to lower-case */
|
||||||
|
|||||||
@ -113,7 +113,7 @@ char* mu_query_as_string (MuQuery *self, const char* searchexpr, GError **err)
|
|||||||
*
|
*
|
||||||
* @return a pre-processed query, free it with g_free
|
* @return a pre-processed query, free it with g_free
|
||||||
*/
|
*/
|
||||||
char* mu_query_preprocess (const char *query)
|
char* mu_query_preprocess (const char *query, GError **err)
|
||||||
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
|
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|||||||
Reference in New Issue
Block a user