[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: NUMVAL recognizes only uppercase "CR" and "DB".
From: |
Simon Sobisch |
Subject: |
Re: NUMVAL recognizes only uppercase "CR" and "DB". |
Date: |
Wed, 18 Jan 2023 00:28:02 +0100 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 |
Thank you for the report, this is correct.
The fix is in libcob/intrinsic.c:
static COB_INLINE COB_A_INLINE int
at_cr_or_db (const unsigned char *p)
{
- return memcmp (p, "CR", 2) == 0
- || memcmp (p, "DB", 2) == 0;
+ return (toupper (p[0]) == 'C' && toupper (p[1]) == 'R')
+ || (toupper (p[0]) == 'D' && toupper (p[1]) == 'B');
}
I'll commit this to 3.x branch along with a testsuite adjustment
tomorrow morning (will be merged to trunk in the next weeks).
Simon
Am 18.01.2023 um 00:01 schrieb Robert Dubner:
The following code, when compiled with cobc 3.2.dev, generates the output:
$ cobc -x -free -o gc playpen.cbl
./gc
123.400
123.400
123.400
-123.400
-123.400
-123.400
123.400
123.400
123.400
-123.400
123.400
123.400
123.400
The final eight values should all be " -123.400", as per the ISO/IEC
1989-2014 specification section 15.62.2:
"...CR or DB, if specified, shall be the letters 'CR' or 'DB' in uppercase
or lowercase, or a combination of uppercase and lowercase..."
======
IDENTIFICATION DIVISION.
PROGRAM-ID. intrinsix.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 FILLER.
02 numval-list-values.
03 FILLER pic X(24) value " 123.4 ".
03 FILLER pic X(24) value " + 123.4 ".
03 FILLER pic X(24) value " 123.4 + ".
03 FILLER pic X(24) value " - 123.4 ".
03 FILLER pic X(24) value " 123.4 - ".
03 FILLER pic X(24) value " 123.4 CR ".
03 FILLER pic X(24) value " 123.4 cR ".
03 FILLER pic X(24) value " 123.4 Cr ".
03 FILLER pic X(24) value " 123.4 cr ".
03 FILLER pic X(24) value " 123.4 DB ".
03 FILLER pic X(24) value " 123.4 dB ".
03 FILLER pic X(24) value " 123.4 Db ".
03 FILLER pic X(24) value " 123.4 db ".
02 FILLER redefines numval-list-values.
03 numval-list pic X(24) OCCURS 13 times.
01 numval-result PIC ---9.999.
01 i pic 999.
PROCEDURE DIVISION.
PERFORM VARYING i from 1 by 1 until i > 13
MOVE FUNCTION NUMVAL(numval-list(i)) TO numval-result
DISPLAY numval-result
END-PERFORM.
END PROGRAM intrinsix.
=====