1 // cl_string debugging support.
4 #include "base/cl_sysdep.h"
11 #include "cln/string.h"
17 static void dprint (cl_heap* pointer)
19 var const cl_string& obj = *(const cl_string*)&pointer;
20 fprint(cl_debugout, "(cl_string) \"");
21 var unsigned long l = obj.length();
22 for (var unsigned long i = 0; i < l; i++) {
23 var unsigned char c = obj[i];
25 if (c == '"' || c == '\\')
26 fprintchar(cl_debugout, '\\');
27 fprintchar(cl_debugout, c);
30 case '\n': fprint(cl_debugout, "\\n"); break;
31 case '\t': fprint(cl_debugout, "\\t"); break;
32 case '\b': fprint(cl_debugout, "\\b"); break;
33 case '\r': fprint(cl_debugout, "\\r"); break;
34 case '\f': fprint(cl_debugout, "\\f"); break;
35 case '\v': fprint(cl_debugout, "\\v"); break;
37 static const char hexdigits[] = "0123456789abcdef";
38 fprintchar(cl_debugout, '\\');
39 fprintchar(cl_debugout, 'x');
40 fprintchar(cl_debugout, hexdigits[(c>>4)&0x0f]);
41 fprintchar(cl_debugout, hexdigits[c&0x0f]);
45 fprint(cl_debugout, "\"");
47 AT_INITIALIZATION(dprint_string)
48 { cl_register_type_printer(cl_class_string,dprint); }
50 // This dummy links in this module when <cln/string.h> requires it.
51 int cl_string_debug_module;