Adopt use of gnulib for portability.
[pspp-builds.git] / src / descript.c
index e05c92921614c4e3b11d8499248ad281fbda65ee..fedba7f6938586ee098ee4c758a3e24111c271d8 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. */
 
 /* 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"
 #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. */
@@ -464,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;
 }
@@ -477,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);
@@ -924,7 +928,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];