Lines Matching +full:no +full:- +full:wp
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
19 * Utility functions for multibyte-character handling,
49 * For US-ASCII and UTF-8 encodings, we can safely recover from
50 * encoding errors and from non-printable characters. For any
52 * For state-dependent encodings, recovery is impossible.
53 * For arbitrary encodings, replacement of non-printable
54 * characters would be non-trivial and too fragile.
56 * returns for US-ASCII on various operating systems.
64 return strcmp(loc, "UTF-8") != 0 && in dangerous_locale()
65 strcmp(loc, "US-ASCII") != 0 && /* OpenBSD */ in dangerous_locale()
66 strcmp(loc, "ANSI_X3.4-1968") != 0 && /* Linux */ in dangerous_locale()
67 strcmp(loc, "ISO8859-1") != 0 && /* AIX */ in dangerous_locale()
84 return -1; in grow_dst()
85 *dp = tp + (*dp - *dst); in grow_dst()
93 * including the terminating '\0', to sz. Unless wp is NULL,
94 * they limit the number of display columns occupied to *wp.
97 * non-NUL bytes that would have been written if both were unlimited.
98 * If wp is NULL, newline, carriage return, and tab are allowed;
100 * written is returned in *wp.
104 vasnmprintf(char **str, size_t maxsz, int *wp, const char *fmt, va_list ap) in vasnmprintf() argument
125 ret = -1; in vasnmprintf()
137 max_width = wp == NULL ? INT_MAX : *wp; in vasnmprintf()
139 if ((len = mbtowc(&wc, sp, MB_CUR_MAX)) == -1) { in vasnmprintf()
142 ret = -1; in vasnmprintf()
146 width = -1; in vasnmprintf()
147 } else if (wp == NULL && in vasnmprintf()
152 * is only returned for wp != NULL. in vasnmprintf()
155 } else if ((width = wcwidth(wc)) == -1 && in vasnmprintf()
157 ret = -1; in vasnmprintf()
164 if (print && (dp - dst >= (int)maxsz - len || in vasnmprintf()
165 total_width > max_width - width)) in vasnmprintf()
169 &dp, len) == -1) { in vasnmprintf()
170 ret = -1; in vasnmprintf()
186 if (print && (dp - dst >= (int)maxsz - 4 || in vasnmprintf()
187 total_width > max_width - 4)) in vasnmprintf()
191 &dp, 4) == -1) { in vasnmprintf()
192 ret = -1; in vasnmprintf()
196 width = tp - dp; in vasnmprintf()
201 len--; in vasnmprintf()
212 if (wp != NULL) in vasnmprintf()
213 *wp = total_width; in vasnmprintf()
224 ret = -1; in vasnmprintf()
228 if (wp != NULL) in vasnmprintf()
229 *wp = 0; in vasnmprintf()
235 return -1; in vasnmprintf()
240 snmprintf(char *str, size_t sz, int *wp, const char *fmt, ...) in snmprintf() argument
247 ret = vasnmprintf(&cp, sz, wp, fmt, ap); in snmprintf()
258 asmprintf(char **outp, size_t sz, int *wp, const char *fmt, ...) in asmprintf() argument
265 ret = vasnmprintf(outp, sz, wp, fmt, ap); in asmprintf()
273 * return the number of non-NUL bytes written.
284 return -1; in vfmprintf()
287 ret = -1; in vfmprintf()
321 * always prefer to select C.[encoding] if possible, but there's no
342 * If we're in a UTF-8 locale then prefer to use in msetlocale()
343 * the C.UTF-8 locale (or equivalent) if it exists. in msetlocale()
345 if ((strcasestr(cp, "UTF-8") != NULL || in msetlocale()
347 (setlocale(LC_CTYPE, "C.UTF-8") != NULL || in msetlocale()
348 setlocale(LC_CTYPE, "POSIX.UTF-8") != NULL)) in msetlocale()