summaryrefslogtreecommitdiffstats
path: root/cmd-string.c
authortcunha <tcunha>2009-11-28 14:45:30 (GMT)
committer tcunha <tcunha>2009-11-28 14:45:30 (GMT)
commit0c9f59fbc15b5a4692ca1923e728c9c4c7e2528a (patch) (side-by-side diff)
tree4cae1175e8bcd09ddf38f15b77a5a6d549b14c55 /cmd-string.c
parenta7a79cb891b36826be97cf4295e2b8085eb6573e (diff)
downloadtmux-old-0c9f59fbc15b5a4692ca1923e728c9c4c7e2528a.zip
tmux-old-0c9f59fbc15b5a4692ca1923e728c9c4c7e2528a.tar.gz
tmux-old-0c9f59fbc15b5a4692ca1923e728c9c4c7e2528a.tar.bz2
Sync OpenBSD patchset 565:
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 'cmd-string.c') (more/less context) (ignore whitespace changes)
-rw-r--r--cmd-string.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/cmd-string.c b/cmd-string.c
index 5c000e1..ca4fbb1 100644
--- a/cmd-string.c
+++ b/cmd-string.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-string.c,v 1.27 2009/11/22 00:13:34 tcunha Exp $ */
+/* $Id: cmd-string.c,v 1.28 2009/11/28 14:45:30 tcunha Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <[email protected]>
@@ -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)