git.haldean.org expel / f5ef2f1
more helpful value output Haldean Brown 6 years ago
1 changed file(s) with 28 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
160160 return OK;
161161 }
162162
163 static xl_error
164 _print_ascii_word(struct xl_stream *out, xl_word word)
165 {
166 size_t written;
167 size_t buflen;
168 size_t i;
169 char *buf;
170
171 buf = xl_word_explain(word);
172 buflen = strlen(buf);
173 for (i = 0; i < buflen; i++)
174 if (buf[i] < ' ' || buf[i] > 'z')
175 return OK;
176 written = xl_stream_write(out, buf, buflen);
177 if (written != buflen)
178 return xl_raise(ERR_WRITE_FAILED, "print value");
179 free(buf);
180 return OK;
181 }
182
163183 no_ignore xl_error
164184 xl_value_print(struct xl_stream *out, struct xl_value *v)
165185 {
178198
179199 if (v->tag & TAG_LEFT_WORD)
180200 {
181 n = snprintf(buf, 64, "0x%" PRIX64, v->left.w);
201 n = snprintf(buf, 64, "0x%" PRIX64 "/", v->left.w);
182202 written = xl_stream_write(out, buf, n);
183203 if (written != n)
184204 return xl_raise(ERR_WRITE_FAILED, "print value");
205 err = _print_ascii_word(out, v->left.w);
206 if (err != OK)
207 return err;
185208 }
186209 else if (v->tag & TAG_LEFT_NODE)
187210 {
198221
199222 if (v->tag & TAG_RIGHT_WORD)
200223 {
201 n = snprintf(buf, 64, "0x%" PRIX64, v->right.w);
224 n = snprintf(buf, 64, "0x%" PRIX64 "/", v->right.w);
202225 written = xl_stream_write(out, buf, n);
203226 if (written != n)
204227 return xl_raise(ERR_WRITE_FAILED, "print value");
228 err = _print_ascii_word(out, v->right.w);
229 if (err != OK)
230 return err;
205231 }
206232 else if (v->tag & TAG_RIGHT_NODE)
207233 {