diff --git a/pkg/urbit/include/noun/manage.h b/pkg/urbit/include/noun/manage.h index f01784af1..4efed35ef 100644 --- a/pkg/urbit/include/noun/manage.h +++ b/pkg/urbit/include/noun/manage.h @@ -122,6 +122,11 @@ c3_c* u3m_pretty(u3_noun som); + /* u3m_pretty_path(): prettyprint a path to string. RETAIN. + */ + c3_c* + u3m_pretty_path(u3_noun som); + /* u3m_p(): dumb print with caption. RETAIN. */ void diff --git a/pkg/urbit/noun/manage.c b/pkg/urbit/noun/manage.c index 342a44618..730722ab5 100644 --- a/pkg/urbit/noun/manage.c +++ b/pkg/urbit/noun/manage.c @@ -1369,6 +1369,56 @@ u3m_pretty(u3_noun som) return pre_c; } +/* _cm_in_pretty_path: measure/cut prettyprint. + * + * Modeled after _cm_in_pretty(), the backend to u3m_p(), but with the + * assumption that we're always displaying a path. + */ +static c3_w +_cm_in_pretty_path(u3_noun som, c3_c* str_c) +{ + if ( _(u3du(som)) ) { + c3_w sel_w, one_w, two_w; + if ( str_c ) { + *(str_c++) = '/'; + } + sel_w = 1; + + one_w = _cm_in_pretty_path(u3h(som), str_c); + if ( str_c ) { + str_c += one_w; + } + + two_w = _cm_in_pretty_path(u3t(som), str_c); + if ( str_c ) { + str_c += two_w; + } + + return sel_w + one_w + two_w; + } + else { + c3_w len_w = u3r_met(3, som); + if ( str_c && len_w ) { + u3r_bytes(0, len_w, (c3_y *)str_c, som); + str_c += len_w; + } + return len_w; + } +} + +/* u3m_pretty_path(): prettyprint a path to string. +*/ +c3_c* +u3m_pretty_path(u3_noun som) +{ + c3_w len_w = _cm_in_pretty_path(som, NULL); + c3_c* pre_c = malloc(len_w + 1); + + _cm_in_pretty_path(som, pre_c); + pre_c[len_w] = 0; + return pre_c; +} + /* u3m_p(): dumb print with caption. */ void diff --git a/pkg/urbit/noun/trace.c b/pkg/urbit/noun/trace.c index 3ea98a9c2..81485d446 100644 --- a/pkg/urbit/noun/trace.c +++ b/pkg/urbit/noun/trace.c @@ -433,54 +433,6 @@ u3t_nock_trace_push(u3_noun lab) } } -/* _in_trace_pretty: measure/cut prettyprint. - * - * Modeled after _cm_in_pretty(), the backend to u3m_p(), but with the - * assumption that we're always displaying a path. - */ -static c3_w -_in_trace_pretty(u3_noun som, c3_c* str_c) -{ - if ( _(u3du(som)) ) { - c3_w sel_w, one_w, two_w; - if ( str_c ) { - *(str_c++) = '/'; - } - sel_w = 1; - - one_w = _in_trace_pretty(u3h(som), str_c); - if ( str_c ) { - str_c += one_w; - } - - two_w = _in_trace_pretty(u3t(som), str_c); - if ( str_c ) { - str_c += two_w; - } - - return sel_w + one_w + two_w; - } - else { - c3_w len_w = u3r_met(3, som); - if ( str_c && len_w ) { - u3r_bytes(0, len_w, (c3_y *)str_c, som); - str_c += len_w; - } - return len_w; - } -} - -static c3_c* -trace_pretty(u3_noun som) -{ - c3_w len_w = _in_trace_pretty(som, NULL); - c3_c* pre_c = malloc(len_w + 1); - - _in_trace_pretty(som, pre_c); - pre_c[len_w] = 0; - return pre_c; -} - /* u3t_nock_trace_pop(): pops a trace from the trace stack. * * When we remove the trace from the stack, we check to see if the sample is @@ -503,7 +455,7 @@ u3t_nock_trace_pop() // 33microseconds (a 30th of a millisecond). c3_d duration = u3t_trace_time() - start_time; if (duration > 33) { - c3_c* name = trace_pretty(lab); + c3_c* name = u3m_pretty_path(lab); fprintf(u3_Host.tra_u.fil_u, "{\"cat\": \"nock\", \"name\": \"%s\", \"ph\":\"%c\", \"pid\": %d, "