projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed design matrix column-to-variable matching
[pspp]
/
src
/
sel-if.c
diff --git
a/src/sel-if.c
b/src/sel-if.c
index 07fe318f114b578991aee80a73235f46d5fee1f7..10d1030f004f70eb4419c2a1a060482e2519bebf 100644
(file)
--- a/
src/sel-if.c
+++ b/
src/sel-if.c
@@
-14,27
+14,31
@@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
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., 5
9 Temple Place - Suite 330
, Boston, MA
- 0211
1-1307
, USA. */
+ Foundation, Inc., 5
1 Franklin Street, Fifth Floor
, Boston, MA
+ 0211
0-1301
, USA. */
#include <config.h>
#include <config.h>
+#include <stdlib.h>
#include "alloc.h"
#include "command.h"
#include "alloc.h"
#include "command.h"
+#include "dictionary.h"
#include "error.h"
#include "error.h"
-#include "expr.h"
+#include "expr
essions/public
.h"
#include "lexer.h"
#include "str.h"
#include "var.h"
#include "lexer.h"
#include "str.h"
#include "var.h"
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
/* SELECT IF transformation. */
struct select_if_trns
{
/* SELECT IF transformation. */
struct select_if_trns
{
- struct trns_header h;
struct expression *e; /* Test expression. */
};
struct expression *e; /* Test expression. */
};
-static
int select_if_proc (struct trns_header *, struct ccase *)
;
-static
void select_if_free (struct trns_header *)
;
+static
trns_proc_func select_if_proc
;
+static
trns_free_func select_if_free
;
/* Parses the SELECT IF transformation. */
int
/* Parses the SELECT IF transformation. */
int
@@
-43,10
+47,7
@@
cmd_select_if (void)
struct expression *e;
struct select_if_trns *t;
struct expression *e;
struct select_if_trns *t;
- lex_match_id ("SELECT");
- lex_match_id ("IF");
-
- e = expr_parse (PXP_BOOLEAN);
+ e = expr_parse (default_dict, EXPR_BOOLEAN);
if (!e)
return CMD_FAILURE;
if (!e)
return CMD_FAILURE;
@@
-58,34
+59,34
@@
cmd_select_if (void)
}
t = xmalloc (sizeof *t);
}
t = xmalloc (sizeof *t);
- t->h.proc = select_if_proc;
- t->h.free = select_if_free;
t->e = e;
t->e = e;
- add_transformation (
(struct trns_header *)
t);
+ add_transformation (
select_if_proc, select_if_free,
t);
return CMD_SUCCESS;
}
/* Performs the SELECT IF transformation T on case C. */
static int
return CMD_SUCCESS;
}
/* Performs the SELECT IF transformation T on case C. */
static int
-select_if_proc (struct trns_header * t, struct ccase * c)
+select_if_proc (void *t_, struct ccase *c,
+ int case_num)
{
{
- return (expr_evaluate (((struct select_if_trns *) t)->e, c, NULL) == 1.0) - 2;
+ struct select_if_trns *t = t_;
+ return expr_evaluate_num (t->e, c, case_num) == 1.0 ? -1 : -2;
}
/* Frees SELECT IF transformation T. */
static void
}
/* Frees SELECT IF transformation T. */
static void
-select_if_free (
struct trns_header * t
)
+select_if_free (
void *t_
)
{
{
- expr_free (((struct select_if_trns *) t)->e);
+ struct select_if_trns *t = t_;
+ expr_free (t->e);
+ free (t);
}
/* Parses the FILTER command. */
int
cmd_filter (void)
{
}
/* Parses the FILTER command. */
int
cmd_filter (void)
{
- lex_match_id ("FILTER");
-
if (lex_match_id ("OFF"))
dict_set_filter (default_dict, NULL);
else
if (lex_match_id ("OFF"))
dict_set_filter (default_dict, NULL);
else
@@
-103,7
+104,7
@@
cmd_filter (void)
return CMD_FAILURE;
}
return CMD_FAILURE;
}
- if (
v->name[0] == '#'
)
+ if (
dict_class_from_id (v->name) == DC_SCRATCH
)
{
msg (SE, _("The filter variable may not be scratch."));
return CMD_FAILURE;
{
msg (SE, _("The filter variable may not be scratch."));
return CMD_FAILURE;
@@
-123,10
+124,7
@@
cmd_process_if (void)
{
struct expression *e;
{
struct expression *e;
- lex_match_id ("PROCESS");
- lex_match_id ("IF");
-
- e = expr_parse (PXP_BOOLEAN);
+ e = expr_parse (default_dict, EXPR_BOOLEAN);
if (!e)
return CMD_FAILURE;
if (!e)
return CMD_FAILURE;