mirror of
https://github.com/tmux/tmux.git
synced 2025-01-27 16:48:49 +00:00
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.
This commit is contained in:
parent
9c0147915e
commit
3e147967e2
14
cmd-string.c
14
cmd-string.c
@ -32,7 +32,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_string_getc(const char *, size_t *);
|
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_string(const char *, size_t *, char, int);
|
||||||
char *cmd_string_variable(const char *, size_t *);
|
char *cmd_string_variable(const char *, size_t *);
|
||||||
char *cmd_string_expand_tilde(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
|
int
|
||||||
cmd_string_getc(const char *s, size_t *p)
|
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 (EOF);
|
||||||
return (s[(*p)++]);
|
return (ucs[(*p)++]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_string_ungetc(unused const char *s, size_t *p)
|
cmd_string_ungetc(size_t *p)
|
||||||
{
|
{
|
||||||
(*p)--;
|
(*p)--;
|
||||||
}
|
}
|
||||||
@ -306,7 +308,7 @@ cmd_string_variable(const char *s, size_t *p)
|
|||||||
if (fch == '{' && ch != '}')
|
if (fch == '{' && ch != '}')
|
||||||
goto error;
|
goto error;
|
||||||
if (ch != EOF && fch != '{')
|
if (ch != EOF && fch != '{')
|
||||||
cmd_string_ungetc(s, p); /* ch */
|
cmd_string_ungetc(p); /* ch */
|
||||||
|
|
||||||
buf = xrealloc(buf, 1, len + 1);
|
buf = xrealloc(buf, 1, len + 1);
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
@ -337,7 +339,7 @@ cmd_string_expand_tilde(const char *s, size_t *p)
|
|||||||
home = pw->pw_dir;
|
home = pw->pw_dir;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cmd_string_ungetc(s, p);
|
cmd_string_ungetc(p);
|
||||||
if ((username = cmd_string_string(s, p, '/', 0)) == NULL)
|
if ((username = cmd_string_string(s, p, '/', 0)) == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
if ((pw = getpwnam(username)) != NULL)
|
if ((pw = getpwnam(username)) != NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user