=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/utf8.c,v retrieving revision 1.39 retrieving revision 1.40 diff -c -r1.39 -r1.40 *** src/usr.bin/tmux/utf8.c 2017/06/04 09:02:57 1.39 --- src/usr.bin/tmux/utf8.c 2019/03/18 20:53:33 1.40 *************** *** 1,4 **** ! /* $OpenBSD: utf8.c,v 1.39 2017/06/04 09:02:57 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: utf8.c,v 1.40 2019/03/18 20:53:33 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott *************** *** 381,446 **** s++; } return (width); - } - - /* Trim UTF-8 string to width. Caller frees. */ - char * - utf8_trimcstr(const char *s, u_int width) - { - struct utf8_data *tmp, *next; - char *out; - u_int at; - - tmp = utf8_fromcstr(s); - - at = 0; - for (next = tmp; next->size != 0; next++) { - if (at + next->width > width) { - next->size = 0; - break; - } - at += next->width; - } - - out = utf8_tocstr(tmp); - free(tmp); - return (out); - } - - /* Trim UTF-8 string to width. Caller frees. */ - char * - utf8_rtrimcstr(const char *s, u_int width) - { - struct utf8_data *tmp, *next, *end; - char *out; - u_int at; - - tmp = utf8_fromcstr(s); - - for (end = tmp; end->size != 0; end++) - /* nothing */; - if (end == tmp) { - free(tmp); - return (xstrdup("")); - } - next = end - 1; - - at = 0; - for (;;) { - if (at + next->width > width) { - next++; - break; - } - at += next->width; - - if (next == tmp) - break; - next--; - } - - out = utf8_tocstr(next); - free(tmp); - return (out); } /* Pad UTF-8 string to width. Caller frees. */ --- 381,386 ----