mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-23 16:43:11 +01:00
Handle commented lines.
This commit is contained in:
parent
0695db3889
commit
85135221f0
14
cfg.c
14
cfg.c
@ -1,4 +1,4 @@
|
||||
/* $Id: cfg.c,v 1.10 2008-06-19 21:13:56 nicm Exp $ */
|
||||
/* $Id: cfg.c,v 1.11 2008-06-19 21:20:24 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -78,17 +78,11 @@ load_cfg(const char *path, char **cause)
|
||||
}
|
||||
n++;
|
||||
|
||||
/* Trim spaces from start and end. */
|
||||
while (*buf != '\0' && (*buf == ' ' || *buf == '\t'))
|
||||
*buf++ = '\0';
|
||||
len = strlen(buf);
|
||||
while (len > 0 && (buf[len - 1] == ' ' || buf[len - 1] == '\t'))
|
||||
buf[--len] = '\0';
|
||||
if (*buf == '\0')
|
||||
if ((cmd = cmd_string_parse(buf, cause)) == NULL) {
|
||||
if (*cause == NULL)
|
||||
continue;
|
||||
|
||||
if ((cmd = cmd_string_parse(buf, cause)) == NULL)
|
||||
goto error;
|
||||
}
|
||||
cfg_cause = NULL;
|
||||
|
||||
ctx.msgdata = NULL;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd-command-prompt.c,v 1.1 2008-06-19 20:45:20 nicm Exp $ */
|
||||
/* $Id: cmd-command-prompt.c,v 1.2 2008-06-19 21:20:25 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -73,6 +73,8 @@ cmd_command_prompt_callback(void *data, char *s)
|
||||
return;
|
||||
|
||||
if ((cmd = cmd_string_parse(s, &cause)) == NULL) {
|
||||
if (cause == NULL)
|
||||
return;
|
||||
*cause = toupper((u_char) *cause);
|
||||
server_set_client_message(c, cause);
|
||||
xfree(cause);
|
||||
|
10
cmd-string.c
10
cmd-string.c
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd-string.c,v 1.2 2008-06-19 21:13:56 nicm Exp $ */
|
||||
/* $Id: cmd-string.c,v 1.3 2008-06-19 21:20:27 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -39,6 +39,10 @@ cmd_string_getc(const char *s, size_t *p)
|
||||
return (s[(*p)++]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse command string. Return command or NULL on error. If returning NULL,
|
||||
* cause is error string, or NULL for empty command.
|
||||
*/
|
||||
struct cmd *
|
||||
cmd_string_parse(const char *s, char **cause)
|
||||
{
|
||||
@ -56,6 +60,8 @@ cmd_string_parse(const char *s, char **cause)
|
||||
|
||||
cmd = NULL;
|
||||
|
||||
*cause = NULL;
|
||||
|
||||
p = 0;
|
||||
for (;;) {
|
||||
ch = cmd_string_getc(s, &p);
|
||||
@ -94,7 +100,7 @@ cmd_string_parse(const char *s, char **cause)
|
||||
if (ch != EOF)
|
||||
break;
|
||||
if (argc == 0)
|
||||
goto error;
|
||||
goto out;
|
||||
|
||||
cmd = cmd_parse(argc, argv, cause);
|
||||
goto out;
|
||||
|
Loading…
Reference in New Issue
Block a user