control-stack: Move from language to data directory.
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 3 Aug 2013 23:51:31 +0000 (16:51 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Mon, 16 Feb 2015 19:25:09 +0000 (11:25 -0800)
src/data/automake.mk
src/data/control-stack.c [new file with mode: 0644]
src/data/control-stack.h [new file with mode: 0644]
src/data/transformations.c
src/language/control/automake.mk
src/language/control/control-stack.c [deleted file]
src/language/control/control-stack.h [deleted file]
src/language/control/do-if.c
src/language/control/loop.c
src/language/control/temporary.c

index 17d5ce1d6fc5c4b497f570484c8299fc3129b6c1..43e3d4e172827282f0dd26b62a645ddfe8ae8a18 100644 (file)
@@ -43,6 +43,8 @@ src_data_libdata_la_SOURCES = \
        src/data/case-tmpfile.c \
        src/data/case-tmpfile.h \
        src/data/column.h \
+       src/data/control-stack.c \
+       src/data/control-stack.h \
        src/data/csv-file-writer.c \
        src/data/csv-file-writer.h \
        src/data/data-in.c \
diff --git a/src/data/control-stack.c b/src/data/control-stack.c
new file mode 100644 (file)
index 0000000..d8228f8
--- /dev/null
@@ -0,0 +1,98 @@
+#include <config.h>
+
+#include "data/control-stack.h"
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include "libpspp/compiler.h"
+#include "libpspp/message.h"
+
+#include "gl/xalloc.h"
+
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
+struct ctl_struct
+  {
+    const struct ctl_class *class;    /* Class of control structure. */
+    struct ctl_struct *down;   /* Points toward the bottom of ctl_stack. */
+    void *private;              /* Private data. */
+  };
+
+static struct ctl_struct *ctl_stack;
+
+void
+ctl_stack_clear (void)
+{
+  while (ctl_stack != NULL)
+    {
+      struct ctl_struct *top = ctl_stack;
+      msg (SE, _("%s without %s."),
+           top->class->start_name, top->class->end_name);
+      ctl_stack_pop (top->private);
+    }
+}
+
+void
+ctl_stack_push (const struct ctl_class *class, void *private)
+{
+  struct ctl_struct *ctl;
+
+  assert (private != NULL);
+  ctl = xmalloc (sizeof *ctl);
+  ctl->class = class;
+  ctl->down = ctl_stack;
+  ctl->private = private;
+  ctl_stack = ctl;
+}
+
+void *
+ctl_stack_top (const struct ctl_class *class)
+{
+  struct ctl_struct *top = ctl_stack;
+  if (top != NULL && top->class == class)
+    return top->private;
+  else
+    {
+      if (ctl_stack_search (class) != NULL)
+        msg (SE, _("This command must appear inside %s...%s, "
+                   "without intermediate %s...%s."),
+             class->start_name, class->end_name,
+             top->class->start_name, top->class->end_name);
+      return NULL;
+    }
+}
+
+void *
+ctl_stack_search (const struct ctl_class *class)
+{
+  struct ctl_struct *ctl;
+
+  for (ctl = ctl_stack; ctl != NULL; ctl = ctl->down)
+    if (ctl->class == class)
+      return ctl->private;
+
+  msg (SE, _("This command cannot appear outside %s...%s."),
+       class->start_name, class->end_name);
+  return NULL;
+}
+
+void
+ctl_stack_pop (void *private)
+{
+  struct ctl_struct *top = ctl_stack;
+
+  assert (top != NULL);
+  assert (top->private == private);
+
+  top->class->close (top->private);
+  ctl_stack = top->down;
+  free (top);
+}
+
+bool
+ctl_stack_is_empty (void)
+{
+  return ctl_stack == NULL;
+}
diff --git a/src/data/control-stack.h b/src/data/control-stack.h
new file mode 100644 (file)
index 0000000..9c6824b
--- /dev/null
@@ -0,0 +1,43 @@
+/* PSPP - a program for statistical analysis.
+   Copyright (C) 1997-9, 2000, 2011 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef CTL_STACK_H
+#define CTL_STACK_H 1
+
+#include <stdbool.h>
+
+/* The following #include avoids a potential problem when Gnulib substitutes
+ * for close() by putting "#define close rpl_close" into <unistd.h>, by
+ * ensuring that every source file that includes this one sees the #define..
+ * (It would probably be better to rename the 'close' member of struct
+ * ctl_class.)  */
+#include <unistd.h>
+
+struct ctl_class
+  {
+    const char *start_name;     /* e.g. LOOP. */
+    const char *end_name;       /* e.g. END LOOP. */
+    void (*close) (void *);     /* Closes the control structure. */
+  };
+
+void ctl_stack_clear (void);
+void ctl_stack_push (const struct ctl_class *, void *private);
+void *ctl_stack_top (const struct ctl_class *);
+void *ctl_stack_search (const struct ctl_class *);
+void ctl_stack_pop (void *);
+bool ctl_stack_is_empty (void);
+
+#endif /* ctl_stack.h */
index 884def67531de301129872b6298f96327b6d5d09..700ed85e40c6285963716857931e597665d6fcfb 100644 (file)
@@ -22,7 +22,7 @@
 #include <stdlib.h>
 
 #include "libpspp/str.h"
-#include "language/control/control-stack.h" /* XXX layering violation */
+#include "data/control-stack.h" /* XXX layering violation */
 
 #include "gl/xalloc.h"
 
index 11c5fdc3d05a24b462bcef36adff693628608ec9..ca665309eed69e4fc081a9da1db335e046a9a813 100644 (file)
@@ -2,8 +2,6 @@
 
 
 language_control_sources = \
-       src/language/control/control-stack.c \
-       src/language/control/control-stack.h \
        src/language/control/do-if.c \
        src/language/control/loop.c \
        src/language/control/repeat.c \
diff --git a/src/language/control/control-stack.c b/src/language/control/control-stack.c
deleted file mode 100644 (file)
index f806c78..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-#include <config.h>
-
-#include "language/control/control-stack.h"
-
-#include <assert.h>
-#include <stdlib.h>
-
-#include "libpspp/compiler.h"
-#include "libpspp/message.h"
-
-#include "gl/xalloc.h"
-
-#include "gettext.h"
-#define _(msgid) gettext (msgid)
-
-struct ctl_struct
-  {
-    const struct ctl_class *class;    /* Class of control structure. */
-    struct ctl_struct *down;   /* Points toward the bottom of ctl_stack. */
-    void *private;              /* Private data. */
-  };
-
-static struct ctl_struct *ctl_stack;
-
-void
-ctl_stack_clear (void)
-{
-  while (ctl_stack != NULL)
-    {
-      struct ctl_struct *top = ctl_stack;
-      msg (SE, _("%s without %s."),
-           top->class->start_name, top->class->end_name);
-      ctl_stack_pop (top->private);
-    }
-}
-
-void
-ctl_stack_push (const struct ctl_class *class, void *private)
-{
-  struct ctl_struct *ctl;
-
-  assert (private != NULL);
-  ctl = xmalloc (sizeof *ctl);
-  ctl->class = class;
-  ctl->down = ctl_stack;
-  ctl->private = private;
-  ctl_stack = ctl;
-}
-
-void *
-ctl_stack_top (const struct ctl_class *class)
-{
-  struct ctl_struct *top = ctl_stack;
-  if (top != NULL && top->class == class)
-    return top->private;
-  else
-    {
-      if (ctl_stack_search (class) != NULL)
-        msg (SE, _("This command must appear inside %s...%s, "
-                   "without intermediate %s...%s."),
-             class->start_name, class->end_name,
-             top->class->start_name, top->class->end_name);
-      return NULL;
-    }
-}
-
-void *
-ctl_stack_search (const struct ctl_class *class)
-{
-  struct ctl_struct *ctl;
-
-  for (ctl = ctl_stack; ctl != NULL; ctl = ctl->down)
-    if (ctl->class == class)
-      return ctl->private;
-
-  msg (SE, _("This command cannot appear outside %s...%s."),
-       class->start_name, class->end_name);
-  return NULL;
-}
-
-void
-ctl_stack_pop (void *private)
-{
-  struct ctl_struct *top = ctl_stack;
-
-  assert (top != NULL);
-  assert (top->private == private);
-
-  top->class->close (top->private);
-  ctl_stack = top->down;
-  free (top);
-}
-
-bool
-ctl_stack_is_empty (void)
-{
-  return ctl_stack == NULL;
-}
diff --git a/src/language/control/control-stack.h b/src/language/control/control-stack.h
deleted file mode 100644 (file)
index 9c6824b..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2011 Free Software Foundation, Inc.
-
-   This program is free software: you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation, either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef CTL_STACK_H
-#define CTL_STACK_H 1
-
-#include <stdbool.h>
-
-/* The following #include avoids a potential problem when Gnulib substitutes
- * for close() by putting "#define close rpl_close" into <unistd.h>, by
- * ensuring that every source file that includes this one sees the #define..
- * (It would probably be better to rename the 'close' member of struct
- * ctl_class.)  */
-#include <unistd.h>
-
-struct ctl_class
-  {
-    const char *start_name;     /* e.g. LOOP. */
-    const char *end_name;       /* e.g. END LOOP. */
-    void (*close) (void *);     /* Closes the control structure. */
-  };
-
-void ctl_stack_clear (void);
-void ctl_stack_push (const struct ctl_class *, void *private);
-void *ctl_stack_top (const struct ctl_class *);
-void *ctl_stack_search (const struct ctl_class *);
-void ctl_stack_pop (void *);
-bool ctl_stack_is_empty (void);
-
-#endif /* ctl_stack.h */
index bbb8fa92c5ee1343b7a620f586b578f1757e18a9..ea7056709115da24c396d84114de751a982345d9 100644 (file)
 #include <stdlib.h>
 
 #include "data/case.h"
+#include "data/control-stack.h"
 #include "data/dataset.h"
 #include "data/transformations.h"
 #include "data/value.h"
 #include "language/command.h"
-#include "language/control/control-stack.h"
 #include "language/expressions/public.h"
 #include "language/lexer/lexer.h"
 #include "libpspp/compiler.h"
index 4d2aaa33a44636e615618fc3de27a3846206a023..34c6a1d36307f254a986357816d2d46cc736e2d3 100644 (file)
@@ -16,9 +16,8 @@
 
 #include <config.h>
 
-#include "language/control/control-stack.h"
-
 #include "data/case.h"
+#include "data/control-stack.h"
 #include "data/dataset.h"
 #include "data/dictionary.h"
 #include "data/settings.h"
index 7ebcc5ad9c8b92092a8850ddd05d547e58be4ffb..75e5e7b28a10569d404558973b3ee2d928931254 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2010, 2011, 2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 #include <stddef.h>
 #include <stdlib.h>
 
+#include "data/control-stack.h"
 #include "data/dataset.h"
 #include "data/dictionary.h"
 #include "data/transformations.h"
 #include "data/value-labels.h"
 #include "data/variable.h"
 #include "language/command.h"
-#include "language/control/control-stack.h"
 #include "language/lexer/lexer.h"
 #include "libpspp/message.h"
 #include "libpspp/str.h"