Skip to content

Commit d676d81

Browse files
committed
INSPECT文の不具合を修正した
1 parent 2e490b0 commit d676d81

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

libcob/strings.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,7 @@ cob_inspect_converting (const cob_field *f1, const cob_field *f2)
412412

413413
len = (size_t)(inspect_end - inspect_start);
414414

415-
puts("[dbg] call inspect_converting");
416415
#ifdef I18N_UTF8
417-
puts("[dbg] call inspect_converting 1");
418416
if (f2 == &cob_quote) {
419417
fig_const = &cob_quote;
420418
fig_constw = &cob_zen_quote;
@@ -478,7 +476,6 @@ cob_inspect_converting (const cob_field *f1, const cob_field *f2)
478476
}
479477
}
480478
#else /*!I18N_UTF8*/
481-
puts("[dbg] call inspect_converting 2");
482479
if (COB_FIELD_TYPE (f1) == COB_TYPE_NATIONAL ||
483480
COB_FIELD_TYPE (f1) == COB_TYPE_NATIONAL_EDITED) {
484481
if (f2 == &cob_quote) {

libcobj/src/jp/osscons/opensourcecobol/libcobj/common/CobolInspect.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,11 @@ private static void common(AbstractCobolField f1, AbstractCobolField f2, int typ
140140
public static void init(AbstractCobolField var, int replacing) {
141141
CobolInspect.inspectVarCopy = var;
142142
CobolInspect.inspectVar = CobolInspect.inspectVarCopy;
143-
CobolInspect.inspectReplacing = replacing;
144-
CobolInspect.inspectSign = var.getSign();
145143
if(inspectVar.getAttribute().isTypeNumericDisplay()) {
146144
inspectVar.putSign(1);
147145
}
146+
CobolInspect.inspectReplacing = replacing;
147+
CobolInspect.inspectSign = var.getSign();
148148
CobolInspect.inspectSize = var.getFieldSize();
149149
CobolInspect.inspectData = var.getDataStorage();
150150
CobolInspect.inspectStart = -1;
@@ -178,15 +178,16 @@ public static void before (AbstractCobolField str) {
178178
switch(str.getAttribute().getType()) {
179179
case CobolFieldAttribute.COB_TYPE_NUMERIC_DISPLAY:
180180
CobolDataStorage data = str.getDataStorage();
181+
int firstIndex = str.getFirstDataIndex();
181182
int size = str.getFieldSize();
182183
int n = 0;
183184
int i = 0;
184-
while(size > 1 && data.getByte(i) == (byte)'0') {
185+
while(size > 1 && (data.getByte(firstIndex + i) == (byte)'0' || data.getByte(firstIndex + i) == (byte)0x70)) {
185186
size--;
186187
i++;
187188
}
188189
while(size-- > 0) {
189-
int b = data.getByte(i++);
190+
int b = data.getByte(firstIndex + i++);
190191
n = n * 10 + (b >= 0x70 ? b - 0x70 : b - 0x30);
191192
fig++;
192193
}
@@ -324,12 +325,14 @@ public static void converting(AbstractCobolField f1, AbstractCobolField f2) {
324325
} else {
325326
for(int j=0; j<f1.getSize(); ++j) {
326327
for(int i=0; i<len; ++i) {
327-
if(f2 == CobolConstant.quote || f2 == CobolConstant.space || f2 == CobolConstant.zero) {
328-
inspectData.setByte(inspectStart + i, data.getByte(0));
329-
} else {
330-
inspectData.setByte(inspectStart + i, data.getByte(j));
328+
if(inspectMark[i] == -1 && inspectData.getByte(inspectStart + i) == f1.getDataStorage().getByte(j)) {
329+
if(f2 == CobolConstant.quote || f2 == CobolConstant.space || f2 == CobolConstant.zero) {
330+
inspectData.setByte(inspectStart + i, data.getByte(0));
331+
} else {
332+
inspectData.setByte(inspectStart + i, data.getByte(j));
333+
}
334+
inspectMark[i] = 1;
331335
}
332-
inspectMark[i] = 1;
333336
}
334337
}
335338
}

0 commit comments

Comments
 (0)