Skip to content

Commit

Permalink
WI #2614 Fix wrong PictureType length when Picture is NationalEdited (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
efr15 committed Feb 5, 2024
1 parent 0053131 commit bb4a488
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
11 changes: 10 additions & 1 deletion TypeCobol.Test/Parser/Memory/MemoryNational.MEM.txt
Expand Up @@ -3,7 +3,7 @@ Diagnostics
None

--------- FIELD LEVEL|NAME ---------- START END LENGTH
1 ZONE 1 478 478
1 ZONE 1 514 514
5 ZONE01 1 20 20
5 ZONE02 21 108 88
10 ZONE03 21 30 10
Expand Down Expand Up @@ -40,3 +40,12 @@ Diagnostics
5 ZONE60 435 454 20
5 ZONE61 455 466 12
5 ZONE62 467 478 12
5 ZONE70 479 482 4
5 ZONE71 483 486 4
5 ZONE72 487 490 4
5 ZONE80 491 494 4
5 ZONE81 495 498 4
5 ZONE82 499 502 4
5 ZONE90 503 506 4
5 ZONE91 507 510 4
5 ZONE92 511 514 4
9 changes: 9 additions & 0 deletions TypeCobol.Test/Parser/Memory/MemoryNational.pgm
Expand Up @@ -41,6 +41,15 @@ WORKING-STORAGE SECTION.
05 ZONE60 PIC N(10) USAGE NATIONAL.
05 ZONE61 PIC 9(03).99 USAGE IS NATIONAL.
05 ZONE62 PIC ZZ9.99 USAGE IS NATIONAL.
05 ZONE70 PIC BN.
05 ZONE71 PIC 0N.
05 ZONE72 PIC /N.
05 ZONE80 PIC BN USAGE IS NATIONAL.
05 ZONE81 PIC 0N USAGE IS NATIONAL.
05 ZONE82 PIC /N USAGE IS NATIONAL.
05 ZONE90 PIC N(2) USAGE IS DISPLAY-1.
05 ZONE91 PIC G(2) USAGE IS DISPLAY-1.
05 ZONE92 PIC GB USAGE IS DISPLAY-1.

Procedure Division.
goback
Expand Down
7 changes: 7 additions & 0 deletions TypeCobol/Compiler/Types/PictureType.cs
Expand Up @@ -113,6 +113,10 @@ public override int Length
{
add = Sequence.Sum(c => c.SpecialChar == SC.B ? c.Count : 0);
}
else if (Category == PictureCategory.NationalEdited)
{
add = Sequence.Sum(c => c.SpecialChar == SC.B || c.SpecialChar == SC.ZERO || c.SpecialChar == SC.SLASH ? c.Count : 0);
}
return Size + add;
}
if (Category == PictureCategory.ExternalFloatingPoint)
Expand Down Expand Up @@ -169,6 +173,7 @@ public override int Length
case SC.S:
break;
case SC.B:
// Category cannot be NationalEdited if Usage is DISPLAY-1
if (Category == PictureCategory.DBCS)
{
len += c.Count;//double the size of B.
Expand Down Expand Up @@ -197,9 +202,11 @@ public override int Length
case SC.A:
case SC.B:
case SC.Z:
case SC.ZERO:
case SC.NINE:
case SC.DOT:
case SC.COMMA:
case SC.SLASH:
len += c.Count;//double the size.
break;
}
Expand Down

0 comments on commit bb4a488

Please sign in to comment.