0

I am using gnucobol3.1 on Ubuntu 22.04 and trying to compile source code that came from RM/COBOL running on SCO OpenServer6. Several sections of the code are in copybooks, such as the fd for files used, or our standard copyright notice. The compiler reads the files and, using the notice as example, tries to compile every word in the paragraph as a system-name. The headers are present in the source, but the compiler complains about that, too.

parsing:        /tmp/cob172970_0.cob (sourco/namfil)
sourco/library/notice2.cbl:2: warning: ENVIRONMENT DIVISION header missing - assumed [-Wothers]
sourco/library/notice2.cbl:2: warning: CONFIGURATION SECTION header missing - assumed [-Wothers]
sourco/library/notice2.cbl:2: warning: SPECIAL-NAMES header missing - assumed [-Wothers]
sourco/library/notice2.cbl:2: error: invalid system-name 'PROPRIETARY'
sourco/library/notice2.cbl:2: error: invalid system-name 'NOTICE'
sourco/library/notice2.cbl:2: error: syntax error, unexpected :, expecting CRT or Identifier
sourco/library/notice2.cbl:2: error: syntax error, unexpected ALL
sourco/library/notice2.cbl:2: error: invalid system-name 'RIGHTS'
sourco/library/notice2.cbl:4: error: invalid system-name 'THIS'
sourco/library/notice2.cbl:4: error: syntax error, unexpected CONTAINS
sourco/library/notice2.cbl:4: error: invalid system-name 'THE'
sourco/library/notice2.cbl:4: error: invalid system-name 'PROPERTIES'
sourco/library/notice2.cbl:5: error: syntax error, unexpected AND, expecting CRT or Identifier
sourco/library/notice2.cbl:5: error: invalid system-name 'TRADE'
sourco/library/notice2.cbl:5: error: syntax error, unexpected OF
sourco/library/notice2.cbl:9: error: invalid system-name 'CLIFTON'
sourco/library/notice2.cbl:9: error: invalid system-name 'JERSEY'
sourco/library/notice2.cbl:9: error: syntax error, unexpected (, expecting CRT or Identifier
sourco/library/notice2.cbl:9: error: invalid system-name 'TSI'
sourco/library/notice2.cbl:9: error: syntax error, unexpected ), expecting CRT or Identifier
sourco/library/notice2.cbl:9: error: invalid system-name 'EMBODYING'
sourco/library/notice2.cbl:10: error: invalid system-name 'CREATIVE'
sourco/library/notice2.cbl:10: etc.

Another example is this mangling of a ws condition:

sourco/namfil:36: error: syntax error, unexpected WORKING-STORAGE
sourco/ws/fildir:3: error: unknown statement '01'
sourco/ws/filstat:2: error: unknown statement '01'
sourco/ws/filstat:5: error: unknown statement '88'
sourco/ws/filstat:6: error: unknown statement '88'
sourco/ws/filstat:7: error: unknown statement '88'
sourco/ws/filstat:8: error: unknown statement '88'
sourco/ws/filstat:9: error: unknown statement '88'
sourco/ws/filstat:10: error: unknown statement '88'
sourco/ws/filstat:11: error: unknown statement '88'
sourco/ws/filstat:12: error: unknown statement '88'
sourco/ws/filstat:13: error: unknown statement '88'
sourco/ws/filstat:14: error: unknown statement '88'
sourco/ws/filstat:15: error: unknown statement '88'
sourco/ws/filstat:16: error: unknown statement '88'
sourco/ws/filstat:17: error: unknown statement '88'

...and so on down the line. Here's a snippet of that source:

       01 FILE-STATUS                          PIC X(02).
           88 I-O-OK                           VALUE "00", "02".
           88 SAME-NEXT                        VALUE "02".
           88 AT-END                           VALUE "10", "46".
           88 INVALID-KEY                      VALUE "21".
           88 DUPLICATE-KEY                    VALUE "22".
           88 RECORD-NOT-FOUND                 VALUE "23".
           88 BAD-READ                         VALUE "23", "46".
           88 KIF-FULL                         VALUE "24".
           88 PERMANENT-ERROR                  VALUE "30".
           88 SEQ-FULL                         VALUE "34".
           88 NO-FILE                          VALUE "35".**

...and so on down the line.

This code compiles on the old system. I brought it to the Ubuntu in a tarball. I've tried many combinations of cobc options but the same dismal result occurs. Full disclosure, I am very comfortable with UNIX but new to LINUX. I didn't expect so many differences between System V and BSD.

As I mentioned, I tried several compiler options, especially every flavour of -std= configuration. I tried changing the file encoding. I tried saving it in different formats from different editors. I was expecting it to at least compile, albeit with errors.

Simon Sobisch
  • 6,263
  • 1
  • 18
  • 38
frankg
  • 1
  • Please [take the tour](https://stackoverflow.com/tour) to learn how this site works and how to write good questions. As is the question looks more like a rant (no clear "this is the question, this is what I've tried"). – Simon Sobisch Feb 28 '23 at 07:22

1 Answers1

0

As the actual question is missing I'm answering "Why do I see these error messages and how can I get this code to work?"...

The problem is, that the compiler sees something it does not recognize and to provide its support of compiling code with missing headers it assumes they would have been written:

sourco/library/notice2.cbl:2: warning: ENVIRONMENT DIVISION header missing - assumed [-Wothers]
sourco/library/notice2.cbl:2: warning: CONFIGURATION SECTION header missing - assumed [-Wothers]
sourco/library/notice2.cbl:2: warning: SPECIAL-NAMES header missing - assumed [-Wothers]

It then parses the following code as SPECIAL-NAMES paragraphs. The main question here is what notice2.cbl lines 1+2 look like and what comes in the source that includes the copbook before.

The errors further down

sourco/namfil:36: error: syntax error, unexpected WORKING-STORAGE

are related and similar: the parser explicit states that it does not expect WORKING-STORAGE hereand ignores that, so the following messages are all "to be expected".
Working on this only is reasonable when the error at the top is solved, if it doesn't vanish then (which is likely), then the solution would be similar to the one above.

Simon Sobisch
  • 6,263
  • 1
  • 18
  • 38