Skip to content

Commit

Permalink
portability fix for [r5249]
Browse files Browse the repository at this point in the history
additional: adjusted indent in testsuite for improved COBOL85 compat
  • Loading branch information
sf-mensch committed May 6, 2024
1 parent ed789c8 commit 1daa393
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 89 deletions.
160 changes: 80 additions & 80 deletions tests/testsuite.src/run_file.at
Original file line number Diff line number Diff line change
Expand Up @@ -4291,13 +4291,13 @@ fexists_signed (char *fid, char *signature, int signature_size)

f = fopen (fid, "r");
if (f != NULL) {
bfr = (char *) cob_malloc (signature_size);
if (1 == fread (bfr, signature_size, 1, f)) {
bfr = (char *) cob_malloc (signature_size);
if (1 == fread (bfr, signature_size, 1, f)) {
if (!memcmp (signature, bfr, signature_size)) {
res = 0;
res = 0;
}
}
free (bfr);
}
free (bfr);
}
return res;
}
Expand Down Expand Up @@ -13787,7 +13787,7 @@ AT_DATA([prog.cob], [
ASCENDING sort-entry
USING SORT-IN
GIVING SORT-IN.
STOP RUN.
STOP RUN.
])

AT_CHECK([$COMPILE prog.cob], [0], [], [])
Expand Down Expand Up @@ -13990,11 +13990,11 @@ AT_DATA([prog.cob], [
2 file4-key2 pic 9.
2 filler pic x(10).
PROCEDURE DIVISION.
MERGE file4 ON ASCENDING file4-key1
MERGE file4 ON ASCENDING file4-key1
DESCENDING file4-key2
USING file1 file2
GIVING file3.
STOP RUN.
STOP RUN.
])

AT_CHECK([$COMPILE prog.cob], [0], [], [])
Expand Down Expand Up @@ -14050,7 +14050,7 @@ AT_DATA([prog.cob], [
ASCENDING KEY WRK-REC
USING SORT-IN
GIVING SORT-OUT.
STOP RUN.
STOP RUN.
])

AT_CHECK([$COMPILE prog.cob], [0], [], [])
Expand Down Expand Up @@ -14111,37 +14111,37 @@ AT_DATA([prog.cob], [
3 1-data pic x(10).
PROCEDURE DIVISION.
a01-main.
SORT file1 ON ASCENDING file1-key
INPUT PROCEDURE a02-release-to-sort
OUTPUT PROCEDURE a03-return-from-sort.
STOP RUN.
SORT file1 ON ASCENDING file1-key
INPUT PROCEDURE a02-release-to-sort
OUTPUT PROCEDURE a03-return-from-sort.
STOP RUN.
*
a02-release-to-sort.
PERFORM VARYING ix-1 FROM 1 BY 2 UNTIL ix-1 > 26
RELEASE file1-rec from 1-record(ix-1)
END-PERFORM.
PERFORM VARYING ix-1 FROM 2 BY 2 UNTIL ix-1 > 26
RELEASE file1-rec from 1-record(ix-1)
END-PERFORM.
PERFORM VARYING ix-1 FROM 1 BY 2 UNTIL ix-1 > 26
RELEASE file1-rec from 1-record(ix-1)
END-PERFORM.
PERFORM VARYING ix-1 FROM 2 BY 2 UNTIL ix-1 > 26
RELEASE file1-rec from 1-record(ix-1)
END-PERFORM.
*
a03-return-from-sort.
PERFORM VARYING ix-1 FROM 1 BY 1
UNTIL (ix-1 > 26) OR (w-eof = 1)
RETURN file1 RECORD
AT END MOVE 1 TO w-eof
END-RETURN
IF (file1-rec <> 1-record(ix-1))
MOVE 1 TO w-eof
END-IF
END-PERFORM.
IF (w-eof = 1)
DISPLAY "FAILED: unexpected eof"
ELSE
RETURN file1 RECORD
AT END CONTINUE
NOT AT END DISPLAY "FAILED: expected eof"
END-RETURN
END-IF.
PERFORM VARYING ix-1 FROM 1 BY 1
UNTIL (ix-1 > 26) OR (w-eof = 1)
RETURN file1 RECORD
AT END MOVE 1 TO w-eof
END-RETURN
IF (file1-rec <> 1-record(ix-1))
MOVE 1 TO w-eof
END-IF
END-PERFORM.
IF (w-eof = 1)
DISPLAY "FAILED: unexpected eof"
ELSE
RETURN file1 RECORD
AT END CONTINUE
NOT AT END DISPLAY "FAILED: expected eof"
END-RETURN
END-IF.
])

