Skip to content

Commit b6677eb

Browse files
committed
FUNCTION NATIONAL関数をサポートする設定の追加です。
Add option to enable function NATIONAL.
1 parent f8e0cac commit b6677eb

File tree

16 files changed

+336
-5
lines changed

16 files changed

+336
-5
lines changed

cobc/config.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ CB_CONFIG_BOOLEAN (cb_enable_sort_status_register, "enable-sort-status-register"
4848
CB_CONFIG_BOOLEAN (cb_enable_special_names_argument_clause, "enable-special-names-argument-clause")
4949
CB_CONFIG_BOOLEAN (cb_enable_special_names_environment_clause, "enable-special-names-environment-clause")
5050
CB_CONFIG_BOOLEAN (cb_enable_leng_intrinsic_function, "enable-leng-intrinsic-function")
51+
CB_CONFIG_BOOLEAN (cb_enable_national_intrinsic_function, "enable-national-intrinsic-function")
5152
CB_CONFIG_SUPPORT (cb_author_paragraph, "author-paragraph")
5253
CB_CONFIG_SUPPORT (cb_memory_size_clause, "memory-size-clause")
5354
CB_CONFIG_SUPPORT (cb_multiple_file_tape_clause, "multiple-file-tape-clause")

cobc/reserved.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,9 @@ static const struct cb_intrinsic_table function_list[] = {
775775
{ "MOD", 2, 1, CB_INTR_MOD,
776776
"cob_intr_mod",
777777
CB_CATEGORY_NUMERIC, 0 },
778+
{ "NATIONAL", 1, 1, CB_INTR_NATIONAL,
779+
"cob_intr_national",
780+
CB_CATEGORY_NATIONAL, 0 },
778781
{ "NATIONAL-OF", -1, 0, CB_INTR_NATIONAL_OF,
779782
NULL,
780783
CB_CATEGORY_ALPHANUMERIC, 0 },

cobc/tree.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2704,6 +2704,13 @@ RXW */
27042704
case CB_INTR_TEST_DAY_YYYYDDD:
27052705
case CB_INTR_TRIM:
27062706
return make_intrinsic (name, cbp, args, NULL, refmod);
2707+
case CB_INTR_NATIONAL:
2708+
if (cb_enable_national_intrinsic_function) {
2709+
return make_intrinsic (name, cbp, args, NULL, refmod);
2710+
} else {
2711+
cb_error_x (name, _("FUNCTION %s not implemented"), CB_NAME (name));
2712+
return cb_error_node;
2713+
}
27072714

27082715
case CB_INTR_CONCATENATE:
27092716
return make_intrinsic (name, cbp, args, cb_int1, refmod);

cobc/tree.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,7 @@ enum cb_intr_enum {
887887
CB_INTR_MIDRANGE,
888888
CB_INTR_MIN,
889889
CB_INTR_MOD,
890+
CB_INTR_NATIONAL,
890891
CB_INTR_NATIONAL_OF,
891892
CB_INTR_NUMVAL,
892893
CB_INTR_NUMVAL_C,

config/default.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,4 @@ enable-sort-status-register: no
129129
enable-special-names-argument-clause: no
130130
enable-special-names-environment-clause: no
131131
enable-leng-intrinsic-function: no
132+
enable-national-intrinsic-function: no

config/jp-compat.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ enable-sort-status-register: yes
1313
enable-special-names-argument-clause: yes
1414
enable-special-names-environment-clause: yes
1515
enable-leng-intrinsic-function: yes
16+
enable-national-intrinsic-function: yes

libcob/intrinsic.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3294,6 +3294,23 @@ cob_intr_lcl_time_from_secs (const int offset, const int length,
32943294
return curr_field;
32953295
}
32963296

3297+
cob_field *
3298+
cob_intr_national (cob_field *srcfield)
3299+
{
3300+
cob_field_attr attr;
3301+
cob_field field;
3302+
char *pdata;
3303+
int ndata;
3304+
3305+
pdata = han2zen ((char *)srcfield->data, srcfield->size, &ndata);
3306+
COB_ATTR_INIT (COB_TYPE_NATIONAL, 0, 0, 0, NULL);
3307+
COB_FIELD_INIT (ndata, NULL, &attr);
3308+
make_field_entry (&field);
3309+
memcpy (curr_field->data, pdata, ndata);
3310+
free (pdata);
3311+
return curr_field;
3312+
}
3313+
32973314
/* Initialization routine */
32983315

32993316
void

libcob/intrinsic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,6 @@ extern cob_field *cob_intr_seconds_past_midnight (void);
9898
extern cob_field *cob_intr_lcl_time_from_secs (const int, const int,
9999
cob_field *, cob_field *);
100100
extern cob_field *cob_intr_seconds_from_formatted_time (cob_field *, cob_field *);
101+
extern cob_field *cob_intr_national (cob_field *);
101102

102103
#endif /* COB_INTRINSIC_H */

libcob/move.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@ cob_move_alphanum_to_national_edited (cob_field *f1, cob_field *f2)
10831083
}
10841084
}
10851085

1086-
static char *
1086+
char *
10871087
han2zen (char *str, int size, int *retsize)
10881088
{
10891089
#ifdef I18N_UTF8

libcob/move.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include <libcob/common.h>
2525

26+
extern char *han2zen (char *, int, int *);
2627
extern void cob_move (cob_field *, cob_field *);
2728
extern void cob_hankaku_move (cob_field *, cob_field *);
2829
extern void cob_set_int (cob_field *, int);

0 commit comments

Comments
 (0)