void-packages/srcpkgs/gnucobol/patches/move-packed-decimal.patch

30 lines
876 B
Diff

# Taken from: https://git.adelielinux.org/adelie/packages/-/commit/21fe3ef399c25f030d6657e83cc635335f3a9f40
# Tracked upstream: https://sourceforge.net/p/gnucobol/bugs/904/
diff --git a/libcob/numeric.c b/libcob/numeric.c
index 9a8ec889f2..c9c47fd017 100644
--- a/libcob/numeric.c
+++ b/libcob/numeric.c
@@ -2739,17 +2739,12 @@ cob_move_bcd (cob_field *f1, cob_field *f2)
}
} else {
unsigned char *pos = fld2 + fld2_size - 1;
- if (COB_FIELD_HAVE_SIGN (f2)) {
- if (!fld1_sign) {
- *pos &= 0xF0;
- *pos |= 0x0C;
- } else {
- *pos &= 0xF0;
- *pos |= fld1_sign;
- }
- } else {
- *pos &= 0xF0;
+ if (!COB_FIELD_HAVE_SIGN (f2)) {
*pos |= 0x0F;
+ } else if (fld1_sign == 0x0D) {
+ *pos = (*pos & 0xF0) | 0x0D;
+ } else {
+ *pos = (*pos & 0xF0) | 0x0C;
}
if (!(COB_FIELD_DIGITS (f2) & 1) /* -> digits % 2 == 0 */) {
*fld2 &= 0x0F;