Skip to content

Added funcConcatenate in CobolIntrinsic.java #212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 29, 2023
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
46 changes: 46 additions & 0 deletions libcobj/src/jp/osscons/opensourcecobol/libcobj/common/CobolIntrinsic.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -1690,6 +1690,13 @@ public static AbstractCobolField funcNational(AbstractCobolField srcfield) {
return currField;
}

/**
* cob_intr_combined_datetimeの実装
*
* @param srcdays
* @param srctime
* @return
*/
public static AbstractCobolField funcCombinedDatetime(
AbstractCobolField srcdays, AbstractCobolField srctime) {
int srdays;
Expand Down Expand Up @@ -1724,4 +1731,43 @@ public static AbstractCobolField funcCombinedDatetime(
currField.getDataStorage().memcpy(buff);
return currField;
}

/**
* cob_intr_concatenateの実装
*
* @param offset
* @param length
* @param params
* @param fields
* @return
*/
public static AbstractCobolField funcConcatenate(
int offset, int length, int params, AbstractCobolField... fields) {
int calcsize = 0;
int i;
int index = 0;
int size;
byte[] data;

for (i = 0; i < params; i++) {
calcsize += fields[i].getSize();
}
CobolFieldAttribute attr =
new CobolFieldAttribute(CobolFieldAttribute.COB_TYPE_ALPHANUMERIC, 0, 0, 0, null);
AbstractCobolField field =
CobolFieldFactory.makeCobolField(calcsize, (CobolDataStorage) null, attr);
makeFieldEntry(field);
data = new byte[calcsize];
for (i = 0; i < params; i++) {
size = fields[i].getSize();
System.arraycopy(
fields[i].getDataStorage().getByteBuffer(size).array(), 0, data, index, size);
index += size;
}
currField.setDataStorage(new CobolDataStorage(data));
if (offset > 0) {
calcRefMod(currField, offset, length);
}
return currField;
}
}
2 changes: 0 additions & 2 deletions tests/run.src/functions.at
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ AT_CHECK([java prog], [0],
AT_CLEANUP

AT_SETUP([FUNCTION CONCATENATE])
AT_CHECK([${SKIP_TEST}])

AT_DATA([prog.cob], [
IDENTIFICATION DIVISION.
Expand All @@ -223,7 +222,6 @@ AT_CHECK([java prog], [0],
AT_CLEANUP

AT_SETUP([FUNCTION CONCATENATE with reference modding])
AT_CHECK([${SKIP_TEST}])

AT_DATA([prog.cob], [
IDENTIFICATION DIVISION.
Expand Down