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.