mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-31 23:06:21 +00:00
Fix /correct quotation marks usage
Add new `parse_args_as_one()` function to just use everything after the command as the argument. Fix https://github.com/profanity-im/profanity/issues/1404
This commit is contained in:
@@ -4189,7 +4189,6 @@ _lastactivity_autocomplete(ProfWin* window, const char* const input, gboolean pr
|
|||||||
if (result) {
|
if (result) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -2443,7 +2443,7 @@ static struct cmd_t command_defs[] = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
{ "/correct",
|
{ "/correct",
|
||||||
parse_args_with_freetext, 1, 1, NULL,
|
parse_args_as_one, 1, 1, NULL,
|
||||||
CMD_NOSUBFUNCS
|
CMD_NOSUBFUNCS
|
||||||
CMD_MAINFUNC(cmd_correct)
|
CMD_MAINFUNC(cmd_correct)
|
||||||
CMD_TAGS(
|
CMD_TAGS(
|
||||||
|
|||||||
@@ -222,6 +222,33 @@ parse_args_with_freetext(const char* const inp, int min, int max, gboolean* resu
|
|||||||
return _parse_args_helper(inp, min, max, result, TRUE);
|
return _parse_args_helper(inp, min, max, result, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Will just take everything after the first space as the argument.
|
||||||
|
* Used for `/correct` so that we also include quotation marks.
|
||||||
|
*/
|
||||||
|
gchar**
|
||||||
|
parse_args_as_one(const char* const inp, int min, int max, gboolean* result)
|
||||||
|
{
|
||||||
|
gchar** args = g_malloc0(2 * sizeof(*args));
|
||||||
|
int length = g_utf8_strlen(inp, -1);
|
||||||
|
gchar* space = g_utf8_strchr(inp, length, ' ');
|
||||||
|
if (space) {
|
||||||
|
int sub_length = g_utf8_strlen(space, -1);
|
||||||
|
if (sub_length > 1) {
|
||||||
|
args[0] = g_strdup(space + 1);
|
||||||
|
*result = TRUE;
|
||||||
|
return args;
|
||||||
|
} else {
|
||||||
|
g_free(args);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
g_free(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
*result = FALSE;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
count_tokens(const char* const string)
|
count_tokens(const char* const string)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
|
|
||||||
gchar** parse_args(const char* const inp, int min, int max, gboolean* result);
|
gchar** parse_args(const char* const inp, int min, int max, gboolean* result);
|
||||||
gchar** parse_args_with_freetext(const char* const inp, int min, int max, gboolean* result);
|
gchar** parse_args_with_freetext(const char* const inp, int min, int max, gboolean* result);
|
||||||
|
gchar** parse_args_as_one(const char* const inp, int min, int max, gboolean* result);
|
||||||
int count_tokens(const char* const string);
|
int count_tokens(const char* const string);
|
||||||
char* get_start(const char* const string, int tokens);
|
char* get_start(const char* const string, int tokens);
|
||||||
GHashTable* parse_options(gchar** args, gchar** keys, gboolean* res);
|
GHashTable* parse_options(gchar** args, gchar** keys, gboolean* res);
|
||||||
|
|||||||
Reference in New Issue
Block a user