aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmd.c11
-rw-r--r--cmd2.c18
-rw-r--r--main.c5
-rw-r--r--main.h3
-rw-r--r--utils.c7
5 files changed, 32 insertions, 12 deletions
diff --git a/cmd.c b/cmd.c
index cfb7888..7edb507 100644
--- a/cmd.c
+++ b/cmd.c
@@ -62,7 +62,7 @@ static void cmd_help _, cmd_shell _,
cmd_record _, cmd_request _, cmd_reset _, cmd_retrace _,
cmd_save _, cmd_send _, cmd_setvar _, cmd_snoop _, cmd_spawn _, cmd_stop _,
cmd_time _, cmd_var _, cmd_ver _, cmd_while _, cmd_write _,
- cmd_eval _, cmd_zap _, cmd_module _, cmd_group _, cmd_speedwalk _;
+ cmd_eval _, cmd_zap _, cmd_module _, cmd_group _, cmd_speedwalk _, cmd_groupdelim _;
#ifdef BUG_TELNET
static void cmd_color _;
@@ -103,6 +103,7 @@ cmdstruct default_commands[] =
{NULL,"file", "[=[filename]]\t\tset/show powwow definition file", cmd_file,NULL},
{NULL,"for", "([init];check;[loop]) command\twhile \"check\" is true exec \"command\"", cmd_for,NULL},
{NULL,"group", "[name] [on|off|list]\tgroup alias/action manipulation", cmd_group,NULL},
+ {NULL,"groupdelim", "[delimiter]\tchange delimiter for action/alias groups", cmd_groupdelim,NULL},
{NULL,"hilite", "[attr]\t\t\thighlight your input line", cmd_hilite,NULL},
{NULL,"history", "[{number|(expr)}]\tlist/execute commands in history", cmd_history,NULL},
{NULL,"host", "[hostname port]]\tset/show address of default host", cmd_host,NULL},
@@ -324,6 +325,14 @@ static void cmd_group __P1 (char *,arg) {
}
}
+static void cmd_groupdelim __P1 (char *,arg) {
+ if( *arg != 0 ) {
+ free( group_delim );
+ group_delim = my_strdup( arg );
+ PRINTF( "#group delimiter is now '%s'\n", group_delim );
+ }
+}
+
static void cmd_help __P1 (char *,arg)
{
int i, size;
diff --git a/cmd2.c b/cmd2.c
index fda5694..004789f 100644
--- a/cmd2.c
+++ b/cmd2.c
@@ -64,9 +64,9 @@ void show_aliases __P0 (void)
reverse_sortedlist((sortednode **)&sortedaliases);
for (p = sortedaliases; p; p = p->snext) {
escape_specials(buf, p->name);
- tty_printf("#alias %s%s@%s=%s\n",
+ tty_printf("#alias %s%s%s%s=%s\n",
p->active ? "" : "(disabled) ",
- buf,p->group == NULL ? "*" : p->group, p->subst);
+ buf, group_delim, p->group == NULL ? "*" : p->group, p->subst);
}
reverse_sortedlist((sortednode **)&sortedaliases);
}
@@ -161,10 +161,10 @@ void parse_alias __P1 (char *,str)
unescape(left);
/* break out group name (if present) */
- group = strchr( left, '@' );
+ group = strstr( left, group_delim );
if( group ) {
*group = 0;
- group++;
+ group += strlen( group_delim );
}
if (check_alias(left))
@@ -216,8 +216,9 @@ void parse_alias __P1 (char *,str)
if (*np) {
char buf[BUFSIZE];
escape_specials(buf, left);
- snprintf(inserted_next, BUFSIZE, "#alias %s@%s=%s",
+ snprintf(inserted_next, BUFSIZE, "#alias %s%s%s=%s",
buf,
+ group_delim,
(*np)->group == NULL ? "*" : (*np)->group,
(*np)->subst);
} else {
@@ -334,9 +335,10 @@ void show_actions __P0 (void)
PRINTF("#%s action%s defined%c\n", actions ? "the following" : "no",
(actions && !actions->next) ? " is" : "s are", actions ? ':' : '.');
for (p = actions; p; p = p->next)
- tty_printf("#action %c%c%s@%s %s=%s\n",
+ tty_printf("#action %c%c%s%s%s %s=%s\n",
action_chars[p->type],
p->active ? '+' : '-', p->label,
+ group_delim,
p->group == NULL ? "*" : p->group,
p->pattern,
p->command);
@@ -415,10 +417,10 @@ void parse_action __P2 (char *,str, int,onprompt)
*p = '\0';
/* break out group name (if present) */
- group = strchr( str, '@' );
+ group = strstr( str, group_delim );
if( group ) {
*group = 0;
- group++;
+ group += strlen( group_delim );
}
my_strncpy(label, str, BUFSIZE-1);
diff --git a/main.c b/main.c
index 991ae85..a9d6fc7 100644
--- a/main.c
+++ b/main.c
@@ -235,6 +235,8 @@ int delim_len [] = { 2 , 21 , 0 };
char *delim_name[] = { "normal", "program", "custom" };
int delim_mode = DELIM_NORMAL;
+/* Group delimiter */
+char *group_delim;
int main __P2 (int,argc, char **,argv)
{
@@ -252,7 +254,8 @@ int main __P2 (int,argc, char **,argv)
/* initializations */
initstr[0] = 0;
memzero(conn_list, sizeof(conn_list));
-
+ group_delim = my_strdup( "@" );
+
update_now();
ref_time = start_time = movie_last = now;
diff --git a/main.h b/main.h
index bbd9790..3d27f33 100644
--- a/main.h
+++ b/main.h
@@ -112,6 +112,9 @@ extern int delim_len[];
extern char *delim_name[];
extern int delim_mode;
+/* Group delimiter for actions/aliases, defaults to @ */
+extern char *group_delim;
+
extern char action_chars[];
#endif /* _MAIN_H_ */
diff --git a/utils.c b/utils.c
index 302d1d9..2e63215 100644
--- a/utils.c
+++ b/utils.c
@@ -1074,6 +1074,9 @@ int save_settings __P0 (void)
delim_mode == DELIM_CUSTOM ? ptrdata(pp) : "" );
}
+ if (failed > 0)
+ failed = fprintf(f, "#groupdelim %s\n", group_delim);
+
if (failed > 0 && *initstr)
failed = fprintf(f, "#init =%s\n", initstr);
@@ -1089,7 +1092,7 @@ int save_settings __P0 (void)
pp = ptrmescape(pp, alp->name, strlen(alp->name), 0);
if (MEM_ERROR) { failed = -1; break; }
failed = fprintf(f, "#alias %s%s%s=%s\n", ptrdata(pp),
- alp -> group == NULL ? "" : "@",
+ alp -> group == NULL ? "" : group_delim,
alp -> group == NULL ? "" : alp -> group,
alp->subst);
}
@@ -1100,7 +1103,7 @@ int save_settings __P0 (void)
failed = fprintf(f, "#action %c%c%s%s%s %s=%s\n",
action_chars[acp->type], acp->active ? '+' : '-',
acp->label,
- acp -> group == NULL ? "" : "@",
+ acp -> group == NULL ? "" : group_delim,
acp -> group == NULL ? "" : acp -> group,
acp->pattern, acp->command);
}