X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fset.q;h=f9a00c52a17b6c7c9f64e5a82e75d2a459e95bf0;hb=05a2c3f6e9560a57e87206ac3358946bf6d43b42;hp=c291c1a87946575f20c37320fc7f49b240da723b;hpb=d5e5cf282cc56899913654a62c425e584acecfb2;p=pspp-builds.git diff --git a/src/set.q b/src/set.q index c291c1a8..f9a00c52 100644 --- a/src/set.q +++ b/src/set.q @@ -14,13 +14,13 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ /* Categories of SET subcommands: - data input: BLANKS, DECIMAL, FORMAT. + data input: BLANKS, DECIMAL, FORMAT, EPOCH. program input: ENDCMD, NULLINE. @@ -93,6 +93,8 @@ static int set_results; static double set_blanks=SYSMIS; +static int set_epoch = -1; + static struct fmt_spec set_format={FMT_F,8,2}; static struct set_cust_currency set_cc[5]; @@ -147,6 +149,7 @@ static unsigned long random_seed (void); echo=echo:on/off; eject=eject:on/off; endcmd=string "x==1" "one character long"; + epoch=custom; errorbreak=errbrk:on/off; errors=errors:on/off/terminal/listing/both/none; format=custom; @@ -236,6 +239,13 @@ aux_stc_custom_disk(struct cmd_set *cmd UNUSED) return aux_stc_custom_listing(cmd); } +static int +aux_stc_custom_epoch(struct cmd_set *cmd UNUSED) +{ + msg (MM, _("EPOCH is %d"), get_epoch ()); + return 0; +} + static int aux_stc_custom_format(struct cmd_set *cmd UNUSED) { @@ -601,7 +611,7 @@ stc_custom_pager (struct cmd_set *cmd UNUSED) } return 1; #else /* USE_INTERNAL_PAGER */ - if (match_id (OFF)) + if (lex_match_id ("OFF")) return 1; msg (SW, "External pagers not supported."); return 0; @@ -632,6 +642,34 @@ stc_custom_blanks (struct cmd_set *cmd UNUSED) return 1; } +/* Parses the EPOCH subcommand, which controls the epoch used for + parsing 2-digit years. */ +static int +stc_custom_epoch (struct cmd_set *cmd UNUSED) +{ + lex_match ('='); + if (lex_match_id ("AUTOMATIC")) + set_epoch = -1; + else if (lex_is_integer ()) + { + int new_epoch = lex_integer (); + lex_get (); + if (new_epoch < 1500) + { + msg (SE, _("EPOCH must be 1500 or later.")); + return 0; + } + set_epoch = new_epoch; + } + else + { + lex_error (_("expecting AUTOMATIC or year")); + return 0; + } + + return 1; +} + static int stc_custom_length (struct cmd_set *cmd UNUSED) { @@ -1051,6 +1089,22 @@ set_viewport(int sig_num UNUSED) /* Public functions */ +void +done_settings(void) +{ + if ( rng ) + gsl_rng_free (rng); + free (set_pager); + free (set_journal); + + free (cmd.s_endcmd); + free (cmd.s_prompt); + free (cmd.s_cprompt); + free (cmd.s_dprompt); +} + + + void init_settings(void) { @@ -1088,10 +1142,18 @@ init_settings(void) #if !USE_INTERNAL_PAGER { - char *pager; + const char *pager = getenv ("STAT_PAGER"); - pager = getenv ("STAT_PAGER"); - if (!pager) set_pager = getenv ("PAGER"); + if (!pager) + { + const char *p = getenv ("PAGER"); + + if ( p != NULL ) + set_pager = xstrdup (p); + else + set_pager = 0; + } + if (pager) set_pager = xstrdup (pager); @@ -1155,6 +1217,21 @@ get_decimal(void) return (cmd.dec == STC_DOT ? '.' : ','); } +int +get_epoch (void) +{ + if (set_epoch < 0) + { + time_t t = time (0); + struct tm *tm = localtime (&t); + if (tm != NULL) + set_epoch = (tm->tm_year + 1900) - 69; + else + set_epoch = 2000 - 69; + } + + return set_epoch; +} char get_grouping(void)