Commit 50000fdc authored by rdubner's avatar rdubner
Browse files

Modifications to cprint/b and cprint/x

Got rid of a traceback-causing error that Sjaak found.  Modified /b display with "0b" prefix.
Modified /b and /x display to prefix display strings for remodded variables  with 0b and 0x
inside the brackets.
parent 39e9388c
......@@ -1657,6 +1657,7 @@ class CobolVariable():
binary_byte_limit = 16
retval = ""
if len(self.data) > 0:
retval += "0b"
output_bytes = self.data[:]
if GV_GlobalVariables.byteorder == "little" and not self.Refmod:
if (self.AttrFlags & COB_FLAG_BINARY_SWAP) == 0: # If this is ON, then it is already in display order
......@@ -4830,11 +4831,11 @@ class CPrintWorker():
body = ""
if payload.Refmod:
if GV_ModuleState.current_display_submode == DISPLAY_SUBMODE_BINARY:
body = self.GetDataAsBinary()
if not payload.display_body.startswith('"') or GV_ModuleState.current_display_submode == DISPLAY_SUBMODE_HEX:
body = "[0x" + payload.GetDataAsBinary() + ']'
elif not payload.display_body.startswith('"') or GV_ModuleState.current_display_submode == DISPLAY_SUBMODE_HEX:
# The refmod payload is not alphabetic (or the submode is x for hex) and so we are
# going to display the refmodded payload in hex:
body = '['
body = "[0x"
for i in range(len(payload.data)):
# This is a trick. By adding 256 to the byte, we ensure that
# 0, for example, becomes 0x100 instead of 0x0. Thus we can
......
......@@ -166,7 +166,7 @@ variables=[{name="header/test",value="\"' ' <repeats 40 times>\""},{name="def-CO
cprint/x 1
01 header/test [W-S] : 0x20202020202020202020202020202020...(40 total bytes)
cprint/b 1
01 header/test [W-S] : 00100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000...(40 total bytes)
01 header/test [W-S] : 0b00100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000...(40 total bytes)
KNOWN GOOD FINISH
KNOWN GOOD START
cprint/v0 *
......@@ -296,7 +296,7 @@ variables=[{name="header/test",value="\"\\\"An extravaganza of variables!\\\", '
cprint/x 1
01 header/test [W-S] : 0x416e206578747261766167616e7a6120...(40 total bytes)
cprint/b 1
01 header/test [W-S] : 01000001011011100010000001100101011110000111010001110010011000010111011001100001011001110110000101101110011110100110000100100000...(40 total bytes)
01 header/test [W-S] : 0b01000001011011100010000001100101011110000111010001110010011000010111011001100001011001110110000101101110011110100110000100100000...(40 total bytes)
KNOWN GOOD FINISH
KNOWN GOOD START
cprint/v0 *
......@@ -420,7 +420,7 @@ cprint/m ?
cprint/x 1
01 header/test [W-S] : 0x416e206578747261766167616e7a6120...(40 total bytes)
cprint/b 1
01 header/test [W-S] : 01000001011011100010000001100101011110000111010001110010011000010111011001100001011001110110000101101110011110100110000100100000...(40 total bytes)
01 header/test [W-S] : 0b01000001011011100010000001100101011110000111010001110010011000010111011001100001011001110110000101101110011110100110000100100000...(40 total bytes)
KNOWN GOOD FINISH
KNOWN GOOD START
cprint/v0 *
......@@ -543,7 +543,7 @@ cprint/m ?
cprint/x 1
01 header/test [W-S] : 0x416e206578747261766167616e7a6120...(40 total bytes)
cprint/b 1
01 header/test [W-S] : 01000001011011100010000001100101011110000111010001110010011000010111011001100001011001110110000101101110011110100110000100100000...(40 total bytes)
01 header/test [W-S] : 0b01000001011011100010000001100101011110000111010001110010011000010111011001100001011001110110000101101110011110100110000100100000...(40 total bytes)
KNOWN GOOD FINISH
KNOWN GOOD START
cprint/v0 *
......@@ -673,7 +673,7 @@ variables=[{name="header/test",value="\"\\\"An extravaganza of variables!\\\", '
cprint/x 1
01 header/test [W-S] : 0x416e206578747261766167616e7a6120...(40 total bytes)
cprint/b 1
01 header/test [W-S] : 01000001011011100010000001100101011110000111010001110010011000010111011001100001011001110110000101101110011110100110000100100000...(40 total bytes)
01 header/test [W-S] : 0b01000001011011100010000001100101011110000111010001110010011000010111011001100001011001110110000101101110011110100110000100100000...(40 total bytes)
KNOWN GOOD FINISH
KNOWN GOOD START
cprint/v0 *
......@@ -811,7 +811,7 @@ variables=[{name="header/test",value="\"\\\"An extravaganza of variables!\\\", '
cprint/x 1
01 header/test [W-S] : 0x416e206578747261766167616e7a6120...(40 total bytes)
cprint/b 1
01 header/test [W-S] : 01000001011011100010000001100101011110000111010001110010011000010111011001100001011001110110000101101110011110100110000100100000...(40 total bytes)
01 header/test [W-S] : 0b01000001011011100010000001100101011110000111010001110010011000010111011001100001011001110110000101101110011110100110000100100000...(40 total bytes)
KNOWN GOOD FINISH
KNOWN GOOD START
cprint/v0 *
......@@ -963,7 +963,7 @@ variables=[{name="def-BINARY-CHAR/test",value="\"+123\""},{name="def-BINARY-CHAR
cprint/x 1
01 def-BINARY-CHAR/test [W-S] : 0x7b
cprint/b 1
01 def-BINARY-CHAR/test [W-S] : 01111011
01 def-BINARY-CHAR/test [W-S] : 0b01111011
KNOWN GOOD FINISH
KNOWN GOOD START
cprint/v0 *
......@@ -1123,7 +1123,7 @@ variables=[{name="def-BINARY-LONG/test",value="\"+0000000011\""},{name="def-BINA
cprint/x 1
01 def-BINARY-LONG/test [W-S] : 0x0000000b
cprint/b 1
01 def-BINARY-LONG/test [W-S] : 00000000000000000000000000001011
01 def-BINARY-LONG/test [W-S] : 0b00000000000000000000000000001011
KNOWN GOOD FINISH
KNOWN GOOD START
cprint/v0 *
......@@ -1283,7 +1283,7 @@ variables=[{name="def-COMPUTATIONAL-1/test",value="\"3.3299999\""},{name="def-CO
cprint/x 1
01 def-COMPUTATIONAL-1/test [W-S] : 0x40551eb8
cprint/b 1
01 def-COMPUTATIONAL-1/test [W-S] : 01000000010101010001111010111000
01 def-COMPUTATIONAL-1/test [W-S] : 0b01000000010101010001111010111000
KNOWN GOOD FINISH
KNOWN GOOD START
cprint/v0 *
......@@ -1442,7 +1442,7 @@ variables=[{name="def-SIGNED-SHORT/test",value="\"+00025\""},{name="def-UNSIGNED
cprint/x 1
01 def-SIGNED-SHORT/test [W-S] : 0x0019
cprint/b 1
01 def-SIGNED-SHORT/test [W-S] : 0000000000011001
01 def-SIGNED-SHORT/test [W-S] : 0b0000000000011001
KNOWN GOOD FINISH
KNOWN GOOD START
cprint/v0 *
......@@ -1598,7 +1598,7 @@ variables=[{name="def-COMP/test",value="\"+988776654.1223345\""},{name="def-COMP
cprint/x 1
01 def-COMP/test [W-S] : 0x002320df0c4fc5b1
cprint/b 1
01 def-COMP/test [W-S] : 0000000000100011001000001101111100001100010011111100010110110001
01 def-COMP/test [W-S] : 0b0000000000100011001000001101111100001100010011111100010110110001
KNOWN GOOD FINISH
KNOWN GOOD START
cprint com
......
......@@ -206,6 +206,10 @@ cp ws-table(25:100)
The refmod (25:100) length has to be between 1 and 24
cp ws-table(3:4)
01 WS-TABLE(3:4) : "ABCD"
cp/x ws-table(3:4)
01 WS-TABLE(3:4) : [0x41424344]
cp/b ws-table(3:4)
01 WS-TABLE(3:4) : [0x0b01000001010000100100001101000100]
cp ws-table(three of nums1:4)
01 WS-TABLE(3:4) : "ABCD"
cp ws-table(3:four of nums2)
......@@ -395,9 +399,9 @@ cp *
42 : 03 var-tab/FILLER(1) : "1"
43 : 03 var-entry/FILLER : " "
cp/x ws-table(:)
01 WS-TABLE(1:24) : [3132414243444546202020202020202035364d4e4f505152]
01 WS-TABLE(1:24) : [0x3132414243444546202020202020202035364d4e4f505152]
cp/x ws-table(three of nums1:four of nums1)
01 WS-TABLE(3:4) : [41424344]
01 WS-TABLE(3:4) : [0x41424344]
cprint tab-adr-prgm
15 TAB-ADR-PRGM/TAB-ADR-PRGM-ID/TAB-ADR-ELEMENT/T_ADDRESSES : "First---"
cprint tab-adr-prgm(2)
......@@ -436,15 +440,15 @@ cp svalue = 1234
cp svalue
01 svalue : +001234
cp svalue(2:2) = 89
01 svalue(2:2) : [3839]
01 svalue(2:2) : [0x3839]
cp svalue
01 svalue : +684818
cp svalue(2:2) = x'89'
01 svalue(2:2) : [8900]
01 svalue(2:2) : [0x8900]
cp svalue
01 svalue : +978642
cp svalue(2:2) = x'1234'
01 svalue(2:2) : [1234]
01 svalue(2:2) : [0x1234]
cp svalue
01 svalue : +193170
cp svalue = -12345
......
......@@ -97,6 +97,10 @@ echo cp ws-table(25:100)\n
cp ws-table(25:100)
echo cp ws-table(3:4)\n
cp ws-table(3:4)
echo cp/x ws-table(3:4)\n
cp/x ws-table(3:4)
echo cp/b ws-table(3:4)\n
cp/b ws-table(3:4)
echo cp ws-table(three of nums1:4)\n
cp ws-table(three of nums1:4)
echo cp ws-table(3:four of nums2)\n
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment