@@ -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