summaryrefslogtreecommitdiff
path: root/src/plugins/alias
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2010-03-02 17:34:49 +0100
committerSebastien Helleu <flashcode@flashtux.org>2010-03-02 17:34:49 +0100
commit0543b0ccc7253bd38d5f473c3e1092e2b065b6ec (patch)
tree0ae2d27cddbf087212fdaf8853133c33999172b2 /src/plugins/alias
parent282f786c1a75978ea0ad4399b7740abd6ff6486a (diff)
downloadweechat-0543b0ccc7253bd38d5f473c3e1092e2b065b6ec.zip
Add new option weechat.look.command_chars, add functions string_is_command_char and string_input_for_buffer in plugin and script API
Diffstat (limited to 'src/plugins/alias')
-rw-r--r--src/plugins/alias/alias.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/plugins/alias/alias.c b/src/plugins/alias/alias.c
index 7821b7c8f..d93a51b66 100644
--- a/src/plugins/alias/alias.c
+++ b/src/plugins/alias/alias.c
@@ -371,10 +371,10 @@ alias_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
alias_command = malloc (1 + length1 + 1 + length2 + 1);
if (alias_command)
{
- if (*ptr_cmd[0] != '/')
+ if (!weechat_string_is_command_char (*ptr_cmd))
strcpy (alias_command, "/");
else
- strcpy (alias_command, "");
+ alias_command[0] = '\0';
strcat (alias_command, *ptr_cmd);
strcat (alias_command, " ");
@@ -387,7 +387,7 @@ alias_cb (void *data, struct t_gui_buffer *buffer, int argc, char **argv,
}
else
{
- if (*ptr_cmd[0] == '/')
+ if (weechat_string_is_command_char (*ptr_cmd))
{
alias_run_command (&buffer,
(args_replaced) ? args_replaced : *ptr_cmd);
@@ -497,9 +497,9 @@ alias_new (const char *name, const char *command)
if (!name || !name[0] || !command || !command[0])
return NULL;
- while (name[0] == '/')
+ while (weechat_string_is_command_char (name))
{
- name++;
+ name = weechat_utf8_next_char (name);
}
ptr_alias = alias_search (name);
@@ -514,7 +514,8 @@ alias_new (const char *name, const char *command)
if (str_completion)
{
snprintf (str_completion, length, "%%%%%s",
- (command[0] == '/') ? command + 1 : command);
+ (weechat_string_is_command_char (command)) ?
+ weechat_utf8_next_char (command) : command);
}
new_hook = weechat_hook_command (name, command, NULL, NULL,
(str_completion) ? str_completion : NULL,
@@ -587,8 +588,8 @@ alias_get_final_command (struct t_alias *alias)
return NULL;
}
- ptr_alias = alias_search ((alias->command[0] == '/') ?
- alias->command + 1 : alias->command);
+ ptr_alias = alias_search ((weechat_string_is_command_char (alias->command)) ?
+ weechat_utf8_next_char (alias->command) : alias->command);
if (ptr_alias)
{
alias->running = 1;
@@ -596,8 +597,8 @@ alias_get_final_command (struct t_alias *alias)
alias->running = 0;
return result;
}
- return (alias->command[0] == '/') ?
- alias->command + 1 : alias->command;
+ return (weechat_string_is_command_char (alias->command)) ?
+ weechat_utf8_next_char (alias->command) : alias->command;
}
/*
@@ -812,7 +813,8 @@ alias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
if (argc > 1)
{
- alias_name = (argv[1][0] == '/') ? argv[1] + 1 : argv[1];
+ alias_name = (weechat_string_is_command_char (argv[1])) ?
+ weechat_utf8_next_char (argv[1]) : argv[1];
if (argc > 2)
{
/* Define new alias */
@@ -920,7 +922,8 @@ unalias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
{
for (i = 1; i < argc; i++)
{
- alias_name = (argv[i][0] == '/') ? argv[i] + 1 : argv[i];
+ alias_name = (weechat_string_is_command_char (argv[i])) ?
+ weechat_utf8_next_char (argv[i]) : argv[i];
ptr_alias = alias_search (alias_name);
if (!ptr_alias)
{