summaryrefslogtreecommitdiff
path: root/user/gnucobol/0001-move-packed-decimal.patch
blob: d5251172ad79b724c7cf45a10495fb08fbb810b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
See also:

* https://sourceforge.net/p/gnucobol/bugs/904/

diff -ur a/gnucobol-3.2/libcob/numeric.c b/gnucobol-3.2/libcob/numeric.c
--- a/libcob/numeric.c	2023-08-18 01:07:41.324059298 +0000
+++ b/libcob/numeric.c	2023-08-18 01:31:31.294137417 +0000
@@ -2739,17 +2739,12 @@
 		}
 	} 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;