From: John Darrington Date: Thu, 4 Nov 2004 03:17:32 +0000 (+0000) Subject: Fixed the parsing of subcommands, such that the (n) setting is optional X-Git-Tag: v0.4.0~242 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0dfeb46aa388fae94797accde705a13d9ef7aff8;p=pspp-builds.git Fixed the parsing of subcommands, such that the (n) setting is optional Added prototypes for the va*_to_string functions --- diff --git a/src/ChangeLog b/src/ChangeLog index 69c756d4..ec56b315 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +Thu Nov 4 11:09:01 WST 2004 John Darrington + + * q2c.c examine.q Fixed a bug (feature?) whereby arrays in the + command which had settings didn't get the appropriate code + generated. + + * val.h value-labels.[ch] var-labs.c Added v*to_string functions + to convert variables/values to strings. + + * examine.q Added framework for the EXAMINE command. + Mon Nov 1 12:46:17 WST 2004 John Darrington * q2c.c frequencies.q set.q t-test.q Fixed the q2c parsing of DBL diff --git a/src/examine.q b/src/examine.q index 491a5919..546fcc05 100644 --- a/src/examine.q +++ b/src/examine.q @@ -40,7 +40,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "casefile.h" /* (specification) - "EXAMINE" (examine_): + "EXAMINE" (xmn_): *variables=custom; +total=custom; +nototal=custom; @@ -117,8 +117,13 @@ cmd_examine(void) int i; short total=1; + + if ( !parse_examine(&cmd) ) return CMD_FAILURE; + + if ( cmd.st_n == SYSMIS ) + cmd.st_n = 5; if ( ! cmd.sbc_cinterval) cmd.n_cinterval[0] = 95.0; @@ -136,10 +141,10 @@ cmd_examine(void) if ( cmd.sbc_statistics ) { - if ( cmd.a_statistics[EXAMINE_ST_DESCRIPTIVES]) + if ( cmd.a_statistics[XMN_ST_DESCRIPTIVES]) show_descriptives(dependent_vars, n_dependent_vars, 0); - if ( cmd.st_n != SYSMIS ) + if ( cmd.a_statistics[XMN_ST_EXTREME]) show_extremes(dependent_vars, n_dependent_vars, 0, cmd.st_n); } } @@ -158,10 +163,10 @@ cmd_examine(void) if ( cmd.sbc_statistics ) { - if ( cmd.a_statistics[EXAMINE_ST_DESCRIPTIVES]) + if ( cmd.a_statistics[XMN_ST_DESCRIPTIVES]) show_descriptives(dependent_vars, n_dependent_vars,f); - if ( cmd.st_n != SYSMIS ) + if ( cmd.a_statistics[XMN_ST_EXTREME]) show_extremes(dependent_vars, n_dependent_vars,f,cmd.st_n); } } @@ -175,7 +180,7 @@ cmd_examine(void) /* TOTAL and NOTOTAL are simple, mutually exclusive flags */ static int -examine_custom_total(struct cmd_examine *p) +xmn_custom_total(struct cmd_examine *p) { if ( p->sbc_nototal ) { @@ -187,7 +192,7 @@ examine_custom_total(struct cmd_examine *p) } static int -examine_custom_nototal(struct cmd_examine *p) +xmn_custom_nototal(struct cmd_examine *p) { if ( p->sbc_total ) { @@ -253,7 +258,7 @@ free_factor(struct factor *f, void *aux UNUSED) /* Parser for the variables sub command */ static int -examine_custom_variables(struct cmd_examine *cmd ) +xmn_custom_variables(struct cmd_examine *cmd ) { lex_match('='); diff --git a/src/q2c.c b/src/q2c.c index 39a6cc4e..fec3e3ab 100644 --- a/src/q2c.c +++ b/src/q2c.c @@ -705,6 +705,15 @@ parse_specifier (specifier *spec, subcommand *sbc) } skip_token (':'); + if ( sbc->type == SBC_ARRAY && token == T_ID ) + { + spec->varname = xstrdup (st_lower (tokstr)); + spec->index = sbc->narray; + sbc->narray++; + } + + + /* Parse all the settings. */ { setting **s = &spec->s; @@ -779,6 +788,7 @@ parse_subcommand (subcommand *sbc) sbc->type = SBC_ARRAY; parse_specifiers (sbc); + } else { @@ -1062,7 +1072,6 @@ dump_declarations (void) specifier *spec; for (spec = sbc->spec; spec; spec = spec->next) - if (!spec->s) dump (0, "%s%s%s = %d,", st_upper (prefix), st_upper (sbc->prefix), st_upper (spec->varname), spec->index); @@ -1108,8 +1117,12 @@ dump_declarations (void) spec->varname); else if (f == 0) { - dump (0, "int a_%s[%d];", - st_lower (sbc->name), sbc->narray); + dump (0, "int a_%s[%s%scount];", + st_lower (sbc->name), + st_upper (prefix), + st_upper (sbc->prefix) + ); + f = 1; } } @@ -1390,6 +1403,7 @@ dump_specifier_parse (const specifier *spec, const subcommand *sbc) dump (1, "%sif (%s)", first ? "" : "else ", make_match (s->specname)); + /* Handle values. */ if (s->value == VAL_NONE) dump (0, "p->%s%s = %s%s;", sbc->prefix, spec->varname, @@ -1400,9 +1414,18 @@ dump_specifier_parse (const specifier *spec, const subcommand *sbc) dump (1, "{"); if (spec->varname) - dump (0, "p->%s%s = %s%s;", sbc->prefix, spec->varname, - st_upper (prefix), find_symbol (s->con)->name); - + { + dump (0, "p->%s%s = %s%s;", sbc->prefix, spec->varname, + st_upper (prefix), find_symbol (s->con)->name); + + if ( sbc->type == SBC_ARRAY ) + dump (0, "p->a_%s[%s%s%s] = 1;", + st_lower (sbc->name), + st_upper (prefix), st_upper (sbc->prefix), + st_upper (spec->varname)); + } + + if (s->valtype == VT_PAREN) { if (s->optvalue) diff --git a/src/value-labels.h b/src/value-labels.h index 50a00a3e..9e8a4719 100644 --- a/src/value-labels.h +++ b/src/value-labels.h @@ -53,4 +53,10 @@ struct val_lab *val_labs_next (const struct val_labs *, struct val_labs_iterator **); void val_labs_done (struct val_labs_iterator **); +/* Return a string representing this value, in the form most + appropriate from a human factors perspective. + (IE: the label if it has one, otherwise the alpha/numeric ) +*/ +const char *value_to_string(const union value *, const struct variable *); + #endif /* value-labels.h */ diff --git a/src/var.h b/src/var.h index 0e15598a..c1ad04c5 100644 --- a/src/var.h +++ b/src/var.h @@ -433,4 +433,13 @@ int parse_var_set_vars (const struct var_set *, struct variable ***, int *, int parse_DATA_LIST_vars (char ***names, int *cnt, int opts); int parse_mixed_vars (char ***names, int *cnt, int opts); + + +/* Return a string representing this variable, in the form most + appropriate from a human factors perspective. + (IE: the label if it has one, otherwise the name ) +*/ +const char * var_to_string(const struct variable *var); + + #endif /* !var_h */