pspp-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pspp-cvs] pspp/src/language/lexer q2c.c subcommand-list.c [simpler-proc


From: Ben Pfaff
Subject: [Pspp-cvs] pspp/src/language/lexer q2c.c subcommand-list.c [simpler-proc]
Date: Sun, 15 Apr 2007 05:14:31 +0000

CVSROOT:        /cvsroot/pspp
Module name:    pspp
Branch:         simpler-proc
Changes by:     Ben Pfaff <blp> 07/04/15 05:14:31

Modified files:
        src/language/lexer: q2c.c subcommand-list.c 

Log message:
        Implement support for "INTEGER LIST"-type subcommands in q2c.  The
        documentation claimed these were supported, but actually they weren't.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/lexer/q2c.c?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.21.2.1&r2=1.21.2.2
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/lexer/subcommand-list.c?cvsroot=pspp&only_with_tag=simpler-proc&r1=1.3&r2=1.3.2.1

Patches:
Index: q2c.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/lexer/q2c.c,v
retrieving revision 1.21.2.1
retrieving revision 1.21.2.2
diff -u -b -r1.21.2.1 -r1.21.2.2
--- q2c.c       14 Apr 2007 04:59:27 -0000      1.21.2.1
+++ q2c.c       15 Apr 2007 05:14:31 -0000      1.21.2.2
@@ -1274,13 +1274,13 @@
            switch (sbc->type)
              {
              case SBC_INT_LIST:
-               break;
-
              case SBC_DBL_LIST:
                dump (1, "{");
                dump (0, "int i;");
                dump (1, "for (i = 0; i < MAXLISTS; ++i)");
-               dump (0, "subc_list_double_create(&p->dl_%s[i]) ;",
+               dump (0, "subc_list_%s_create(&p->%cl_%s[i]) ;",
+                      sbc->type == SBC_INT_LIST ? "int" : "double",
+                      sbc->type == SBC_INT_LIST ? 'i' : 'd',
                      st_lower (sbc->name)
                      );
                dump (-2, "}");
@@ -1710,7 +1710,7 @@
       dump (-1, "p->n_%s = lex_integer (lexer);", st_lower (sbc->name));
       dump (0, "lex_match (lexer, ')');");
     }
-  else if (sbc->type == SBC_DBL_LIST)
+  else if (sbc->type == SBC_DBL_LIST || sbc->type == SBC_INT_LIST)
     {
       dump (0, "if ( p->sbc_%s > MAXLISTS)",st_lower(sbc->name));
       dump (1, "{");
@@ -1726,9 +1726,10 @@
       dump (0, "goto lossage;");
       dump (-1,"}");
 
-      dump (0, "subc_list_double_push (&p->dl_%s[p->sbc_%s-1], lex_number 
(lexer));", 
-           st_lower (sbc->name), st_lower (sbc->name)
-           );
+      dump (0, "subc_list_%s_push (&p->%cl_%s[p->sbc_%s-1], lex_number 
(lexer));",
+            sbc->type == SBC_INT_LIST ? "int" : "double",
+            sbc->type == SBC_INT_LIST ? 'i' : 'd',
+            st_lower (sbc->name), st_lower (sbc->name));
 
       dump (0, "lex_get (lexer);");
       dump (-1,"}");
@@ -1937,13 +1938,9 @@
   if ( ! persistent ) 
     {
       for (sbc = subcommands; sbc; sbc = sbc->next)
-       {
-          if (sbc->type == SBC_STRING)
-            used = 1;
-          if (sbc->type == SBC_DBL_LIST)
-            used = 1;
-       }
-
+        used = (sbc->type == SBC_STRING
+                || sbc->type == SBC_DBL_LIST
+                || sbc->type == SBC_INT_LIST);
     }
 
   dump (0, "static void");
@@ -1965,10 +1962,14 @@
              dump (0, "free (p->s_%s);", st_lower (sbc->name));
              break;
            case SBC_DBL_LIST:
+           case SBC_INT_LIST:
               dump (0, "{");
              dump (1, "int i;");
              dump (2, "for(i = 0; i < MAXLISTS ; ++i)");
-             dump (1, "subc_list_double_destroy(&p->dl_%s[i]);", st_lower 
(sbc->name));
+             dump (1, "subc_list_%s_destroy(&p->%cl_%s[i]);",
+                    sbc->type == SBC_INT_LIST ? "int" : "double",
+                    sbc->type == SBC_INT_LIST ? 'i' : 'd',
+                    st_lower (sbc->name));
               dump (0, "}");
              outdent();
              break;

Index: subcommand-list.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/lexer/subcommand-list.c,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -b -r1.3 -r1.3.2.1
--- subcommand-list.c   16 Dec 2006 04:26:42 -0000      1.3
+++ subcommand-list.c   15 Apr 2007 05:14:31 -0000      1.3.2.1
@@ -38,6 +38,14 @@
   l->n_data = 0;
 }
 
+void
+subc_list_int_create(subc_list_int *l)
+{
+  l->data = xnmalloc (CHUNKSIZE, sizeof *l->data);
+  l->sz = CHUNKSIZE;
+  l->n_data = 0;
+}
+
 /* Push a value onto the list */
 void
 subc_list_double_push(subc_list_double *l, double d)
@@ -52,6 +60,19 @@
 
 }
 
+void
+subc_list_int_push(subc_list_int *l, int d)
+{
+  l->data[l->n_data++] = d;
+
+  if (l->n_data >= l->sz ) 
+    {
+      l->sz += CHUNKSIZE;
+      l->data = xnrealloc (l->data, l->sz, sizeof *l->data);
+    }
+
+}
+
 /* Return the number of items in the list */
 int 
 subc_list_double_count(const subc_list_double *l)
@@ -59,6 +80,12 @@
   return l->n_data;
 }
 
+int 
+subc_list_int_count(const subc_list_int *l)
+{
+  return l->n_data;
+}
+
 
 /* Index into the list (array) */
 double
@@ -67,9 +94,21 @@
   return l->data[idx];
 }
 
+int
+subc_list_int_at(const subc_list_int *l, int idx)
+{
+  return l->data[idx];
+}
+
 /* Free up the list */
 void
 subc_list_double_destroy(subc_list_double *l)
 {
   free(l->data);
 }
+
+void
+subc_list_int_destroy(subc_list_int *l)
+{
+  free(l->data);
+}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]