Skip to content

Commit 7537fe8

Browse files
committed
通貨記号をconfigで設定できるように変更しました。
Add option to change default currency symbol.
1 parent 3429ebd commit 7537fe8

File tree

10 files changed

+313
-10
lines changed

10 files changed

+313
-10
lines changed

cobc/cobc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ enum cb_replace_type {
237237
#define CB_CONFIG_ANY(type,var,name) extern type var;
238238
#define CB_CONFIG_INT(var,name) extern int var;
239239
#define CB_CONFIG_STRING(var,name) extern const char *var;
240+
#define CB_CONFIG_CHAR(var,name) extern char var;
240241
#define CB_CONFIG_BOOLEAN(var,name) extern int var;
241242
#define CB_CONFIG_SUPPORT(var,name) extern enum cb_support var;
242243
#include "config.def"

cobc/config.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@
3131
#undef CB_CONFIG_ANY
3232
#undef CB_CONFIG_INT
3333
#undef CB_CONFIG_STRING
34+
#undef CB_CONFIG_CHAR
3435
#undef CB_CONFIG_BOOLEAN
3536
#undef CB_CONFIG_SUPPORT
3637
#define CB_CONFIG_ANY(type,var,name) type var;
3738
#define CB_CONFIG_INT(var,name) int var;
3839
#define CB_CONFIG_STRING(var,name) const char *var;
40+
#define CB_CONFIG_CHAR(var,name) char var;
3941
#define CB_CONFIG_BOOLEAN(var,name) int var;
4042
#define CB_CONFIG_SUPPORT(var,name) enum cb_support var;
4143
#include "config.def"
@@ -44,6 +46,7 @@ enum cb_config_type {
4446
ANY,
4547
INT, /* integer */
4648
STRING, /* "..." */
49+
CHAR, /* single character */
4750
BOOLEAN, /* 'yes', 'no' */
4851
SUPPORT /* 'ok', 'archaic', 'obsolete',
4952
'skip', 'ignore', 'unconformable' */
@@ -62,11 +65,13 @@ static struct {
6265
#undef CB_CONFIG_ANY
6366
#undef CB_CONFIG_INT
6467
#undef CB_CONFIG_STRING
68+
#undef CB_CONFIG_CHAR
6569
#undef CB_CONFIG_BOOLEAN
6670
#undef CB_CONFIG_SUPPORT
6771
#define CB_CONFIG_ANY(type,var,name) {ANY, name, &var, NULL},
6872
#define CB_CONFIG_INT(var,name) {INT, name, &var, NULL},
6973
#define CB_CONFIG_STRING(var,name) {STRING, name, &var, NULL},
74+
#define CB_CONFIG_CHAR(var,name) {CHAR, name, &var, NULL},
7075
#define CB_CONFIG_BOOLEAN(var,name) {BOOLEAN, name, &var, NULL},
7176
#define CB_CONFIG_SUPPORT(var,name) {SUPPORT, name, &var, NULL},
7277
#include "config.def"
@@ -270,6 +275,14 @@ cb_load_conf (const char *fname, const int check_nodef, const int prefix_dir)
270275
*((const char **)var) = val;
271276
}
272277
break;
278+
case CHAR:
279+
if (1 != strnlen (val, 2)) {
280+
invalid_value (fname, line, name);
281+
ret = -1;
282+
} else {
283+
*((char *)var) = *val;
284+
}
285+
break;
273286
case BOOLEAN:
274287
if (strcmp (val, "yes") == 0) {
275288
*((int *)var) = 1;

cobc/config.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020

2121
CB_CONFIG_STRING (cb_config_name, "name")
22+
CB_CONFIG_CHAR (cb_default_currency_symbol, "default-currency-symbol")
2223
CB_CONFIG_INT (cb_tab_width, "tab-width")
2324
CB_CONFIG_INT (cb_text_column, "text-column")
2425
CB_CONFIG_INT (cb_max_alpha_character_data_size, "max-alpha-character-data-size")

cobc/tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ cb_build_program (struct cb_program *last_program, int nest_level)
908908
p->next_program = last_program;
909909
p->nested_level = nest_level;
910910
p->decimal_point = '.';
911-
p->currency_symbol = '\\';
911+
p->currency_symbol = cb_default_currency_symbol;
912912
p->numeric_separator = ',';
913913
if (nest_level) {
914914
p->global_file_list = last_program->global_file_list;

config/Makefile.am

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,11 @@ configdir = @COB_CONFIG_DIR@
88
config_DATA = default.conf cobol85.conf cobol2002.conf \
99
mf.conf ibm.conf mvs.conf bs2000.conf
1010

11-
EXTRA_DIST = $(config_DATA)
11+
EXTRA_DIST = $(config_DATA) \
12+
default-en.conf \
13+
default-jp.conf \
14+
jp-compat.conf \
15+
boundary-limit.conf
16+
17+
install-data-hook:
18+
$(configDATA_INSTALL) 'default-jp.conf' '$(DESTDIR)$(configdir)/default.conf'

config/Makefile.in

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ sharedstatedir = @sharedstatedir@
193193
sysconfdir = @sysconfdir@
194194
target_alias = @target_alias@
195195
configdir = @COB_CONFIG_DIR@
196-
config_DATA = default.conf cobol85.conf cobol2002.conf \
196+
config_DATA = default.conf default-en.conf default-jp.conf cobol85.conf cobol2002.conf \
197197
mf.conf ibm.conf mvs.conf bs2000.conf
198198

199199
EXTRA_DIST = $(config_DATA)
@@ -340,6 +340,8 @@ info: info-am
340340
info-am:
341341

342342
install-data-am: install-configDATA
343+
@$(NORMAL_INSTALL)
344+
$(MAKE) $(AM_MAKEFLAGS) install-data-hook
343345

344346
install-exec-am:
345347

@@ -370,13 +372,17 @@ uninstall-am: uninstall-configDATA uninstall-info-am
370372
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
371373
distclean distclean-generic distclean-libtool distdir dvi \
372374
dvi-am html html-am info info-am install install-am \
373-
install-configDATA install-data install-data-am install-exec \
374-
install-exec-am install-info install-info-am install-man \
375-
install-strip installcheck installcheck-am installdirs \
376-
maintainer-clean maintainer-clean-generic mostlyclean \
377-
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
378-
uninstall uninstall-am uninstall-configDATA uninstall-info-am
375+
install-configDATA install-data install-data-am \
376+
install-data-hook install-exec install-exec-am install-info \
377+
install-info-am install-man install-strip installcheck \
378+
installcheck-am installdirs maintainer-clean \
379+
maintainer-clean-generic mostlyclean mostlyclean-generic \
380+
mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am \
381+
uninstall-configDATA uninstall-info-am
382+
379383

384+
install-data-hook:
385+
$(configDATA_INSTALL) 'default-jp.conf' '$(DESTDIR)$(configdir)/default.conf'
380386
# Tell versions [3.59,3.63) of GNU make to not export all variables.
381387
# Otherwise a system limit (for SysV at least) may be exceeded.
382388
.NOEXPORT:

config/default-en.conf

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# COBOL compiler configuration -*- sh -*-
2+
3+
# Value: any string
4+
name: "OpenCOBOL"
5+
6+
# Value: int
7+
tab-width: 8
8+
text-column: 72
9+
10+
# Value: 'cobol2002', 'mf', 'ibm'
11+
#
12+
assign-clause: mf
13+
14+
# If yes, file names are resolved at run time using environment variables.
15+
# For example, given ASSIGN TO "DATAFILE", the actual file name will be
16+
# 1. the value of environment variable 'DD_DATAFILE' or
17+
# 2. the value of environment variable 'dd_DATAFILE' or
18+
# 3. the value of environment variable 'DATAFILE' or
19+
# 4. the literal "DATAFILE"
20+
# If no, the value of the assign clause is the file name.
21+
#
22+
# Value: 'yes', 'no'
23+
filename-mapping: yes
24+
25+
# Value: 'yes', 'no'
26+
pretty-display: yes
27+
28+
# Value: 'yes', 'no'
29+
auto-initialize: yes
30+
31+
# Value: 'yes', 'no'
32+
complex-odo: no
33+
34+
# Value: 'yes', 'no'
35+
indirect-redefines: no
36+
37+
# Binary byte size - defines the allocated bytes according to PIC
38+
# Value: signed unsigned bytes
39+
# ------ -------- -----
40+
# '2-4-8' 1 - 4 2
41+
# 5 - 9 4
42+
# 10 - 18 8
43+
#
44+
# '1-2-4-8' 1 - 2 1
45+
# 3 - 4 2
46+
# 5 - 9 4
47+
# 10 - 18 8
48+
#
49+
# '1--8' 1 - 2 1 - 2 1
50+
# 3 - 4 3 - 4 2
51+
# 5 - 6 5 - 7 3
52+
# 7 - 9 8 - 9 4
53+
# 10 - 11 10 - 12 5
54+
# 12 - 14 13 - 14 6
55+
# 15 - 16 15 - 16 7
56+
# 17 - 18 17 - 18 8
57+
binary-size: 1-2-4-8
58+
59+
# Value: 'yes', 'no'
60+
binary-truncate: yes
61+
62+
# Value: 'native', 'big-endian'
63+
binary-byteorder: big-endian
64+
65+
# Value: 'yes', 'no'
66+
larger-redefines-ok: no
67+
68+
# Value: 'yes', 'no'
69+
relaxed-syntax-check: no
70+
71+
# Perform type OSVS - If yes, the exit point of any currently executing perform
72+
# is recognized if reached.
73+
# Value: 'yes', 'no'
74+
perform-osvs: no
75+
76+
# If yes, linkage-section items remain allocated
77+
# between invocations.
78+
# Value: 'yes', 'no'
79+
sticky-linkage: no
80+
81+
# If yes, set the file assign to the external file
82+
# Value: 'yes', 'no'
83+
assign_external: no
84+
85+
# If yes, allow non-matching level numbers
86+
# Value: 'yes', 'no'
87+
relax-level-hierarchy: no
88+
89+
# not-reserved:
90+
# Value: Word to be taken out of the reserved words list
91+
# (case independent)
92+
93+
# Dialect features
94+
# Value: 'ok', 'archaic', 'obsolete', 'skip', 'ignore', 'unconformable'
95+
author-paragraph: obsolete
96+
memory-size-clause: obsolete
97+
multiple-file-tape-clause: obsolete
98+
label-records-clause: obsolete
99+
value-of-clause: obsolete
100+
data-records-clause: obsolete
101+
top-level-occurs-clause: skip
102+
synchronized-clause: ok
103+
goto-statement-without-name: obsolete
104+
stop-literal-statement: obsolete
105+
debugging-line: obsolete
106+
padding-character-clause: obsolete
107+
next-sentence-phrase: archaic
108+
eject-statement: skip
109+
entry-statement: obsolete
110+
move-noninteger-to-alphanumeric: error
111+
odo-without-to: ok
112+
113+
# Value: any single character
114+
default-currency-symbol: $
115+
116+
# Value: int
117+
max-alpha-character-data-size: 2147483647
118+
max-sjis-character-data-size: 1073741823
119+
max-utf8-character-data-size: 715827882
120+
121+
# If yes, length of PROGRAM-ID of after translation is bigger than
122+
# 31 characters, give warning.
123+
c89-identifier-length-check: no
124+
125+
# jp compatible
126+
# Value: 'yes', 'no'
127+
allow-end-program-with-wrong-name: no
128+
allow-missing-also-clause-in-evaluate: no
129+
allow-empty-imperative-statement: no
130+
enable-program-status-register: no
131+
enable-sort-status-register: no
132+
enable-special-names-argument-clause: no
133+
enable-special-names-environment-clause: no
134+
enable-leng-intrinsic-function: no
135+
enable-length-an-intrinsic-function: no
136+
enable-national-intrinsic-function: no

0 commit comments

Comments
 (0)