Skip to content

Commit

Permalink
another more compiler warning fixed...
Browse files Browse the repository at this point in the history
libcob/intrinsic.c (cob_intr_hex_to_char): minor speedup by switch to pointer arithmetic

plus c89 line comments
  • Loading branch information
sf-mensch committed Jan 18, 2023
1 parent 9e69866 commit a917774
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion config/acu.words
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ reserved: INTERVAL-TIMER # actually a function not supported in GC
reserved: JSON
reserved: JSON-CODE # note: this is a register, move as soon as supported
reserved: JSON-STATUS # note: this is a register, move as soon as supported
reserved: JUST
reserved: JUST=JUSTIFIED
reserved: JUSTIFIED
reserved: KEPT
reserved: KEY
Expand Down
2 changes: 2 additions & 0 deletions libcob/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
has proven to be a bit faster than multiplication on pre-calculated mpz
* numeric.c (cob_cmp_packed): optimized for speed
* intrinsic.c (at_cr_or_db): fixed to do case-insensitive check
* intrinsic.c (cob_intr_hex_to_char): minor speedup by switch to pointer
arithmetic (fixing compiler warning)

2023-01-17 Simon Sobisch <[email protected]>

Expand Down
12 changes: 6 additions & 6 deletions libcob/intrinsic.c
Original file line number Diff line number Diff line change
Expand Up @@ -3916,22 +3916,22 @@ cob_intr_hex_to_char (cob_field *srcfield)
{
cob_field field;
const size_t size = srcfield->size / 2;
size_t i, j;
unsigned char *hex_char;
const unsigned char *end = srcfield->data + size * 2;
unsigned char *hex_char, *p;

if (size * 2 != srcfield->size) {
/* possibly raise nonfatal exception here -> we only process the valid ones */
// size--;
}

COB_FIELD_INIT (size, NULL, &const_alpha_attr);
make_field_entry (&field);

hex_char = curr_field->data;

for (i = j = 0; j < srcfield->size; ++i) {
p = srcfield->data;
while (p < end) {
unsigned char src, dst;
src = (cob_u8_t)srcfield->data[j++];
src = *p++;
if (src >= 'A' && src <= 'F') {
dst = src - 'A' + 10;
} else if (src >= 'a' && src <= 'f') {
Expand All @@ -3943,7 +3943,7 @@ cob_intr_hex_to_char (cob_field *srcfield)
cob_set_exception (COB_EC_ARGUMENT_FUNCTION);
}
dst *= 16;
src = (cob_u8_t)srcfield->data[j++];
src = *p++;
if (src >= 'A' && src <= 'F') {
dst = dst + src - 'A' + 10;
} else if (src >= 'a' && src <= 'f') {
Expand Down
6 changes: 3 additions & 3 deletions libcob/screenio.c
Original file line number Diff line number Diff line change
Expand Up @@ -2070,7 +2070,7 @@ cob_screen_get_all (const int initial_curs, const int accept_timeout)
mevent.bstate &= cob_mask_accept;
if (mevent.bstate != 0) {
global_return = mouse_to_exception_code (mevent.bstate);
cob_move_cursor (mline, mcolumn); // move cursor to pass position
cob_move_cursor (mline, mcolumn); /* move cursor to pass position */
goto screen_return;
}
continue;
Expand Down Expand Up @@ -3012,7 +3012,7 @@ field_accept (cob_field *f, const int sline, const int scolumn, cob_field *fgc,
mevent.bstate &= cob_mask_accept;
if (mevent.bstate != 0) {
fret = mouse_to_exception_code (mevent.bstate);
cob_move_cursor (mline, mcolumn); // move cursor to pass position
cob_move_cursor (mline, mcolumn); /* move cursor to pass position */
goto field_return;
}
}
Expand Down Expand Up @@ -3254,7 +3254,7 @@ field_accept (cob_field *f, const int sline, const int scolumn, cob_field *fgc,
mevent.bstate &= cob_mask_accept;
if (mevent.bstate != 0) {
fret = mouse_to_exception_code (mevent.bstate);
cob_move_cursor (mline, mcolumn); // move cursor to pass position
cob_move_cursor (mline, mcolumn); /* move cursor to pass position */
goto field_return;
}
continue;
Expand Down

0 comments on commit a917774

Please sign in to comment.