6 /* ---------------------------------------------------------------------- */
8 #define SAVE_STRING_COUNT 50
9 static void *strings[SAVE_STRING_COUNT];
10 static int nextstring;
12 /* ---------------------------------------------------------------------- */
18 if (strings[nextstring]) free (strings[nextstring]);
19 res = strings[nextstring] = xmalloc (n);
20 if (++nextstring == SAVE_STRING_COUNT) nextstring = 0;
24 /* ---------------------------------------------------------------------- */
27 debugstr_an (LPCSTR src, int n)
31 if (!src) return "(null)";
33 dst = res = gimme1 (n * 4 + 10);
35 while (n-- > 0 && *src)
40 case '\n': *dst++ = '\\'; *dst++ = 'n'; break;
41 case '\r': *dst++ = '\\'; *dst++ = 'r'; break;
42 case '\t': *dst++ = '\\'; *dst++ = 't'; break;
43 case '"': *dst++ = '\\'; *dst++ = '"'; break;
44 case '\\': *dst++ = '\\'; *dst++ = '\\'; break;
46 if (c >= ' ' && c <= 126)
51 *dst++ = '0' + ((c >> 6) & 7);
52 *dst++ = '0' + ((c >> 3) & 7);
53 *dst++ = '0' + ((c >> 0) & 7);
68 /* ---------------------------------------------------------------------- */
73 return debugstr_an (s, 80);
76 /* ---------------------------------------------------------------------- */
79 debugstr_wn (LPCWSTR src, int n)
83 if (!src) return "(null)";
85 dst = res = gimme1 (n * 4 + 10);
87 while (n-- > 0 && *src)
92 case '\n': *dst++ = '\\'; *dst++ = 'n'; break;
93 case '\r': *dst++ = '\\'; *dst++ = 'r'; break;
94 case '\t': *dst++ = '\\'; *dst++ = 't'; break;
95 case '"': *dst++ = '\\'; *dst++ = '"'; break;
96 case '\\': *dst++ = '\\'; *dst++ = '\\'; break;
98 if (c >= ' ' && c <= 126)
103 *dst++ = '0' + ((c >> 6) & 7);
104 *dst++ = '0' + ((c >> 3) & 7);
105 *dst++ = '0' + ((c >> 0) & 7);
120 /* ---------------------------------------------------------------------- */
123 debugstr_w (LPCWSTR s)
125 return debugstr_wn (s, 80);
128 /* ---------------------------------------------------------------------- */
129 /* This routine returns a nicely formated name of the resource res
130 If the resource name is a string, it will return '<res-name>'
131 If it is a number, it will return #<4-digit-hex-number> */
132 LPSTR debugres_a( LPCSTR res )
135 if (HIWORD(res)) return debugstr_a(res);
136 sprintf(resname, "#%04x", LOWORD(res));
137 return debugstr_a (resname);
140 LPSTR debugres_w( LPCWSTR res )
143 if (HIWORD(res)) return debugstr_w(res);
144 sprintf(resname, "#%04x", LOWORD(res));
145 return debugstr_a (resname);
148 /* ---------------------------------------------------------------------- */
150 void debug_dumpstr (LPCSTR s)
159 fputc ('\\', stderr);
163 fputc ('\\', stderr);
167 fputc ('\\', stderr);
171 fputc ('\\', stderr);
176 fprintf (stderr, "\\0x%02x", *s);