Skip to content

Commit

Permalink
Fix R3-Alpha garbage trace on array input
Browse files Browse the repository at this point in the history
When tracing a parse of a block, the debug string being used would
try and print it as a string.  This is because it was using the same
output format string as for string output (%s) instead of for a value
(%r).  Although there are better modes of tracing pending, it's easy
enough to fix.

However the idea of using numbered constants in this way for the
strings is actively harmful with no benefit over writing the strings
literally in the source.  If they are to be decoupled, there should
be some benefit to it.  Leaves a remark to that effect with the fix.
  • Loading branch information
hostilefork committed Jan 21, 2016
1 parent a47822b commit 53747df
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
28 changes: 17 additions & 11 deletions src/boot/strings.r
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,24 @@ info:
; "lower security"
; "execute a system shell command: "

; !!! This R3-Alpha concept of using numbered "resource strings" is not
; very maintainable. It would probably be better to just hardcode the
; strings in the source :-/ ... but assuming it's interesting to override
; them they should be override-able somewhere. Review general solutoin.
;
trace:
"trace"
"%-02d: %50r"
" : %50r"
" : %s %50m"
" : %s"
"--> %s"
"<-- %s =="
"Parse match: %r"
"Parse input: %s"
"Parse back: %r"
"**: error : %r %r" ; 10
"trace" ; 0
"%-02d: %50r" ; 1
" : %50r" ; 2
" : %s %50m" ; 3
" : %s" ; 4
"--> %s" ; 5
"<-- %s ==" ; 6
"Parse match: %r" ; 7
"Parse input: %s" ; 8 - input is an ANY-STRING!
"Parse input: %r" ; 9 - input is an ANY-ARRAY!
"Parse back: %r" ; 10
"**: error : %r %r" ; 11

stack:
"STACK Expanded - DSP: %d MAX: %d"
Expand Down
7 changes: 6 additions & 1 deletion src/core/c-do.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ void Trace_Value(REBINT n, const REBVAL *value)
Debug_Fmt(cs_cast(BOOT_STR(RS_TRACE,n)), value);
}


//
// Trace_String: C
//
Expand All @@ -243,7 +244,11 @@ void Trace_Error(const REBVAL *value)
{
int depth;
CHECK_DEPTH(depth);
Debug_Fmt(cs_cast(BOOT_STR(RS_TRACE, 10)), &VAL_ERR_VALUES(value)->type, &VAL_ERR_VALUES(value)->id);
Debug_Fmt(
cs_cast(BOOT_STR(RS_TRACE, 11)),
&VAL_ERR_VALUES(value)->type,
&VAL_ERR_VALUES(value)->id
);
}


Expand Down
7 changes: 6 additions & 1 deletion src/core/u-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,12 @@ static REBCNT Parse_Next_Array(

if (Trace_Level) {
Trace_Value(7, item);
Trace_Value(8, blk);
if (IS_END(blk)) {
const char *end_str = "** END **";
Trace_String(8, cb_cast(end_str), strlen(end_str));
}
else
Trace_Value(9, blk);
}

// !!! The previous code did not have a handling for this, but it fell
Expand Down

0 comments on commit 53747df

Please sign in to comment.