Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WI #2614 Fix wrong PictureType length when Picture is NationalEdited #2616

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion TypeCobol.Test/Parser/Memory/MemoryNational.MEM.txt
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading