LIST: Remove WEIGHT subcommand.
[pspp-builds.git] / src / language / data-io / list.q
index 5f1b3a99e5fe01c66ff45d1a1529639cc70cc78c..871fa69ef4db6369fcda469e77eb81c1c9adae90 100644 (file)
@@ -56,8 +56,7 @@
      *variables=varlist("PV_NO_SCRATCH");
      cases=:from n:first,"%s>0"/by n:step,"%s>0"/ *to n:last,"%s>0";
      +format=numbering:numbered/!unnumbered,
-             wrap:!wrap/single,
-             weight:weight/!noweight.
+             wrap:!wrap/single.
 */
 /* (declarations) */
 /* (functions) */
@@ -191,30 +190,6 @@ cmd_list (struct lexer *lexer, struct dataset *ds)
       cmd.step = 1;
     }
 
-  /* Weighting variable. */
-  if (cmd.weight == LST_WEIGHT)
-    {
-      if (dict_get_weight (dict) != NULL)
-       {
-         size_t i;
-
-         for (i = 0; i < cmd.n_variables; i++)
-           if (cmd.v_variables[i] == dict_get_weight (dict))
-             break;
-         if (i >= cmd.n_variables)
-           {
-             /* Add the weight variable to the end of the variable list. */
-             cmd.n_variables++;
-             cmd.v_variables = xnrealloc (cmd.v_variables, cmd.n_variables,
-                                           sizeof *cmd.v_variables);
-             cmd.v_variables[cmd.n_variables - 1]
-                = dict_get_weight (dict);
-           }
-       }
-      else
-       msg (SW, _("`/FORMAT WEIGHT' specified, but weighting is not on."));
-    }
-
   /* Case number. */
   if (cmd.numbering == LST_NUMBERED)
     {
@@ -224,7 +199,7 @@ cmd_list (struct lexer *lexer, struct dataset *ds)
       casenum_var = var_create ("Case#", 0);
       var_set_both_formats (casenum_var, &format);
 
-      /* Add the weight variable at the beginning of the variable list. */
+      /* Add the case-number variable at the beginning of the variable list. */
       cmd.n_variables++;
       cmd.v_variables = xnrealloc (cmd.v_variables,
                                    cmd.n_variables, sizeof *cmd.v_variables);
@@ -665,6 +640,7 @@ list_case (const struct ccase *c, casenumber case_idx,
            const struct dataset *ds, struct ll_list *targets)
 {
   struct dictionary *dict = dataset_dict (ds);
+  const char *encoding = dict_get_encoding (dict);
   struct list_target *target;
 
   ll_for_each (target, struct list_target, ll, targets)
@@ -688,6 +664,7 @@ list_case (const struct ccase *c, casenumber case_idx,
               const struct variable *v = cmd.v_variables[column];
               const struct fmt_spec *print = var_get_print_format (v);
               int width;
+              char *s;
 
               if (target->type == 0 && column >= target->n_vertical)
                 {
@@ -716,20 +693,17 @@ list_case (const struct ccase *c, casenumber case_idx,
               if (width > print->w)
                 ds_put_char_multiple(&line_buffer, ' ', width - print->w);
 
-              if (fmt_is_string (print->type)
-                  || dict_contains_var (dict, v))
-                {
-                  data_out (case_data (c, v), print,
-                            ds_put_uninit (&line_buffer, print->w));
-                }
+              if (fmt_is_string (print->type) || dict_contains_var (dict, v))
+                s = data_out (case_data (c, v), encoding, print);
               else
                 {
                   union value case_idx_value;
                   case_idx_value.f = case_idx;
-                  data_out (&case_idx_value, print,
-                            ds_put_uninit (&line_buffer,print->w));
+                  s = data_out (&case_idx_value, encoding, print);
                 }
 
+              ds_put_cstr (&line_buffer, s);
+              free (s);
               ds_put_char(&line_buffer, ' ');
             }
 
@@ -753,21 +727,23 @@ list_case (const struct ccase *c, casenumber case_idx,
             {
               const struct variable *v = cmd.v_variables[column];
               const struct fmt_spec *print = var_get_print_format (v);
-              char buf[256];
+              char *s;
 
               if (fmt_is_string (print->type)
                   || dict_contains_var (dict, v))
-                data_out (case_data (c, v), print, buf);
+                s = data_out (case_data (c, v), encoding, print);
               else
                 {
                   union value case_idx_value;
                   case_idx_value.f = case_idx;
-                  data_out (&case_idx_value, print, buf);
+                  s = data_out (&case_idx_value, encoding, print);
                 }
 
               fputs ("    <TD>", x->file);
-              html_put_cell_contents (d, TAB_FIX, ss_buffer (buf, print->w));
+              html_put_cell_contents (d, TAB_FIX, ss_cstr (s));
               fputs ("</TD>\n", x->file);
+
+              free (s);
             }
 
           fputs ("  </TR>\n", x->file);