*/ void Debug_String(const void *p, REBCNT len, REBOOL uni, REBINT lines) /* ***********************************************************************/ { REBUNI uc; const REBYTE *bp = uni ? NULL : cast(const REBYTE *, p); const REBUNI *up = uni ? cast(const REBUNI *, p) : NULL; if (Trace_Limit > 0) { if (Trace_Buffer->tail >= Trace_Limit) Remove_Series(Trace_Buffer, 0, 2000); if (len == UNKNOWN) len = uni ? Strlen_Uni(up) : LEN_BYTES(bp); // !!! account for unicode! for (; len > 0; len--) { uc = uni ? *up++ : *bp++; Append_Byte(Trace_Buffer, uc); } //Append_Unencoded_Len(Trace_Buffer, bp, len); for (; lines > 0; lines--) Append_Byte(Trace_Buffer, LF); } else { Prin_OS_String(p, len, uni); for (; lines > 0; lines--) Print_OS_Line(); } }
*/ void Out_Str(const REBYTE *bp, REBINT lines) /* ***********************************************************************/ { Prin_OS_String(bp, UNKNOWN, 0); for (; lines > 0; lines--) Print_OS_Line(); }
*/ void Display_Backtrace(REBCNT lines) /* ***********************************************************************/ { REBCNT tail; REBCNT i; if (Trace_Limit > 0) { tail = Trace_Buffer->tail; i = tail - 1; for (lines++ ;lines > 0; lines--, i--) { i = Find_Str_Char(Trace_Buffer, 0, i, tail, -1, LF, 0); if (i == NOT_FOUND || i == 0) { i = 0; break; } } if (lines == 0) i += 2; // start of next line Prin_OS_String(BIN_SKIP(Trace_Buffer, i), tail-i, 0); //RESET_SERIES(Trace_Buffer); } else { Out_Str(cb_cast("backtrace not enabled"), 1); } }
static REBFLG Print_Native_Modifying_Throws( REBVAL *value, // Value may be modified. Contents must be GC-safe! REBOOL newline ) { if (IS_UNSET(value)) { #if !defined(NDEBUG) if (LEGACY(OPTIONS_PRINT_FORMS_EVERYTHING)) goto form_it; #endif // No effect (not even a newline). Previously this also was the // behavior for NONE, but now that none is considered "reified" it // does not opt out from rendering. } else if (IS_BINARY(value)) { #if !defined(NDEBUG) if (LEGACY(OPTIONS_PRINT_FORMS_EVERYTHING)) goto form_it; #endif // Send raw bytes to the console. CGI+ANSI+VT100 etc. require it // for full 8-bit byte transport (UTF-8 is by definition not good // enough...some bytes are illegal to occur in UTF-8 at all). // // Given that PRINT is not a general-purpose PROBE tool (it has // never output values purely "as is", evaluating blocks for // instance) it's worth doing a "strange" thing (though no stranger // than WRITE) to be able to access the facility. Prin_OS_String(VAL_BIN_DATA(value), VAL_LEN(value), OPT_ENC_RAW); // !!! Binary print should never output a newline. This would seem // more natural if PRINT's decision to output newlines was guided // by whether it was given a block or not (under consideration). } else if (IS_BLOCK(value)) { // !!! Pending plan for PRINT of BLOCK! is to do something like // COMBINE where NONE! is elided, single characters are not spaced out, // nested blocks are recursed, etc. So: // // print ["A" newline "B" if 1 > 2 [newline] if 1 < 2 ["C"]]] // // Would output the following (where _ is space): // // A // B_C // // As opposed to historical output, which is: // // A_ // B_none_C // // Currently it effectively FORM REDUCEs the output. if (Reduce_Block_Throws( value, VAL_SERIES(value), VAL_INDEX(value), FALSE )) { return TRUE; } Prin_Value(value, 0, 0); if (newline) Print_OS_Line(); } else { #if !defined(NDEBUG) form_it: // used only by OPTIONS_PRINT_FORMS_EVERYTHING #endif // !!! Full behavior review needed for all types. Prin_Value(value, 0, 0); if (newline) Print_OS_Line(); } return FALSE; }