- *tp++ = D_QUOTE;
- while ((--len >= 0) && (c = *buf++) != '\0') {
- char temp[CCHARW_MAX + 80];
- int j = wctomb(temp, c), k;
- if (j <= 0) {
- sprintf(temp, "\\u%08X", (wint_t) c);
- j = strlen(temp);
- }
- for (k = 0; k < j; ++k) {
- tp = _nc_vischar(tp, UChar(temp[k]));
+ if (tp != 0) {
+ *tp++ = D_QUOTE;
+ while ((--len >= 0) && (c = *buf++) != '\0') {
+ char temp[CCHARW_MAX + 80];
+ int j = wctomb(temp, c), k;
+ if (j <= 0) {
+ sprintf(temp, "\\u%08X", (unsigned) c);
+ j = (int) strlen(temp);
+ }
+ for (k = 0; k < j; ++k) {
+ tp = _nc_vischar(tp, UChar(temp[k]));
+ }