AT_CHECK([$COMPILE prog.cob], [0], [], [])
Expand Down Expand Up @@ -14189,11 +14189,11 @@ AT_DATA([prog.cob], [
2 file3-key2 pic 9.
2 file3-dot pic x.
PROCEDURE DIVISION.
SORT file3 ON ASCENDING file3-key1
DESCENDING file3-key2
USING file1
GIVING file2.
STOP RUN.
SORT file3 ON ASCENDING file3-key1
DESCENDING file3-key2
USING file1
GIVING file2.
STOP RUN.
])

AT_CHECK([$COMPILE prog.cob], [0], [], [])
Expand Down Expand Up @@ -14242,38 +14242,38 @@ AT_DATA([prog.cob], [
PROCEDURE DIVISION.
DECLARATIVES.
P01 SECTION.
USE AFTER ERROR PROCEDURE ON FILE-EXT.
USE AFTER ERROR PROCEDURE ON FILE-EXT.
P0101.
DISPLAY "ERROR ON FILE-EXT".
DISPLAY "ERROR ON FILE-EXT".
P02 SECTION.
USE AFTER ERROR PROCEDURE ON OUTPUT.
USE AFTER ERROR PROCEDURE ON OUTPUT.
P0201.
DISPLAY "ERROR ON OUTPUT".
DISPLAY "ERROR ON OUTPUT".
END DECLARATIVES.
MAIN SECTION.
OPEN OUTPUT FILE-EXT.
CALL "NESTED-PROGRAM-1-1".
OPEN OUTPUT FILE-EXT.
CALL "NESTED-PROGRAM-1-1".
* The next line triggers a SILENT error in NESTED-PROGRAM-1-2
CLOSE FILE-EXT.
CALL "NESTED-PROGRAM-1-2".
GOBACK.
CLOSE FILE-EXT.
CALL "NESTED-PROGRAM-1-2".
GOBACK.

IDENTIFICATION DIVISION.
PROGRAM-ID. NESTED-PROGRAM-1-1.
PROCEDURE DIVISION.
NESTED-PROGRAM .
WRITE FILE-EXT-REC FROM "Hello".
DISPLAY "1-1 TRIED TO WRITE".
GOBACK.
WRITE FILE-EXT-REC FROM "Hello".
DISPLAY "1-1 TRIED TO WRITE".
GOBACK.
END PROGRAM NESTED-PROGRAM-1-1.

IDENTIFICATION DIVISION.
PROGRAM-ID. NESTED-PROGRAM-1-2.
PROCEDURE DIVISION.
NESTED-PROGRAM .
WRITE FILE-EXT-REC FROM "Hello".
DISPLAY "1-2 TRIED TO WRITE".
GOBACK.
WRITE FILE-EXT-REC FROM "Hello".
DISPLAY "1-2 TRIED TO WRITE".
GOBACK.
END PROGRAM NESTED-PROGRAM-1-2.

END PROGRAM NESTED-PROGRAM-1.
Expand All @@ -14294,9 +14294,9 @@ AT_DATA([prog2.cob], [
IDENTIFICATION DIVISION.
PROGRAM-ID. NESTED-FILES.
PROCEDURE DIVISION.
CALL "NESTED-PROGRAM-1".
CALL "NESTED-PROGRAM-2".
STOP RUN.
CALL "NESTED-PROGRAM-1".
CALL "NESTED-PROGRAM-2".
STOP RUN.

IDENTIFICATION DIVISION.
PROGRAM-ID. NESTED-PROGRAM-1.
Expand All @@ -14314,50 +14314,50 @@ AT_DATA([prog2.cob], [
DECLARATIVES.
P01 SECTION.
* This one is GLOBAL and should be called from within nested programs
USE GLOBAL AFTER ERROR PROCEDURE ON FILE-EXT.
USE GLOBAL AFTER ERROR PROCEDURE ON FILE-EXT.
P0101.
DISPLAY "ERROR ON FILE-EXT".
DISPLAY "ERROR ON FILE-EXT".
P02 SECTION.
USE AFTER ERROR PROCEDURE ON OUTPUT.
USE AFTER ERROR PROCEDURE ON OUTPUT.
P0201.
DISPLAY "ERROR ON OUTPUT".
DISPLAY "ERROR ON OUTPUT".
END DECLARATIVES.
MAIN SECTION.
OPEN OUTPUT FILE-EXT.
CALL "NESTED-PROGRAM-1-1".
DISPLAY "CLOSING FILE DESCRIPTOR".
CLOSE FILE-EXT.
CALL "NESTED-PROGRAM-1-2".
GOBACK.
OPEN OUTPUT FILE-EXT.
CALL "NESTED-PROGRAM-1-1".
DISPLAY "CLOSING FILE DESCRIPTOR".
CLOSE FILE-EXT.
CALL "NESTED-PROGRAM-1-2".
GOBACK.

IDENTIFICATION DIVISION.
PROGRAM-ID. NESTED-PROGRAM-1-1.
PROCEDURE DIVISION.
NESTED-PROGRAM .
DISPLAY "ENTERING NESTED-PROGRAM-1-1".
DISPLAY "TRYING TO WRITE".
WRITE FILE-EXT-REC FROM "Hello".
DISPLAY "EXITING NESTED-PROGRAM-1-1".
GOBACK.
DISPLAY "ENTERING NESTED-PROGRAM-1-1".
DISPLAY "TRYING TO WRITE".
WRITE FILE-EXT-REC FROM "Hello".
DISPLAY "EXITING NESTED-PROGRAM-1-1".
GOBACK.
END PROGRAM NESTED-PROGRAM-1-1.

IDENTIFICATION DIVISION.
PROGRAM-ID. NESTED-PROGRAM-1-2.
PROCEDURE DIVISION.
NESTED-PROGRAM .
DISPLAY "ENTERING NESTED-PROGRAM-1-2".
DISPLAY "TRYING TO WRITE".
WRITE FILE-EXT-REC FROM "Hello".
DISPLAY "EXITING NESTED-PROGRAM-1-2".
GOBACK.
DISPLAY "ENTERING NESTED-PROGRAM-1-2".
DISPLAY "TRYING TO WRITE".
WRITE FILE-EXT-REC FROM "Hello".
DISPLAY "EXITING NESTED-PROGRAM-1-2".
GOBACK.
END PROGRAM NESTED-PROGRAM-1-2.

END PROGRAM NESTED-PROGRAM-1.

IDENTIFICATION DIVISION.
PROGRAM-ID. NESTED-PROGRAM-2.
PROCEDURE DIVISION.
GOBACK.
GOBACK.
END PROGRAM NESTED-PROGRAM-2.

END PROGRAM NESTED-FILES.
Expand Down
18 changes: 9 additions & 9 deletions tests/testsuite.src/run_misc.at
Original file line number Diff line number Diff line change
Expand Up @@ -14966,10 +14966,10 @@ AT_DATA([prog1.cob], [
PROGRAM-ID. prog1.
DATA DIVISION.
working-storage section.
1 os-check pic x(7).
01 os-check pic x(7).
88 os-is-windows-or-dos values 'WINDOWS' 'FREEDOS'.
78 callee value "./prog2".
78 callee-wdos value ".\prog2".
01 callee pic x(8) value "./prog2".
88 callee-wdos value ".\prog2".
PROCEDURE DIVISION.
accept os-check from environment "COB_ON_CYGWIN".
if os-check = spaces
Expand All @@ -14978,9 +14978,10 @@ AT_DATA([prog1.cob], [
accept os-check from environment "OS_NAME".
inspect os-check converting "werfdosin" to "WERFDOSIN".
if os-is-windows-or-dos
call "SYSTEM" using callee-wdos
else
call "SYSTEM" using callee.
set callee-wdos to true.
call "SYSTEM" using callee.
if callee = space
call 'impossible'.
GOBACK.
])
AT_DATA([prog2.cob], [
Expand All @@ -14995,7 +14996,6 @@ AT_DATA([prog2.cob], [
CONTINUE.
])
AT_CHECK([$COMPILE_MODULE -fprof prog1.cob])

AT_CHECK([$COMPILE -fprof prog2.cob])

AT_CAPTURE_FILE([prof1.csv])
Expand All @@ -15011,8 +15011,8 @@ AT_CHECK([cat prof1.csv], [0],
prog1,,,,prog1.cob:10,PROGRAM,5000000,0.005 s,1
prog1,MAIN SECTION,,,prog1.cob:11,SECTION,3000000,0.003 s,1
prog1,MAIN SECTION,MAIN PARAGRAPH,,prog1.cob:11,PARAGRAPH,3000000,0.003 s,1
prog1,MAIN SECTION,MAIN PARAGRAPH,SYSTEM,prog1.cob:18,CALL,1000000,0.001 s,1
prog1,MAIN SECTION,MAIN PARAGRAPH,SYSTEM,prog1.cob:20,CALL,0,0.000 s,0
prog1,MAIN SECTION,MAIN PARAGRAPH,SYSTEM,prog1.cob:19,CALL,1000000,0.001 s,1
prog1,MAIN SECTION,MAIN PARAGRAPH,impossible,prog1.cob:21,CALL,0,0.000 s,0
])

AT_CHECK([cat prof2.csv], [0],
Expand Down

0 comments on commit 1daa393

Please sign in to comment.