Skip to content

Commit 205409b

Browse files
committed
ALTERNATE RECORD KEY指定時のファイルオープン処理を修正
1 parent a893946 commit 205409b

File tree

3 files changed

+50
-48
lines changed

3 files changed

+50
-48
lines changed

libcobj/src/jp/osscons/opensourcecobol/libcobj/file/CobolFile.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,13 @@ public void read(AbstractCobolField key, AbstractCobolField fnstatus, int read_o
10131013
}
10141014

10151015
if(this.organization == COB_ORG_INDEXED /* && bdb_env != null*/) {
1016-
//TODO INDEXED実装時
1016+
if(this.open_mode != COB_OPEN_I_O ||
1017+
(this.lock_mode & COB_LOCK_EXCLUSIVE) != 0) {
1018+
read_opts &= ~COB_READ_LOCK;
1019+
} else if((this.lock_mode & COB_LOCK_AUTOMATIC) != 0 &&
1020+
(read_opts & COB_READ_NO_LOCK) == 0) {
1021+
read_opts |= COB_READ_LOCK;
1022+
}
10171023
} else {
10181024
read_opts &= ~COB_READ_LOCK;
10191025
}
@@ -1331,7 +1337,7 @@ public static void cob_init_fileio() {
13311337

13321338
public static void defaultErrorHandle() {
13331339
byte[] file_status = CobolFile.errorFile.file_status;
1334-
int status = (file_status[0] - '0') * 10 + (file_status[0] - '0');
1340+
int status = (file_status[0] - '0') * 10 + (file_status[1] - '0');
13351341
String msg;
13361342
switch (status) {
13371343
case COB_STATUS_10_END_OF_FILE:

libcobj/src/jp/osscons/opensourcecobol/libcobj/file/CobolIndexedFile.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public int open_(String filename, int mode, int sharing) {
202202
}
203203

204204
try {
205-
p.db[i] = env.openDatabase(null, filename, dbConf);
205+
p.db[i] = env.openDatabase(null, runtime_buffer, dbConf);
206206
} catch (OperationFailureException | EnvironmentFailureException | IllegalStateException
207207
| IllegalArgumentException e) {
208208
e.printStackTrace();
@@ -644,10 +644,7 @@ public int readNext(int readOpts) {
644644
return COB_STATUS_00_SUCCESS;
645645
}
646646

647-
//TODO 削除
648-
public static void output_data(String msg, DatabaseEntry data) {
649-
System.out.println("<<<Log>>> "+ msg + " = " + new String(new ByteArrayBinding().entryToObject(data)));
650-
}
647+
651648
/**
652649
* libcob/fileio.cにはない関数
653650
* 複数回出現するカーソルを閉じる処理をまとめた
@@ -678,7 +675,6 @@ private int indexed_write_internal(boolean rewrite, int opt) {
678675
p.write_cursor_open = true;
679676
close_cursor = true;
680677
}
681-
682678
if (this.nkeys > 1 && !rewrite) {
683679
if (this.check_alt_keys(false)) {
684680
if (close_cursor) {
@@ -702,10 +698,10 @@ private int indexed_write_internal(boolean rewrite, int opt) {
702698

703699
p.data = new DatabaseEntry(this.record.getDataStorage().getByteArray(0, this.record.getSize()));
704700
try {
705-
p.cursor[0].put(p.key, p.data);
701+
p.cursor[0].put(p.key, p.data);
706702
} catch (LockConflictException e) {
707703
return COB_STATUS_51_RECORD_LOCKED;
708-
}
704+
}
709705

710706
p.data = p.key;
711707
Put flags;

tests/cobol85/report.pl

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -327,45 +327,45 @@
327327
$skip{SG106A}=1;
328328
$skip{SG204A}=1;
329329

330-
$skip{IX101A}=1;
331-
$skip{IX102A}=1;
332-
$skip{IX103A}=1;
333-
$skip{IX104A}=1;
334-
$skip{IX105A}=1;
335-
$skip{IX106A}=1;
336-
$skip{IX107A}=1;
337-
$skip{IX108A}=1;
338-
$skip{IX109A}=1;
339-
$skip{IX110A}=1;
330+
#$skip{IX101A}=1;
331+
#$skip{IX102A}=1;
332+
#$skip{IX103A}=1;
333+
#$skip{IX104A}=1;
334+
#$skip{IX105A}=1;
335+
#$skip{IX106A}=1;
336+
#$skip{IX107A}=1;
337+
#$skip{IX108A}=1;
338+
#$skip{IX109A}=1;
339+
#$skip{IX110A}=1;
340340
#$skip{IX111A}=1;
341-
$skip{IX112A}=1;
342-
$skip{IX113A}=1;
343-
$skip{IX114A}=1;
344-
$skip{IX115A}=1;
345-
$skip{IX116A}=1;
346-
$skip{IX117A}=1;
347-
$skip{IX118A}=1;
348-
$skip{IX119A}=1;
349-
$skip{IX120A}=1;
350-
$skip{IX121A}=1;
351-
$skip{IX201A}=1;
352-
$skip{IX202A}=1;
353-
$skip{IX203A}=1;
354-
$skip{IX204A}=1;
355-
$skip{IX205A}=1;
356-
$skip{IX206A}=1;
357-
$skip{IX207A}=1;
358-
$skip{IX208A}=1;
359-
$skip{IX209A}=1;
360-
$skip{IX210A}=1;
361-
$skip{IX211A}=1;
362-
$skip{IX212A}=1;
363-
$skip{IX213A}=1;
364-
$skip{IX214A}=1;
365-
$skip{IX215A}=1;
366-
$skip{IX216A}=1;
367-
$skip{IX217A}=1;
368-
$skip{IX218A}=1;
341+
#$skip{IX112A}=1;
342+
#$skip{IX113A}=1;
343+
#$skip{IX114A}=1;
344+
#$skip{IX115A}=1;
345+
#$skip{IX116A}=1;
346+
#$skip{IX117A}=1;
347+
#$skip{IX118A}=1;
348+
#$skip{IX119A}=1;
349+
#$skip{IX120A}=1;
350+
#$skip{IX121A}=1;
351+
#$skip{IX201A}=1;
352+
#$skip{IX202A}=1;
353+
#$skip{IX203A}=1;
354+
#$skip{IX204A}=1;
355+
#$skip{IX205A}=1;
356+
#$skip{IX206A}=1;
357+
#$skip{IX207A}=1;
358+
#$skip{IX208A}=1;
359+
#$skip{IX209A}=1;
360+
#$skip{IX210A}=1;
361+
#$skip{IX211A}=1;
362+
#$skip{IX212A}=1;
363+
#$skip{IX213A}=1;
364+
#$skip{IX214A}=1;
365+
#$skip{IX215A}=1;
366+
#$skip{IX216A}=1;
367+
#$skip{IX217A}=1;
368+
#$skip{IX218A}=1;
369369

370370

371371
open (LOG, "> report.txt") or die;

0 commit comments

Comments
 (0)