… | |
… | |
27 | #include "rxvt.h" /* NECESSARY */ |
27 | #include "rxvt.h" /* NECESSARY */ |
28 | #include "misc.intpro" /* PROTOS for internal routines */ |
28 | #include "misc.intpro" /* PROTOS for internal routines */ |
29 | |
29 | |
30 | /* EXTPROTO */ |
30 | /* EXTPROTO */ |
31 | char * |
31 | char * |
|
|
32 | rxvt_wcstombs (const wchar_t *str, int len) |
|
|
33 | { |
|
|
34 | mbstate mbs; |
|
|
35 | char *r = (char *)rxvt_malloc (len * MB_CUR_MAX + 1); |
|
|
36 | |
|
|
37 | char *dst = r; |
|
|
38 | while (len--) |
|
|
39 | { |
|
|
40 | int l = wcrtomb (dst, *str++, mbs); |
|
|
41 | if (l < 0) |
|
|
42 | *dst++ = '?'; |
|
|
43 | else |
|
|
44 | dst += l; |
|
|
45 | } |
|
|
46 | |
|
|
47 | *dst++ = 0; |
|
|
48 | |
|
|
49 | return r; |
|
|
50 | } |
|
|
51 | |
|
|
52 | /* EXTPROTO */ |
|
|
53 | char * |
32 | rxvt_strdup (const char *str) |
54 | rxvt_strdup (const char *str) |
33 | { |
55 | { |
34 | return str ? strdup (str) : 0; |
56 | return str ? strdup (str) : 0; |
35 | } |
57 | } |
36 | |
58 | |
… | |
… | |
51 | rxvt_print_error (const char *fmt,...) |
73 | rxvt_print_error (const char *fmt,...) |
52 | { |
74 | { |
53 | va_list arg_ptr; |
75 | va_list arg_ptr; |
54 | |
76 | |
55 | va_start (arg_ptr, fmt); |
77 | va_start (arg_ptr, fmt); |
56 | fprintf (stderr, APL_NAME ": "); |
78 | fprintf (stderr, RESNAME ": "); |
57 | vfprintf (stderr, fmt, arg_ptr); |
79 | vfprintf (stderr, fmt, arg_ptr); |
58 | fprintf (stderr, "\n"); |
80 | fprintf (stderr, "\n"); |
59 | va_end (arg_ptr); |
81 | va_end (arg_ptr); |
60 | } |
82 | } |
61 | |
83 | |