Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public int open_(String filename, int mode, int sharing) throws IOException {
}
}

if(mode == COB_OPEN_OUTPUT) {
if (mode == COB_OPEN_OUTPUT) {
this.fp.setLength(0);
this.fp.seek(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ public int readNext(int readOpts) {
}
}
int size = ByteBuffer.wrap(sbuff).getInt();
size = Math.max(size, this.record_min);
size = Math.min(size, this.record_max);
this.record.setSize(size);
}

Expand Down
3 changes: 2 additions & 1 deletion tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ misc_DEPENDENCIES = \
misc.src/fix-subtract.at \
misc.src/display-numeric-NUMERIC-class.at \
misc.src/display-inspect-sign.at \
misc.src/comp1-comp2.at
misc.src/comp1-comp2.at \
misc.src/variable-length-file.at

EXTRA_DIST = $(srcdir)/package.m4 \
$(TESTS) \
Expand Down
3 changes: 2 additions & 1 deletion tests/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,8 @@ misc_DEPENDENCIES = \
misc.src/fix-subtract.at \
misc.src/display-numeric-NUMERIC-class.at \
misc.src/display-inspect-sign.at \
misc.src/comp1-comp2.at
misc.src/comp1-comp2.at \
misc.src/variable-length-file.at

EXTRA_DIST = $(srcdir)/package.m4 \
$(TESTS) \
Expand Down
1 change: 1 addition & 0 deletions tests/misc.at
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ m4_include([fix-subtract.at])
m4_include([display-numeric-NUMERIC-class.at])
m4_include([display-inspect-sign.at])
m4_include([comp1-comp2.at])
m4_include([variable-length-file.at])
Binary file added tests/misc.src/TEST_VAR_LENGTH.txt
Binary file not shown.
51 changes: 51 additions & 0 deletions tests/misc.src/variable-length-file.at
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
AT_SETUP([READING VARIABLE LENGTH FILE])

AT_DATA([prog.cbl], [
IDENTIFICATION DIVISION.
PROGRAM-ID. prog.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT TEST-FILE
ASSIGN TO "../../misc.src/TEST_VAR_LENGTH.txt".
DATA DIVISION.
FILE SECTION.
FD TEST-FILE.
01 REC-1 PIC X(18).
01 REC-2 PIC X(54).
PROCEDURE DIVISION.
MAIN-PARA.
MOVE SPACES TO REC-1 REC-2.
PERFORM OPEN-FILE.
PERFORM READ-REC.
PERFORM CLOSE-FILE.
STOP RUN.

OPEN-FILE.
OPEN INPUT TEST-FILE.

READ-REC.
DISPLAY "REC-1: " REC-1.
DISPLAY "REC-2: " REC-2.
READ TEST-FILE.
DISPLAY "REC-1: " REC-1.
DISPLAY "REC-2: " REC-2.

CLOSE-FILE.
CLOSE TEST-FILE.
])

// Checking the number of bytes
AT_CHECK([od -N 4 -t x1 -An ../../misc.src/TEST_VAR_LENGTH.txt], [0],
[ 00 00 03 0e
])

AT_CHECK([${COMPILE} prog.cbl], [0])
AT_CHECK([${RUN_MODULE} prog], [0],
[REC-1: @&t@
REC-2: @&t@
REC-1: LLL5555555555555 5
REC-2: LLL5555555555555 555555555555L555555555555555555555555
])

AT_CLEANUP