summaryrefslogtreecommitdiffstats
path: root/src/execute.c
diff options
context:
space:
mode:
authorTimo Savinen <tjsa@iki.fi>2005-10-09 14:36:39 +0000
committerHadrien Dorio <hadrien.dorio@gmail.com>2017-12-16 00:24:05 +0100
commitb8e1dc4200c8e57024b9a37edc67f9a24c02f0e5 (patch)
tree49e33aa104913d84863a2228ca0edaf912345492 /src/execute.c
parent11460c1f56ed4939c8f0df0482059f5fecd289fa (diff)
downloadbinary-block-editor-b8e1dc4200c8e57024b9a37edc67f9a24c02f0e5.tar.gz
binary-block-editor-b8e1dc4200c8e57024b9a37edc67f9a24c02f0e5.zip
0.1.3
Diffstat (limited to 'src/execute.c')
-rw-r--r--src/execute.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/execute.c b/src/execute.c
index a69932b..ffadc3c 100644
--- a/src/execute.c
+++ b/src/execute.c
@@ -20,7 +20,7 @@
*
*/
-/* $Id: execute.c,v 1.23 2005/09/30 10:58:15 timo Exp $ */
+/* $Id: execute.c,v 1.25 2005/10/05 16:06:11 timo Exp $ */
#include "bbe.h"
#include <stdlib.h>
@@ -51,6 +51,9 @@ static struct command *current_commands;
/* commands to be executed at end of buffer */
#define BLOCK_END_COMMANDS "AJL"
+/* most significant bit of byte */
+#define BYTE_MASK (1 << (sizeof(unsigned char) * 8 - 1))
+
/* byte_to_string, convert byte value to visible string,
either hex (H), decimal (D), octal (O) or ascii (A)
@@ -58,7 +61,9 @@ static struct command *current_commands;
char *
byte_to_string(unsigned char byte,char format)
{
- static char string[10];
+ static char string[128];
+ int i;
+ int j;
switch(format)
{
@@ -74,6 +79,15 @@ byte_to_string(unsigned char byte,char format)
case 'A':
sprintf(string,"%c",isprint(byte) ? byte : ' ');
break;
+ case 'B':
+ i = 0;
+ do
+ {
+ string[i] = ((BYTE_MASK >> i) & byte) ? '1' : '0';
+ i++;
+ } while (BYTE_MASK >> i);
+ string[i] = 0;
+ break;
default:
string[0] = 0;
break;
@@ -233,7 +247,7 @@ execute_commands(struct command *c,char *command_letters)
c->rpos = 0;
if(last_byte()) // unless last byte of block
{
- if(*out_buffer.write_pos >= '0' && *out_buffer.write_pos <= '9')
+ if(*out_buffer.write_pos >= '0' && *out_buffer.write_pos <= '9')
{
a = *out_buffer.write_pos - '0';
a = (a << 4) & 0xf0;
@@ -257,6 +271,7 @@ execute_commands(struct command *c,char *command_letters)
} else
{
b = 0x0f;
+ if(*out_buffer.write_pos == 'F' || *out_buffer.write_pos == 'f') delete_this_byte=1;
}
out_buffer.write_pos[-1] = a | b;
}
@@ -273,10 +288,16 @@ execute_commands(struct command *c,char *command_letters)
a = (*out_buffer.write_pos >> 4) & 0x0f;
b = *out_buffer.write_pos & 0x0f;
*out_buffer.write_pos = '0' + a;
- if(!delete_this_byte && b != 0x0f)
+ if(!delete_this_byte)
{
write_next_byte();
- *out_buffer.write_pos = '0' + b;
+ if(b == 0x0f)
+ {
+ *out_buffer.write_pos = 'F';
+ } else
+ {
+ *out_buffer.write_pos = '0' + b;
+ }
}
}
break;
OpenPOWER on IntegriCloud