From 219f912f2f983889b686f453888493efc1f5afc1 Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Mon, 4 Feb 2008 11:38:08 +0100 Subject: [PATCH] InterpretDebug-mods: fix escaping and newlines B.W. --- InterpretDebug-mods.patch | 37 +++++++++++++++++++++--------------- core-typeof-syntax.patch | 2 +- extend-for-key-in-array-syntax.patch | 6 +++--- extend-if-key-in-array-syntax.patch | 4 ++-- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/InterpretDebug-mods.patch b/InterpretDebug-mods.patch index d7dfbd1..48e2d00 100644 --- a/InterpretDebug-mods.patch +++ b/InterpretDebug-mods.patch @@ -1,10 +1,10 @@ --- - source/interpret.c | 99 ++++++++++++++++++++++++++++++++--------------------- + source/interpret.c | 104 +++++++++++++++++++++++++++++++++-------------------- source/interpret.h | 2 - source/parse.y | 14 ++----- source/userCmds.c | 4 +- - 4 files changed, 68 insertions(+), 51 deletions(-) + 4 files changed, 73 insertions(+), 51 deletions(-) diff --quilt old/source/interpret.c new/source/interpret.c --- old/source/interpret.c @@ -77,13 +77,13 @@ diff --quilt old/source/interpret.c new/source/interpret.c SparseArrayEntry *ArrayNew(void) { - return((SparseArrayEntry *)rbTreeNew(arrayEmptyAllocator)); -+ return ((SparseArrayEntry *)rbTreeNew(arrayEmptyAllocator)); ++ return((SparseArrayEntry *)rbTreeNew(arrayEmptyAllocator)); } /* ** insert a DataValue into an array, allocate the array if needed ** keyStr must be a string that was allocated with AllocString() -@@ -3601,32 +3604,45 @@ int outPrintd() +@@ -3601,32 +3604,50 @@ int outPrintd() #ifdef DEBUG_DISASSEMBLER /* dumping values in disassembly or stack dump */ static void dumpVal(DataValue dv) { @@ -108,15 +108,20 @@ diff --quilt old/source/interpret.c new/source/interpret.c - s[k] = isprint(src[k]) ? src[k] : '?'; + for (k = 0, l = 0; src[k] && l < sizeof s - 1; k++, l++) { + char *e; -+ const char *from = "\\\"\n\t\b\r\f\v"; -+ const char *to = "\\\"ntbrfv"; -+ if (isprint(src[k])) { -+ s[l] = src[k]; ++ const char to[] = "\\\"ntbrfave"; ++#ifdef EBCDIC_CHARSET ++ const char from[] = "\\\"\n\t\b\r\f\a\v\x27"; /* EBCDIC escape */ ++#else ++ const char from[] = "\\\"\n\t\b\r\f\a\v\x1B"; /* ASCII escape */ ++#endif ++ if ((e = strchr(from, src[k]))) { ++ if (l < sizeof s - 2) { ++ s[l++] = '\\'; ++ s[l] = to[e - from]; ++ } + } -+ else if (l < sizeof s - 2 && -+ (e = strchr(from, src[k]))) { -+ s[l++] = '\\'; -+ s[l] = to[e - from]; ++ else if (isprint(src[k])) { ++ s[l] = src[k]; + } + else { + s[l] = '?'; @@ -138,7 +143,7 @@ diff --quilt old/source/interpret.c new/source/interpret.c if (!dv.val.inst) { printd(""); } -@@ -3699,96 +3715,101 @@ static void disasmInternal(Inst *inst, i +@@ -3699,98 +3720,103 @@ static void disasmInternal(Inst *inst, i "SUBR_CALL_STACKED_N", /* callSubroutineStackedN */ "UNPACKTOARGS", /* unpackArrayToArgs */ }; @@ -246,7 +251,6 @@ diff --quilt old/source/interpret.c new/source/interpret.c + printd(" %x\n", inst[i].value); } } -+ printd("\n"); } -static void disasm(Inst *inst, int nInstr) @@ -258,10 +262,13 @@ diff --quilt old/source/interpret.c new/source/interpret.c + if (name) printd(">> %s\n", name); disasmInternal(inst, nInstr); if (outIsTTY) { printd("\033[J\n"); } ++ if (name) printd("\n"); outPrintd(); } #endif /* #ifdef DEBUG_DISASSEMBLER */ -@@ -3914,11 +3935,11 @@ static void stackdumpInternal(int n, int + + #ifdef DEBUG_STACK /* for run-time stack dumping */ +@@ -3914,11 +3940,11 @@ static void stackdumpInternal(int n, int printd("--------------Stack base--------------\n"); #else if (outpt < TheStack) diff --git a/core-typeof-syntax.patch b/core-typeof-syntax.patch index cc82bb8..9cff020 100644 --- a/core-typeof-syntax.patch +++ b/core-typeof-syntax.patch @@ -148,7 +148,7 @@ diff --quilt old/source/interpret.c new/source/interpret.c ** creates appropriate error messages and returns false */ static int errCheck(const char *s) -@@ -3897,10 +3950,12 @@ static void disasmInternal(Inst *inst, i +@@ -3902,10 +3955,12 @@ static void disasmInternal(Inst *inst, i "SUBR_CALL_STACKED_N", /* callSubroutineStackedN */ "UNPACKTOARGS", /* unpackArrayToArgs */ "ARRAY_INDEX", /* arrayIndex */ diff --git a/extend-for-key-in-array-syntax.patch b/extend-for-key-in-array-syntax.patch index daae00a..65fb066 100644 --- a/extend-for-key-in-array-syntax.patch +++ b/extend-for-key-in-array-syntax.patch @@ -182,7 +182,7 @@ diff --quilt old/source/interpret.c new/source/interpret.c ** if the key exists, 1 is pushed onto the stack, otherwise 0 ** if the left argument is an array 1 is pushed onto the stack if every key ** in the left array exists in the right array, otherwise 0 -@@ -3755,10 +3895,12 @@ static void disasmInternal(Inst *inst, i +@@ -3760,10 +3900,12 @@ static void disasmInternal(Inst *inst, i "NAMED_ARGN", /* namedArgN: "fn(..., [...]=...)" */ "SWAP_TOP2", /* swapTop2: cf namedArgN */ "SUBR_CALL_STACKED_N", /* callSubroutineStackedN */ @@ -195,7 +195,7 @@ diff --quilt old/source/interpret.c new/source/interpret.c for (i = 0; i < nInstr; ++i) { printd("Prog %8p", &inst[i]); -@@ -3798,11 +3940,12 @@ static void disasmInternal(Inst *inst, i +@@ -3803,11 +3945,12 @@ static void disasmInternal(Inst *inst, i } else if (j == OP_SUBR_CALL_STACKED_N) { printd(" %s args[] (?)", inst[i+1].sym->name); @@ -209,7 +209,7 @@ diff --quilt old/source/interpret.c new/source/interpret.c } else if (j == OP_ARRAY_ITER) { printd(" %s = %s++ end-loop=(%+d) %8p", -@@ -3810,10 +3953,19 @@ static void disasmInternal(Inst *inst, i +@@ -3815,10 +3958,19 @@ static void disasmInternal(Inst *inst, i inst[i+2].sym->name, inst[i+3].value, &inst[i+3] + inst[i+3].value); diff --git a/extend-if-key-in-array-syntax.patch b/extend-if-key-in-array-syntax.patch index c47c68e..9f762f9 100644 --- a/extend-if-key-in-array-syntax.patch +++ b/extend-if-key-in-array-syntax.patch @@ -79,7 +79,7 @@ diff --quilt old/source/interpret.c new/source/interpret.c ** After: TheStack-> value, value, next, ... */ static int dupStack(void) -@@ -3717,10 +3754,11 @@ static void disasmInternal(Inst *inst, i +@@ -3722,10 +3759,11 @@ static void disasmInternal(Inst *inst, i "NAMED_ARG1", /* namedArg1: "fn([...]=..., ...)" */ "NAMED_ARGN", /* namedArgN: "fn(..., [...]=...)" */ "SWAP_TOP2", /* swapTop2: cf namedArgN */ @@ -91,7 +91,7 @@ diff --quilt old/source/interpret.c new/source/interpret.c for (i = 0; i < nInstr; ++i) { printd("Prog %8p", &inst[i]); -@@ -3777,11 +3815,12 @@ static void disasmInternal(Inst *inst, i +@@ -3782,11 +3820,12 @@ static void disasmInternal(Inst *inst, i else if (j == OP_ARRAY_REF || j == OP_ARRAY_DELETE || j == OP_ARRAY_ASSIGN || -- 2.11.4.GIT