[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[open-cobol-list] Bug report and a patch: editing field get minus sign w
From: |
Ehud Karni |
Subject: |
[open-cobol-list] Bug report and a patch: editing field get minus sign when value is zero |
Date: |
Wed, 10 Jun 2009 19:32:03 +0300 |
There is a bug (feature ?) in open-cobol-1.1 (2009-02-06).
When sending a small negative value to signed edited field the result
is -0. e.g sending -0.01 to -(3)9 gives -0.
Example program is listed after the patch that fixes the bug.
Ehud.
diff -c ~/open-cobol-1.1/libcob/move.c-sv ~/open-cobol-1.1/libcob/move.c
*** ~/open-cobol-1.1/libcob/move.c-sv Sat Jan 24 15:31:30 2009
--- ~/open-cobol-1.1/libcob/move.c Wed Jun 10 19:12:37 2009
***************
*** 716,722 ****
case 'C':
case 'D':
end = dst;
! memcpy (dst++, neg ? (c == 'C' ? "CR" : "DB") :
" ", 2);
break;
case 'Z':
--- 716,722 ----
case 'C':
case 'D':
end = dst;
! memcpy (dst++, ( neg && !is_zero ) ? (c == 'C'
? "CR" : "DB") : " ", 2);
break;
case 'Z':
***************
*** 738,748 ****
is_zero = suppress_zero = 0;
}
if (trailing_sign) {
! *dst = neg ? '-' : (c == '+') ? '+' : '
';
--end;
} else if (dst == f2->data || suppress_zero) {
*dst = pad;
! sign_symbol = neg ? '-' : (c == '+') ?
'+' : ' ';
if (!curr_symbol) {
++sign_first;
}
--- 738,748 ----
is_zero = suppress_zero = 0;
}
if (trailing_sign) {
! *dst = ( neg && !is_zero ) ? '-' : (c
== '+') ? '+' : ' ';
--end;
} else if (dst == f2->data || suppress_zero) {
*dst = pad;
! sign_symbol = c ;
if (!curr_symbol) {
++sign_first;
}
***************
*** 774,779 ****
--- 774,783 ----
}
}
+ if (sign_symbol) {
+ sign_symbol = ( neg && !is_zero ) ? '-' : (sign_symbol == '+')
? '+' : ' ';
+ }
+
if (suppress_zero || (is_zero && COB_FIELD_BLANK_ZERO (f2))) {
/* all digits are zeros */
if (pad == ' ' || COB_FIELD_BLANK_ZERO (f2)) {
Example program:
identification division.
program-id. tst-prog.
environment division.
data division.
working-storage section.
01 src-rec.
05 src-1 pic S99V99 value 1.10.
05 src-2 pic S99V99 value 0.02.
05 src-3 pic S99V99 value -0.03.
05 src-4 pic S99V99 value -0.04.
05 src-5 pic S99V99 value -0.05.
05 src-6 pic S99V99 value -0.06.
05 src-7 pic S99V99 value -0.07.
05 src-8 pic S99V99 value -0.08.
05 src-9 pic S99V99 value -0.09.
05 src-10 pic S99V99 value -1.10.
01 edt-rec.
05 edt-1 pic -(04)9.
05 filler pic x(04).
05 edt-2 pic -(04)9.
05 filler pic x(04).
05 edt-3 pic -(04)9.
05 filler pic x(04).
05 edt-4 pic +(04)9.
05 filler pic x(04).
05 edt-5 pic -(05).
05 filler pic x(04).
05 edt-6 pic 9(04)-.
05 filler pic x(04).
05 edt-7 pic 9(04)+.
05 filler pic x(04).
05 edt-8 pic Z(04)+.
05 filler pic x(04).
05 edt-9 pic 9(04)DB.
05 filler pic x(04).
05 edt-10 pic 9(04)DB.
procedure division.
move " " to edt-rec.
move src-1 to edt-1.
move src-2 to edt-2.
move src-3 to edt-3.
move src-4 to edt-4.
move src-5 to edt-5.
move src-6 to edt-6.
move src-7 to edt-7.
move src-8 to edt-8.
move src-9 to edt-9.
move src-10 to edt-10.
display edt-rec.
move 0 to return-code.
stop run.
--
Ehud Karni Tel: +972-3-7966-561 /"\
Mivtach - Simon Fax: +972-3-7966-667 \ / ASCII Ribbon Campaign
Insurance agencies (USA) voice mail and X Against HTML Mail
http://www.mvs.co.il FAX: 1-815-5509341 / \
GnuPG: 98EA398D <http://www.keyserver.net/> Better Safe Than Sorry
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [open-cobol-list] Bug report and a patch: editing field get minus sign when value is zero,
Ehud Karni <=