static int add_column_width (int column, char const *buf, size_t bufsize) { size_t width; unsigned int remaining_columns = INT_MAX - column; if (buf) { if (INT_MAX / 2 <= bufsize) return INT_MAX; width = mbsnwidth (buf, bufsize, 0); } else width = bufsize; return width <= remaining_columns ? column + width : INT_MAX; }
/* Returns the number of columns needed to represent the multibyte character string pointed to by STRING. If a non-printable character occurs, and MBSW_REJECT_UNPRINTABLE is specified, -1 is returned. With flags = MBSW_REJECT_INVALID | MBSW_REJECT_UNPRINTABLE, this is the multibyte analogue of the wcswidth function. */ int mbswidth (const char *string, int flags) { return mbsnwidth (string, strlen (string), flags); }
static int rline_calc_point() { return (int)mbsnwidth(rl_line_buffer, rl_point, 0); }