Add aux data parameter to q2c parse_<command>() and custom parser
[pspp] / src / data / case.h
index 6f6abeb50938a67f10c710a3d38ddeea59669c5d..05c4568c6befe3f501cfcf65dd622ab10ee6023c 100644 (file)
@@ -30,7 +30,7 @@
 struct ccase 
   {
     struct case_data *case_data;        /* Actual data. */
-#if GLOBAL_DEBUGGING
+#if DEBUGGING
     struct ccase *this;                 /* Detects unauthorized move/copy. */
 #endif
   };
@@ -43,7 +43,7 @@ struct case_data
     union value values[1];              /* Values. */
   };
 
-#ifdef GLOBAL_DEBUGGING
+#ifdef DEBUGGING
 #define CASE_INLINE
 #else
 #define CASE_INLINE static
@@ -89,9 +89,9 @@ union value *case_data_all_rw (struct ccase *);
 
 void case_unshare (struct ccase *);
 
-#ifndef GLOBAL_DEBUGGING
+#ifndef DEBUGGING
 #include <stdlib.h>
-#include "str.h"
+#include <libpspp/str.h>
 
 static inline void
 case_nullify (struct ccase *c) 
@@ -115,8 +115,11 @@ case_clone (struct ccase *clone, const struct ccase *orig)
 static inline void
 case_move (struct ccase *dst, struct ccase *src) 
 {
-  *dst = *src;
-  src->case_data = NULL;
+  if (dst != src) 
+    {
+      *dst = *src;
+      src->case_data = NULL; 
+    }
 }
 
 static inline void
@@ -132,12 +135,14 @@ case_copy (struct ccase *dst, size_t dst_idx,
            const struct ccase *src, size_t src_idx,
            size_t value_cnt) 
 {
-  if (dst->case_data->ref_cnt > 1)
-    case_unshare (dst);
   if (dst->case_data != src->case_data || dst_idx != src_idx) 
-    memmove (dst->case_data->values + dst_idx,
-             src->case_data->values + src_idx,
-             sizeof *dst->case_data->values * value_cnt); 
+    {
+      if (dst->case_data->ref_cnt > 1)
+        case_unshare (dst);
+      memmove (dst->case_data->values + dst_idx,
+               src->case_data->values + src_idx,
+               sizeof *dst->case_data->values * value_cnt); 
+    }
 }
 
 static inline void
@@ -183,6 +188,6 @@ case_data_rw (struct ccase *c, size_t idx)
     case_unshare (c);
   return &c->case_data->values[idx];
 }
-#endif /* !GLOBAL_DEBUGGING */
+#endif /* !DEBUGGING */
 
 #endif /* case.h */