gnucobol-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[open-cobol-list] ACCEPT or DISPLAY AT COL without LINE


From: David Newall
Subject: [open-cobol-list] ACCEPT or DISPLAY AT COL without LINE
Date: Thu, 19 May 2016 22:43:04 +0930
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2

Hello all,

I've just joined. I'm helping move a large suite of programs written in RM/COBOL's dialect to gnu-cobol, and it seems the simplest way to do that will be to modify cobc. More on that later.

In gnu-cobol 2.0, including AT COLUMN in ACCEPT or DISPLAY without also including LINE results in "Unexpected tree tag 28". This is because the pos parameter is tested using CB_PAIR_P, to differentiate between AT LINE y COL x and AT n, however, that is the wrong test. A better test is CB_LIST_P.

This issue has been reported before, e.g. https://sourceforge.net/p/open-cobol/mailman/message/30759345/, but was incorrectly answered with, "You missed out line nn".

The cobc parser allows COL without LINE, and both the GNU COBOL 2.0 Programmers Guide (p.6-38) and the OpenCOBOL 1.1 Programmers Guide (p. 6-28) show that it is correct, as does the Final Committee Draft International Standard, ISO/IEC 1989:20xx FCD 1.0, which explicitly allows COLUMN without LINE (p. 446, clause 16.) (Never mind that the run-time behaviour specified in this standard is very different to the behaviour in RM/COBOL, and I gather in most other implementations, too.)

I offer the patch, below.

Regards,

David

----8<-------- accept_display-col-without-line.patch -8<--------8<----
--- typeck.c.orig       2016-05-19 00:27:02.300887725 +0930
+++ typeck.c    2016-05-19 21:56:15.278873231 +0930
@@ -2888,7 +2888,7 @@
                        output_screen_from (CB_FIELD (cb_ref (var)), 0);
                        gen_screen_ptr = 1;
                        if (pos) {
-                               if (CB_PAIR_P (pos)) {
+                               if (CB_LIST_P (pos)) {
                                        line = CB_PAIR_X (pos);
                                        column = CB_PAIR_Y (pos);
                                        cb_emit (cb_build_funcall_3 
("cob_screen_accept",
@@ -2909,7 +2909,7 @@
                                        cb_emit (cb_build_funcall_7 
("cob_field_accept",
                                                var, NULL, NULL, fgc, bgc,
                                                scroll, cb_int (dispattrs)));
-                               } else if (CB_PAIR_P (pos)) {
+                               } else if (CB_LIST_P (pos)) {
                                        line = CB_PAIR_X (pos);
                                        column = CB_PAIR_Y (pos);
                                        cb_emit (cb_build_funcall_7 
("cob_field_accept",
@@ -2935,7 +2935,7 @@
                        cb_emit (cb_build_funcall_7 ("cob_field_accept",
                                var, NULL, NULL, fgc, bgc, scroll,
                                cb_int (dispattrs)));
-               } else if (CB_PAIR_P (pos)) {
+               } else if (CB_LIST_P (pos)) {
                        line = CB_PAIR_X (pos);
                        column = CB_PAIR_Y (pos);
                        cb_emit (cb_build_funcall_7 ("cob_field_accept",
@@ -3408,7 +3408,7 @@
                output_screen_from (CB_FIELD (cb_ref (x)), 0);
                gen_screen_ptr = 1;
                if (pos) {
-                       if (CB_PAIR_P (pos)) {
+                       if (CB_LIST_P (pos)) {
                                line = CB_PAIR_X (pos);
                                column = CB_PAIR_Y (pos);
                                if (line == NULL) {
@@ -3433,7 +3433,7 @@
                        cb_emit (cb_build_funcall_7 ("cob_field_display",
                                CB_VALUE (values), NULL, NULL, fgc, bgc,
                                scroll, cb_int (dispattrs)));
-               } else if (CB_PAIR_P (pos)) {
+               } else if (CB_LIST_P (pos)) {
                        line = CB_PAIR_X (pos);
                        column = CB_PAIR_Y (pos);
                        if (line == NULL) {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]