20 |
/* |
/* |
21 |
Categories of SET subcommands: |
Categories of SET subcommands: |
22 |
|
|
23 |
data input: BLANKS, DECIMAL, FORMAT. |
data input: BLANKS, DECIMAL, FORMAT, EPOCH. |
24 |
|
|
25 |
program input: ENDCMD, NULLINE. |
program input: ENDCMD, NULLINE. |
26 |
|
|
93 |
|
|
94 |
static double set_blanks=SYSMIS; |
static double set_blanks=SYSMIS; |
95 |
|
|
96 |
|
static int set_epoch = -1; |
97 |
|
|
98 |
static struct fmt_spec set_format={FMT_F,8,2}; |
static struct fmt_spec set_format={FMT_F,8,2}; |
99 |
|
|
100 |
static struct set_cust_currency set_cc[5]; |
static struct set_cust_currency set_cc[5]; |
149 |
echo=echo:on/off; |
echo=echo:on/off; |
150 |
eject=eject:on/off; |
eject=eject:on/off; |
151 |
endcmd=string "x==1" "one character long"; |
endcmd=string "x==1" "one character long"; |
152 |
|
epoch=custom; |
153 |
errorbreak=errbrk:on/off; |
errorbreak=errbrk:on/off; |
154 |
errors=errors:on/off/terminal/listing/both/none; |
errors=errors:on/off/terminal/listing/both/none; |
155 |
format=custom; |
format=custom; |
240 |
} |
} |
241 |
|
|
242 |
static int |
static int |
243 |
|
aux_stc_custom_epoch(struct cmd_set *cmd UNUSED) |
244 |
|
{ |
245 |
|
msg (MM, _("EPOCH is %d"), get_epoch ()); |
246 |
|
return 0; |
247 |
|
} |
248 |
|
|
249 |
|
static int |
250 |
aux_stc_custom_format(struct cmd_set *cmd UNUSED) |
aux_stc_custom_format(struct cmd_set *cmd UNUSED) |
251 |
{ |
{ |
252 |
msg(MM, fmt_to_string(&set_format)); |
msg(MM, fmt_to_string(&set_format)); |
611 |
} |
} |
612 |
return 1; |
return 1; |
613 |
#else /* USE_INTERNAL_PAGER */ |
#else /* USE_INTERNAL_PAGER */ |
614 |
if (match_id (OFF)) |
if (lex_match_id ("OFF")) |
615 |
return 1; |
return 1; |
616 |
msg (SW, "External pagers not supported."); |
msg (SW, "External pagers not supported."); |
617 |
return 0; |
return 0; |
642 |
return 1; |
return 1; |
643 |
} |
} |
644 |
|
|
645 |
|
/* Parses the EPOCH subcommand, which controls the epoch used for |
646 |
|
parsing 2-digit years. */ |
647 |
|
static int |
648 |
|
stc_custom_epoch (struct cmd_set *cmd UNUSED) |
649 |
|
{ |
650 |
|
lex_match ('='); |
651 |
|
if (lex_match_id ("AUTOMATIC")) |
652 |
|
set_epoch = -1; |
653 |
|
else if (lex_integer_p ()) |
654 |
|
{ |
655 |
|
int new_epoch = lex_integer (); |
656 |
|
lex_get (); |
657 |
|
if (new_epoch < 1500) |
658 |
|
{ |
659 |
|
msg (SE, _("EPOCH must be 1500 or later.")); |
660 |
|
return 0; |
661 |
|
} |
662 |
|
set_epoch = new_epoch; |
663 |
|
} |
664 |
|
else |
665 |
|
{ |
666 |
|
lex_error (_("expecting AUTOMATIC or year")); |
667 |
|
return 0; |
668 |
|
} |
669 |
|
|
670 |
|
return 1; |
671 |
|
} |
672 |
|
|
673 |
static int |
static int |
674 |
stc_custom_length (struct cmd_set *cmd UNUSED) |
stc_custom_length (struct cmd_set *cmd UNUSED) |
675 |
{ |
{ |
1217 |
return (cmd.dec == STC_DOT ? '.' : ','); |
return (cmd.dec == STC_DOT ? '.' : ','); |
1218 |
} |
} |
1219 |
|
|
1220 |
|
int |
1221 |
|
get_epoch (void) |
1222 |
|
{ |
1223 |
|
if (set_epoch < 0) |
1224 |
|
{ |
1225 |
|
time_t t = time (0); |
1226 |
|
struct tm *tm = localtime (&t); |
1227 |
|
if (tm != NULL) |
1228 |
|
set_epoch = (tm->tm_year + 1900) - 69; |
1229 |
|
else |
1230 |
|
set_epoch = 2000 - 69; |
1231 |
|
} |
1232 |
|
|
1233 |
|
return set_epoch; |
1234 |
|
} |
1235 |
|
|
1236 |
char |
char |
1237 |
get_grouping(void) |
get_grouping(void) |