* Determine number of display characters in a string. * @param s string * @return no. of display characters. */
| 116 | * @return no. of display characters. |
| 117 | */ |
| 118 | static inline size_t stringDisplayWidth(const char *s) |
| 119 | { |
| 120 | size_t n = strlen(s); |
| 121 | #ifdef HAVE_MBSRTOWCS |
| 122 | mbstate_t t; |
| 123 | |
| 124 | memset ((void *)&t, 0, sizeof (t)); /* In initial state. */ |
| 125 | /* Determine number of display characters. */ |
| 126 | n = mbsrtowcs (NULL, &s, n, &t); |
| 127 | #else |
| 128 | n = 0; |
| 129 | for (; *s; s = POPT_next_char(s)) |
| 130 | n++; |
| 131 | #endif |
| 132 | |
| 133 | return n; |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * @param opt option(s) |
no test coverage detected