/[pspp]/pspp/src/set.q
ViewVC logotype

Diff of /pspp/src/set.q

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.20 by jmd, Wed Jan 26 03:48:02 2005 UTC revision 1.21 by blp, Tue Mar 1 08:16:16 2005 UTC
# Line 20  Line 20 
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        
# Line 93  static int set_results; Line 93  static int set_results;
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];
# Line 147  static unsigned long random_seed (void); Line 149  static unsigned long random_seed (void);
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;
# Line 237  aux_stc_custom_disk(struct cmd_set *cmd Line 240  aux_stc_custom_disk(struct cmd_set *cmd
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));
# Line 601  stc_custom_pager (struct cmd_set *cmd UN Line 611  stc_custom_pager (struct cmd_set *cmd UN
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;
# Line 632  stc_custom_blanks (struct cmd_set *cmd U Line 642  stc_custom_blanks (struct cmd_set *cmd U
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  {  {
# Line 1179  get_decimal(void) Line 1217  get_decimal(void)
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)

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.21

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26