Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2018-08-19 21:02:37 +01:00
commit 3310972d75
2 changed files with 33 additions and 7 deletions

View File

@ -54,6 +54,22 @@ cmd_string_ungetc(size_t *p)
(*p)--; (*p)--;
} }
static int
cmd_string_unicode(wchar_t *wc, const char *s, size_t *p, char ch)
{
int size = (ch == 'u') ? 4 : 8;
u_int tmp;
if (size == 4 && sscanf(s + *p, "%4x", &tmp) != 1)
return (-1);
if (size == 8 && sscanf(s + *p, "%8x", &tmp) != 1)
return (-1);
*p += size;
*wc = (wchar_t)tmp;
return (0);
}
int int
cmd_string_split(const char *s, int *rargc, char ***rargv) cmd_string_split(const char *s, int *rargc, char ***rargv)
{ {
@ -191,12 +207,11 @@ cmd_string_copy(char **dst, char *src, size_t *len)
static char * static char *
cmd_string_string(const char *s, size_t *p, char endch, int esc) cmd_string_string(const char *s, size_t *p, char endch, int esc)
{ {
int ch; int ch;
char *buf, *t; wchar_t wc;
size_t len; struct utf8_data ud;
char *buf = NULL, *t;
buf = NULL; size_t len = 0;
len = 0;
while ((ch = cmd_string_getc(s, p)) != endch) { while ((ch = cmd_string_getc(s, p)) != endch) {
switch (ch) { switch (ch) {
@ -220,6 +235,18 @@ cmd_string_string(const char *s, size_t *p, char endch, int esc)
case 't': case 't':
ch = '\t'; ch = '\t';
break; break;
case 'u':
case 'U':
if (cmd_string_unicode(&wc, s, p, ch) != 0)
goto error;
if (utf8_split(wc, &ud) != UTF8_DONE)
goto error;
if (len >= SIZE_MAX - ud.size - 1)
goto error;
buf = xrealloc(buf, len + ud.size);
memcpy(buf + len, ud.data, ud.size);
len += ud.size;
continue;
} }
break; break;
case '$': case '$':

View File

@ -461,7 +461,6 @@ window_tree_build(void *modedata, u_int sort_type, uint64_t *tag,
} }
} }
static void static void
window_tree_draw_label(struct screen_write_ctx *ctx, u_int px, u_int py, window_tree_draw_label(struct screen_write_ctx *ctx, u_int px, u_int py,
u_int sx, u_int sy, const struct grid_cell *gc, const char *label) u_int sx, u_int sy, const struct grid_cell *gc, const char *label)