X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdescript.c;h=05e0767d40694fe71c2e6302f1089de690fbbed8;hb=c0240125a4702cccce5d4ea1d58d9e7f3d739dff;hp=9acd21e673d48269afb0d96a36fc249663cc51d6;hpb=06f9ee45954e5e71fa7f6262dbf37defa1dbf996;p=pspp diff --git a/src/descript.c b/src/descript.c index 9acd21e673..05e0767d40 100644 --- a/src/descript.c +++ b/src/descript.c @@ -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. */ /* FIXME: Many possible optimizations. */ @@ -29,6 +29,7 @@ #include "case.h" #include "casefile.h" #include "command.h" +#include "dictionary.h" #include "lexer.h" #include "error.h" #include "magic.h" @@ -38,6 +39,10 @@ #include "var.h" #include "vfm.h" +#include "gettext.h" +#define _(msgid) gettext (msgid) +#define N_(msgid) msgid + /* DESCRIPTIVES private data. */ struct dsc_proc; @@ -119,7 +124,7 @@ static const struct dsc_statistic_info dsc_info[DSC_N_STATS] = struct dsc_var { struct variable *v; /* Variable to calculate on. */ - char z_name[9]; /* Name for z-score variable. */ + char z_name[LONG_NAME_LEN + 1]; /* Name for z-score variable. */ double valid, missing; /* Valid, missing counts. */ struct moments *moments; /* Moments. */ double min, max; /* Maximum and mimimum values. */ @@ -262,11 +267,7 @@ cmd_descriptives (void) else if (lex_match_id ("DEFAULT")) dsc->show_stats |= DEFAULT_STATS; else - { - dsc->show_stats |= 1ul << (match_statistic ()); - if (dsc->show_stats == DSC_NONE) - dsc->show_stats = DEFAULT_STATS; - } + dsc->show_stats |= 1ul << (match_statistic ()); lex_match (','); } if (dsc->show_stats == 0) @@ -468,7 +469,7 @@ try_name (struct dsc_proc *dsc, char *name) if (dict_lookup_var (default_dict, name) != NULL) return 0; for (i = 0; i < dsc->var_cnt; i++) - if (!strcmp (dsc->vars[i].z_name, name)) + if (!strcasecmp (dsc->vars[i].z_name, name)) return 0; return 1; } @@ -481,12 +482,11 @@ static int generate_z_varname (struct dsc_proc *dsc, char *z_name, const char *var_name, int *z_cnt) { - char name[10]; + char name[LONG_NAME_LEN + 1]; /* Try a name based on the original variable name. */ name[0] = 'Z'; - strcpy (name + 1, var_name); - name[8] = '\0'; + str_copy_trunc (name + 1, sizeof name - 1, var_name); if (try_name (dsc, name)) { strcpy (z_name, name); @@ -583,8 +583,9 @@ descriptives_trns_proc (struct trns_header *trns, struct ccase * c, for (vars = t->vars; vars < t->vars + t->var_cnt; vars++) { double score = case_num (c, (*vars)->fv); - if ( score == SYSMIS || (!t->include_user_missing - && is_num_user_missing(score, *vars)) ) + if ( score == SYSMIS + || (!t->include_user_missing + && mv_is_num_user_missing (&(*vars)->miss, score))) { all_sysmis = 1; break; @@ -599,7 +600,8 @@ descriptives_trns_proc (struct trns_header *trns, struct ccase * c, if (z->mean == SYSMIS || z->std_dev == SYSMIS || all_sysmis || input == SYSMIS - || (!t->include_user_missing && is_num_user_missing(input, z->v))) + || (!t->include_user_missing + && mv_is_num_user_missing (&z->v->miss, input))) *output = SYSMIS; else *output = (input - z->mean) / z->std_dev; @@ -739,7 +741,7 @@ calc_descriptives (const struct casefile *cf, void *dsc_) if (dsc->missing_type != DSC_LISTWISE && (x == SYSMIS || (!dsc->include_user_missing - && is_num_user_missing (x, dv->v)))) + && mv_is_num_user_missing (&dv->v->miss, x)))) { dv->missing += weight; continue; @@ -781,7 +783,7 @@ calc_descriptives (const struct casefile *cf, void *dsc_) if (dsc->missing_type != DSC_LISTWISE && (x == SYSMIS || (!dsc->include_user_missing - && is_num_user_missing (x, dv->v)))) + && mv_is_num_user_missing (&dv->v->miss, x)))) continue; if (dv->moments != NULL) @@ -844,7 +846,8 @@ listwise_missing (struct dsc_proc *dsc, const struct ccase *c) double x = case_num (c, dv->v->fv); if (x == SYSMIS - || (!dsc->include_user_missing && is_num_user_missing (x, dv->v))) + || (!dsc->include_user_missing + && mv_is_num_user_missing (&dv->v->miss, x))) return 1; } return 0; @@ -928,7 +931,7 @@ descriptives_compare_dsc_vars (const void *a_, const void *b_, void *dsc_) int result; if (dsc->sort_by_stat == DSC_NAME) - result = strcmp (a->v->name, b->v->name); + result = strcasecmp (a->v->name, b->v->name); else { double as = a->stats[dsc->sort_by_stat];