Skip to content

Commit a983370

Browse files
committed
INDEXEDに関する修正(暫定)
1 parent 45d8770 commit a983370

File tree

3 files changed

+55
-22
lines changed

3 files changed

+55
-22
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,6 @@ public void write(AbstractCobolField rec, int opt, AbstractCobolField fnstatus)
10841084
|| this.open_mode == COB_OPEN_INPUT
10851085
|| this.open_mode == COB_OPEN_EXTEND) {
10861086
saveStatus(COB_STATUS_48_OUTPUT_DENIED, fnstatus);
1087-
System.err.println("write called 03-2");
10881087
return;
10891088
}
10901089
}

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

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,11 @@ public int open_(String filename, int mode, int sharing) {
186186
} else {
187187
dbConf.setAllowCreate(true);
188188
}
189-
190-
dbConf.setSortedDuplicates(this.keys[i].getFlag() != 0);
189+
/*if(this.keys[i].getFlag() != 0) {
190+
dbConf.setSortedDuplicates(true);
191+
}*/
192+
//dbConf.setSortedDuplicates(this.keys[i].getFlag() != 0);
193+
dbConf.setSortedDuplicates(true);
191194

192195
if (mode == COB_OPEN_OUTPUT) {
193196
try {
@@ -586,11 +589,7 @@ public int readNext(int readOpts) {
586589
}
587590
if (read_nextprev) {
588591
try {
589-
//output_data("22222 p.key", p.key);
590-
//System.out.println("<<<Log>>> p.key_index = " + p.key_index);
591592
result = p.cursor[p.key_index].get(p.key, p.data, nextprev, readOptions);
592-
//output_data("33333 p.key", p.key);
593-
//output_data("33333 p.data", p.data);
594593
} catch(LockConflictException e) {
595594
this.discardCursors(p);
596595
return COB_STATUS_51_RECORD_LOCKED;
@@ -628,7 +627,6 @@ public int readNext(int readOpts) {
628627
}
629628
if (p.key_index == 0) {
630629
p.last_readkey[0].memcpy(p.key.getData(), p.key.getSize());
631-
//output_data("xxxxxx p.key", p.key);
632630
} else {
633631
p.last_readkey[p.key_index].memcpy(p.temp_key, this.keys[p.key_index].getField().getSize());
634632
p.last_readkey[p.key_index + this.nkeys].memcpy(p.key.getData(),
@@ -703,8 +701,6 @@ private int indexed_write_internal(boolean rewrite, int opt) {
703701
}
704702

705703
p.data = new DatabaseEntry(this.record.getDataStorage().getByteArray(0, this.record.getSize()));
706-
//output_data("write 0 p.key", p.key);
707-
//output_data("write 0 p.data", p.data);
708704
try {
709705
p.cursor[0].put(p.key, p.data);
710706
} catch (LockConflictException e) {
@@ -728,8 +724,6 @@ private int indexed_write_internal(boolean rewrite, int opt) {
728724
}
729725

730726
p.key = DBT_SET(this.keys[i].getField());
731-
//output_data("write " + i + " p.key", p.key);
732-
//output_data("write " + i + " p.data", p.data);
733727
try {
734728
if(p.db[i].put(null, p.key, p.data, flags, null) == null) {
735729
if (close_cursor) {
@@ -799,9 +793,9 @@ public int write_(int opt) {
799793
private boolean check_alt_keys(boolean rewrite) {
800794
IndexedFile p = this.filei;
801795
for (int i = 1; i < this.nkeys; ++i) {
802-
if (this.keys[i].getFlag() != 0) {
796+
if (this.keys[i].getFlag() == 0) {
803797
p.key = DBT_SET(this.keys[i].getField());
804-
if (p.db[i].get(null, p.key, p.data, Get.SEARCH, null) == null) {
798+
if (p.db[i].get(null, p.key, p.data, Get.SEARCH, null) != null) {
805799
if (rewrite) {
806800
byte[] dataBytes = p.data.getData();
807801
if (this.keys[0].getField().getDataStorage().memcmp(dataBytes,
@@ -849,10 +843,10 @@ private int get_dupno(int i) {
849843
//berkley dbの重複スキーに対するデータは新しいものほど先頭に格納されるが
850844
//java editionでは挿入位置が自動で設定されるため,以下の実装を変えた.
851845
int dupno = 0;
852-
while (ret != null) {
853-
int tempDupno = ByteBuffer.wrap(p.key.getData(), this.keys[0].getField().getSize(), 4).getInt();
854-
if (tempDupno > dupno) {
855-
dupno = tempDupno;
846+
while (ret != null && p.temp_key.memcmp(p.key.getData(), p.key.getSize()) == 0) {
847+
int tempdupno = ByteBuffer.wrap(p.data.getData(), this.keys[0].getField().getSize(), 4).getInt();
848+
if(dupno < tempdupno) {
849+
dupno = tempdupno;
856850
}
857851
ret = p.cursor[i].get(p.key, p.data, Get.NEXT_DUP, null);
858852
}
@@ -861,7 +855,7 @@ private int get_dupno(int i) {
861855
p.cursor[i] = null;
862856

863857
return ++dupno;
864-
}
858+
}
865859

866860
@Override
867861
/**

tests/cobol85/report.pl

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
$skip{NC124A} = 1;
9898
$skip{NC125A} = 1;
9999
$skip{NC126A} = 1;
100-
$skip{NC127A} = 1;
100+
#$skip{NC127A} = 1;
101101
$skip{NC131A} = 1;
102102
$skip{NC132A} = 1;
103103
$skip{NC133A} = 1;
@@ -113,7 +113,7 @@
113113
$skip{NC171A} = 1;
114114
$skip{NC172A} = 1;
115115
$skip{NC173A} = 1;
116-
#$skip{NC174A} = 1;
116+
$skip{NC174A} = 1;
117117
$skip{NC175A} = 1;
118118
$skip{NC176A} = 1;
119119
$skip{NC177A} = 1;
@@ -325,7 +325,47 @@
325325
$skip{SG104A}=1;
326326
$skip{SG105A}=1;
327327
$skip{SG106A}=1;
328-
#$skip{SG204A}=1;
328+
$skip{SG204A}=1;
329+
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;
340+
#$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;
329369

330370

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

0 commit comments

Comments
 (0)