Changed all the licence notices in all the files.
[pspp-builds.git] / src / data-list.c
index 7328f65eec9781bc5814ca010cc4ae11ba059012..24fa0dbcee0b51594bf9c05140c88e4d075c84b4 100644 (file)
@@ -14,8 +14,8 @@
 
    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. */
 
 #include <config.h>
 #include "data-list.h"
@@ -65,7 +65,7 @@ struct dls_var_spec
     int fc, lc;                        /* Column numbers in record. */
 
     /* Free format only. */
-    char name[9];              /* Name of variable. */
+    char name[SHORT_NAME_LEN + 1];             /* Name of variable. */
   };
 
 /* Constants for DATA LIST type. */
@@ -208,7 +208,10 @@ cmd_data_list (void)
                       if (lex_match_id ("TAB"))
                         delim = '\t';
                       else if (token == T_STRING && tokstr.length == 1)
-                        delim = tokstr.string[0];
+                       {
+                         delim = tokstr.string[0];
+                         lex_get();
+                       }
                       else 
                         {
                           lex_error (NULL);
@@ -275,8 +278,7 @@ cmd_data_list (void)
       add_transformation (&new_pgm->h);
     }
   else 
-    vfm_source = create_case_source (&data_list_source_class,
-                                     default_dict, dls);
+    vfm_source = create_case_source (&data_list_source_class, dls);
 
   return CMD_SUCCESS;
 
@@ -347,7 +349,7 @@ parse_fixed (struct data_list_pgm *dls)
       while (lex_match ('/'))
        {
          fx.recno++;
-         if (lex_integer_p ())
+         if (lex_is_integer ())
            {
              if (lex_integer () < fx.recno)
                {
@@ -368,7 +370,7 @@ parse_fixed (struct data_list_pgm *dls)
       if (!parse_DATA_LIST_vars (&fx.name, &fx.name_cnt, PV_NONE))
        return 0;
 
-      if (token == T_NUM)
+      if (lex_is_number ())
        {
          if (!fixed_parse_compatible (&fx, &dls->first, &dls->last))
            goto fail;
@@ -498,7 +500,7 @@ fixed_parse_compatible (struct fixed_parsing_state *fx,
       else
        input.type = FMT_F;
 
-      if (lex_integer_p ())
+      if (lex_is_integer ())
        {
          if (lex_integer () < 1)
            {
@@ -532,7 +534,7 @@ fixed_parse_compatible (struct fixed_parsing_state *fx,
       input.type = FMT_F;
       input.d = 0;
     }
-  if (!check_input_specifier (&input))
+  if (!check_input_specifier (&input, 1))
     return 0;
 
   /* Start column for next specification. */
@@ -710,7 +712,7 @@ fixed_parse_fortran_internal (struct fixed_parsing_state *fx,
       tail = new;
 
       /* Parse count. */
-      if (lex_integer_p ())
+      if (lex_is_integer ())
        {
          new->count = lex_integer ();
          lex_get ();
@@ -728,8 +730,8 @@ fixed_parse_fortran_internal (struct fixed_parsing_state *fx,
        }
       else if (lex_match ('/'))
        new->f.type = FMT_NEWREC;
-      else if (!parse_format_specifier (&new->f, 1)
-              || !check_input_specifier (&new->f))
+      else if (!parse_format_specifier (&new->f, FMTP_ALLOW_XT)
+              || !check_input_specifier (&new->f, 1))
        goto fail;
 
       lex_match (',');
@@ -839,10 +841,11 @@ parse_free (struct dls_var_spec **first, struct dls_var_spec **last)
 
       if (!parse_DATA_LIST_vars (&name, &name_cnt, PV_NONE))
        return 0;
+
       if (lex_match ('('))
        {
          if (!parse_format_specifier (&input, 0)
-              || !check_input_specifier (&input)
+              || !check_input_specifier (&input, 1)
               || !lex_force_match (')')) 
             {
               for (i = 0; i < name_cnt; i++)
@@ -871,6 +874,7 @@ parse_free (struct dls_var_spec **first, struct dls_var_spec **last)
          struct variable *v;
 
          v = dict_create_var (default_dict, name[i], width);
+         
          if (!v)
            {
              msg (SE, _("%s is a duplicate variable name."), name[i]);
@@ -885,7 +889,7 @@ parse_free (struct dls_var_spec **first, struct dls_var_spec **last)
           spec->input = input;
           spec->v = v;
          spec->fv = v->fv;
-         strcpy (spec->name, name[i]);
+         strcpy (spec->name, v->name);
          append_var_spec (first, last, spec);
        }
       for (i = 0; i < name_cnt; i++)
@@ -953,10 +957,10 @@ dump_free_table (const struct data_list_pgm *dls,
    a 1-based column number indicating the beginning of the field
    on success. */
 static int
-cut_field (const struct data_list_pgm *dls, struct len_string *field,
+cut_field (const struct data_list_pgm *dls, struct fixed_string *field,
            int *end_blank)
 {
-  struct len_string line;
+  struct fixed_string line;
   char *cp;
   size_t column_start;
 
@@ -1091,7 +1095,7 @@ read_from_data_list_fixed (const struct data_list_pgm *dls,
     return -2;
   for (i = 1; i <= dls->rec_cnt; i++)
     {
-      struct len_string line;
+      struct fixed_string line;
       
       if (dfm_eof (dls->reader))
        {
@@ -1110,7 +1114,7 @@ read_from_data_list_fixed (const struct data_list_pgm *dls,
          data_in_finite_line (&di, ls_c_str (&line), ls_length (&line),
                                var_spec->fc, var_spec->lc);
          di.v = case_data_rw (c, var_spec->fv);
-         di.flags = 0;
+         di.flags = DI_IMPLIED_DECIMALS;
          di.f1 = var_spec->fc;
          di.format = var_spec->input;
 
@@ -1135,7 +1139,7 @@ read_from_data_list_free (const struct data_list_pgm *dls,
 
   for (var_spec = dls->first; var_spec; var_spec = var_spec->next)
     {
-      struct len_string field;
+      struct fixed_string field;
       int column;
       
       /* Cut out a field and read in a new record if necessary. */
@@ -1186,7 +1190,7 @@ read_from_data_list_list (const struct data_list_pgm *dls,
 
   for (var_spec = dls->first; var_spec; var_spec = var_spec->next)
     {
-      struct len_string field;
+      struct fixed_string field;
       int column;
 
       /* Cut out a field and check for end-of-line. */
@@ -1687,7 +1691,7 @@ parse_num_or_var (struct rpd_num_or_var *value, const char *message)
          return 0;
        }
     }
-  else if (lex_integer_p ())
+  else if (lex_is_integer ())
     {
       value->num = lex_integer ();
       
@@ -1722,7 +1726,7 @@ parse_repeating_data (struct dls_var_spec **first, struct dls_var_spec **last)
       if (!parse_DATA_LIST_vars (&fx.name, &fx.name_cnt, PV_NONE))
        return 0;
 
-      if (token == T_NUM)
+      if (lex_is_number ())
        {
          if (!fixed_parse_compatible (&fx, first, last))
            goto fail;
@@ -1908,7 +1912,7 @@ repeating_data_trns_proc (struct trns_header *trns, struct ccase *c,
 {
   struct repeating_data_trns *t = (struct repeating_data_trns *) trns;
     
-  struct len_string line;       /* Current record. */
+  struct fixed_string line;       /* Current record. */
 
   int starts_beg;      /* Starting column. */
   int starts_end;      /* Ending column. */