[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: PATCH: provide %c and %u8c formatting in pickle printf()
From: |
Jose E. Marchesi |
Subject: |
Re: PATCH: provide %c and %u8c formatting in pickle printf() |
Date: |
Fri, 04 Oct 2019 14:00:29 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
> I just realized that if the last line of the dump is incomplete then the
> ascii appears displaced. Example:
>
> (poke) dump :from strtab.sh_offset :size strtab.sh_size
> 76543210 0011 2233 4455 6677 8899 aabb ccdd eeff 0123456789ABCDEF
> 000001b0: 002e 7379 6d74 6162 002e 7374 7274 6162 ..symtab..strtab
> 000001c0: 002e 7368 7374 7274 6162 002e 7465 7874 ..shstrtab..text
> 000001d0: 002e 6461 7461 002e 6273 7300 2e63 6f6d ..data..bss..com
> 000001e0: 6d65 6e74 002e 6e6f 7465 2e47 4e55 2d73 ment..note.GNU-s
> 000001f0: 7461 636b 002e 7265 6c61 2e65 685f 6672 tack..rela.eh_fr
> 00000200: 616d 6500 ame.
> (poke)
Also, if we reach end-of-file, the exception thrown will stop the hex
output and never reach the ASCII printing.
Is there a predicate we can test for EOF in the loop ?
Hmm, you could test for EOF with something like this:
defun eof = (offset<uint<64>,B> offset) int:
{
try
uint<8> @ offset;
catch if E_eof
{
return 1;
}
return 0;
}
But that seems a bit overkill? An alternative, probably more natural,
is to catch EOF around the loop, do the right thing, then re-raise:
try
THE_LOOP_INCLUDING_draw_ascii_line;
catch if E_eof
{
draw_ascii_line;
raise E_eof;
}
I wonder, maybe we would benefit from some extra language constructions
for situations like this?
For the record, there are three supported forms of try-catch in Poke:
try STMT catch COMPOUND_STMT
catches all exceptions.
try STMT catch if EXPRESSION COMPOUND_STMT
catches exceptions with code EXPRESSION
try STMT catch (Exception FORMAL) COMPOUND_STMT
catches all exceptions, FORMAL contains the exception. Exception is
defined to be of type int<32>.
- Re: PATCH: provide %c and %u8c formatting in pickle printf(), Jose E. Marchesi, 2019/10/01
- Re: PATCH: provide %c and %u8c formatting in pickle printf(), Henner Zeller, 2019/10/03
- Re: PATCH: provide %c and %u8c formatting in pickle printf(), Jose E. Marchesi, 2019/10/03
- Re: PATCH: provide %c and %u8c formatting in pickle printf(), Jose E. Marchesi, 2019/10/03
- Re: PATCH: provide %c and %u8c formatting in pickle printf(), Henner Zeller, 2019/10/03
- Re: PATCH: provide %c and %u8c formatting in pickle printf(),
Jose E. Marchesi <=
- Re: PATCH: provide %c and %u8c formatting in pickle printf(), Jose E. Marchesi, 2019/10/04
- Re: PATCH: provide %c and %u8c formatting in pickle printf(), Henner Zeller, 2019/10/05
- Re: PATCH: provide %c and %u8c formatting in pickle printf(), Jose E. Marchesi, 2019/10/05
- Re: PATCH: provide %c and %u8c formatting in pickle printf(), Jose E. Marchesi, 2019/10/05
- Re: PATCH: provide %c and %u8c formatting in pickle printf(), Jose E. Marchesi, 2019/10/04