diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-11-26 21:14:31 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-11-26 21:14:31 +0000 |
commit | fe4dbdc3fcc3d0168242f1d396dff77a7134f344 (patch) | |
tree | 2ae66ce3629205ede848ee17691c9dfa31fb4a72 /usr.bin/tmux | |
parent | b88b5ffcd3e42c2b9d35dbceb138ba10968feddd (diff) |
Get a u_char from the string, otherwise it isn't possible to enter \0377 as it
is mistaken for EOF (doh).
Also drop an unused argument.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/cmd-string.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/usr.bin/tmux/cmd-string.c b/usr.bin/tmux/cmd-string.c index 6a5a0479e5e..e663610258c 100644 --- a/usr.bin/tmux/cmd-string.c +++ b/usr.bin/tmux/cmd-string.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-string.c,v 1.10 2009/11/21 17:52:18 nicm Exp $ */ +/* $OpenBSD: cmd-string.c,v 1.11 2009/11/26 21:14:30 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -32,7 +32,7 @@ */ int cmd_string_getc(const char *, size_t *); -void cmd_string_ungetc(const char *, size_t *); +void cmd_string_ungetc(size_t *); char *cmd_string_string(const char *, size_t *, char, int); char *cmd_string_variable(const char *, size_t *); char *cmd_string_expand_tilde(const char *, size_t *); @@ -40,13 +40,15 @@ char *cmd_string_expand_tilde(const char *, size_t *); int cmd_string_getc(const char *s, size_t *p) { - if (s[*p] == '\0') + const u_char *ucs = s; + + if (ucs[*p] == '\0') return (EOF); - return (s[(*p)++]); + return (ucs[(*p)++]); } void -cmd_string_ungetc(unused const char *s, size_t *p) +cmd_string_ungetc(size_t *p) { (*p)--; } @@ -306,7 +308,7 @@ cmd_string_variable(const char *s, size_t *p) if (fch == '{' && ch != '}') goto error; if (ch != EOF && fch != '{') - cmd_string_ungetc(s, p); /* ch */ + cmd_string_ungetc(p); /* ch */ buf = xrealloc(buf, 1, len + 1); buf[len] = '\0'; @@ -337,7 +339,7 @@ cmd_string_expand_tilde(const char *s, size_t *p) home = pw->pw_dir; } } else { - cmd_string_ungetc(s, p); + cmd_string_ungetc(p); if ((username = cmd_string_string(s, p, '/', 0)) == NULL) return (NULL); if ((pw = getpwnam(username)) != NULL) |