X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flist.q;h=3480efb2efb533f1d7e7d3b64964bdab65eb70ba;hb=4fdeb2145d081ff1b84e3f6c99f9d1c048c0d64a;hp=824e51da27d1fdbefc977ab691b41f5d3cb4dd5d;hpb=3a7fba81ceae5b049d0f7d671e9e3c3c43bbf703;p=pspp-builds.git diff --git a/src/list.q b/src/list.q index 824e51da..3480efb2 100644 --- a/src/list.q +++ b/src/list.q @@ -14,32 +14,18 @@ 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. */ -/* AIX requires this to be the first thing in the file. */ #include -#if __GNUC__ -#define alloca __builtin_alloca -#else -#if HAVE_ALLOCA_H -#include -#else -#ifdef _AIX -#pragma alloca -#else -#ifndef alloca /* predefined by HP cc +Olibcalls */ -char *alloca (); -#endif -#endif -#endif -#endif - -#include +#include "error.h" #include #include #include "alloc.h" +#include "case.h" #include "command.h" +#include "devind.h" +#include "dictionary.h" #include "lexer.h" #include "error.h" #include "magic.h" @@ -47,16 +33,14 @@ char *alloca (); #include "htmlP.h" #include "output.h" #include "som.h" +#include "tab.h" #include "var.h" #include "vfm.h" #include "format.h" +/* (headers) */ #include "debug-print.h" -#if DEBUGGING -static void debug_print (void); -#endif - /* (specification) list (lst_): *variables=varlist("PV_NO_SCRATCH"); @@ -81,7 +65,7 @@ struct list_ext static struct cmd_list cmd; /* Current case number. */ -static int case_num; +static int case_idx; /* Line buffer. */ static char *line_buf; @@ -92,11 +76,11 @@ static int n_chars_width (struct outp_driver *d); static void write_line (struct outp_driver *d, char *s); /* Other functions. */ -static int list_cases (struct ccase *); +static int list_cases (struct ccase *, void *); static void determine_layout (void); static void clean_up (void); static void write_header (struct outp_driver *); -static void write_all_headers (void); +static void write_all_headers (void *); /* Returns the number of text lines that can fit on the remainder of the page. */ @@ -140,7 +124,6 @@ cmd_list (void) { struct variable casenum_var; - lex_match_id ("LIST"); if (!parse_list (&cmd)) return CMD_FAILURE; @@ -234,15 +217,10 @@ cmd_list (void) cmd.v_variables[0] = &casenum_var; } -#if DEBUGGING - /* Print out command. */ - debug_print (); -#endif - determine_layout (); - case_num = 0; - procedure (write_all_headers, list_cases, NULL); + case_idx = 0; + procedure_with_splits (write_all_headers, list_cases, NULL, NULL); free (line_buf); clean_up (); @@ -253,7 +231,7 @@ cmd_list (void) /* Writes headers to all devices. This is done at the beginning of each SPLIT FILE group. */ static void -write_all_headers (void) +write_all_headers (void *aux UNUSED) { struct outp_driver *d; @@ -268,7 +246,7 @@ write_all_headers (void) { struct html_driver_ext *x = d->ext; - assert (d->driver_open && d->page_open); + assert (d->driver_open); if (x->sequence_no == 0 && !d->class->open_page (d)) { msg (ME, _("Cannot open first page on HTML device %s."), @@ -288,6 +266,10 @@ write_all_headers (void) fputs (" \n", x->file.file); } + else if (d->class == &devind_class) + { + /* FIXME */ + } else assert (0); } @@ -406,6 +388,10 @@ clean_up (void) fputs ("\n", x->file.file); } } + else if (d->class == &devind_class) + { + /* FIXME */ + } else assert (0); @@ -537,6 +523,12 @@ determine_layout (void) if (d->class == &html_class) continue; + else if (d->class == &devind_class) + { + /* FIXME */ + tab_output_text (TAT_NONE, "(devind not supported on LIST yet)"); + continue; + } assert (d->class->special == 0); @@ -619,13 +611,13 @@ determine_layout (void) } static int -list_cases (struct ccase *c) +list_cases (struct ccase *c, void *aux UNUSED) { struct outp_driver *d; - case_num++; - if (case_num < cmd.first || case_num > cmd.last - || (cmd.step != 1 && (case_num - cmd.first) % cmd.step)) + case_idx++; + if (case_idx < cmd.first || case_idx > cmd.last + || (cmd.step != 1 && (case_idx - cmd.first) % cmd.step)) return 1; for (d = outp_drivers (NULL); d; d = outp_drivers (d)) @@ -670,19 +662,15 @@ list_cases (struct ccase *c) memset(&line_buf[x], ' ', width - v->print.w); x += width - v->print.w; } - - { - union value value; - - if (formats[v->print.type].cat & FCAT_STRING) - value.c = c->data[v->fv].s; - else if (v->fv == -1) - value.f = case_num; - else - value.f = c->data[v->fv].f; - - data_out (&line_buf[x], &v->print, &value); - } + + if ((formats[v->print.type].cat & FCAT_STRING) || v->fv != -1) + data_out (&line_buf[x], &v->print, case_data (c, v->fv)); + else + { + union value case_idx_value; + case_idx_value.f = case_idx; + data_out (&line_buf[x], &v->print, &case_idx_value); + } x += v->print.w; line_buf[x++] = ' '; @@ -707,17 +695,16 @@ list_cases (struct ccase *c) for (column = 0; column < cmd.n_variables; column++) { struct variable *v = cmd.v_variables[column]; - union value value; char buf[41]; - if (formats[v->print.type].cat & FCAT_STRING) - value.c = c->data[v->fv].s; - else if (v->fv == -1) - value.f = case_num; - else - value.f = c->data[v->fv].f; - - data_out (buf, &v->print, &value); + if ((formats[v->print.type].cat & FCAT_STRING) || v->fv != -1) + data_out (buf, &v->print, case_data (c, v->fv)); + else + { + union value case_idx_value; + case_idx_value.f = case_idx; + data_out (buf, &v->print, &case_idx_value); + } buf[v->print.w] = 0; fprintf (x->file.file, " %s\n", @@ -726,50 +713,15 @@ list_cases (struct ccase *c) fputs (" \n", x->file.file); } + else if (d->class == &devind_class) + { + /* FIXME */ + } else assert (0); return 1; } - -/* Debugging output. */ - -#if DEBUGGING -/* Prints out the command as parsed by cmd_list(). */ -static void -debug_print (void) -{ - int i; - - puts ("LIST"); - printf (" VARIABLES="); - for (i = 0; i < cmd.n_variables; i++) - { - if (i) - putc (' ', stdout); - fputs (cmd.v_variables[i]->name, stdout); - } - - printf ("\n /CASES=FROM %ld TO %ld BY %ld\n", cmd.first, cmd.last, cmd.step); - - fputs (" /FORMAT=", stdout); - if (cmd.numbering == LST_NUMBERED) - fputs ("NUMBERED", stdout); - else - fputs ("UNNUMBERED", stdout); - putc (' ', stdout); - if (cmd.wrap == LST_WRAP) - fputs ("WRAP", stdout); - else - fputs ("SINGLE", stdout); - putc (' ', stdout); - if (cmd.weight == LST_WEIGHT) - fputs ("WEIGHT", stdout); - else - fputs ("NOWEIGHT", stdout); - puts ("."); -} -#endif /* DEBUGGING */ /* Local Variables: