projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
track axes
[pspp]
/
src
/
language
/
xforms
/
sample.c
diff --git
a/src/language/xforms/sample.c
b/src/language/xforms/sample.c
index 260841a6029b541ddd97dc3ca811391dfee68471..665cd4468edc370e80390441cb27d1ddb9fa3f27 100644
(file)
--- a/
src/language/xforms/sample.c
+++ b/
src/language/xforms/sample.c
@@
-51,8
+51,7
@@
struct sample_trns
unsigned frac; /* TYPE_FRACTION: a fraction of UINT_MAX. */
};
unsigned frac; /* TYPE_FRACTION: a fraction of UINT_MAX. */
};
-static trns_proc_func sample_trns_proc;
-static trns_free_func sample_trns_free;
+static const struct trns_class sample_trns_class;
int
cmd_sample (struct lexer *lexer, struct dataset *ds)
int
cmd_sample (struct lexer *lexer, struct dataset *ds)
@@
-88,17
+87,9
@@
cmd_sample (struct lexer *lexer, struct dataset *ds)
lex_get (lexer);
if (!lex_force_match_id (lexer, "FROM"))
return CMD_FAILURE;
lex_get (lexer);
if (!lex_force_match_id (lexer, "FROM"))
return CMD_FAILURE;
- if (!lex_force_int
(lexer
))
+ if (!lex_force_int
_range (lexer, "FROM", a + 1, INT_MAX
))
return CMD_FAILURE;
b = lex_integer (lexer);
return CMD_FAILURE;
b = lex_integer (lexer);
- if (a >= b)
- {
- msg (SE, _("Cannot sample %d observations from a population of "
- "%d."),
- a, b);
- return CMD_FAILURE;
- }
-
frac = 0;
}
lex_get (lexer);
frac = 0;
}
lex_get (lexer);
@@
-109,13
+100,13
@@
cmd_sample (struct lexer *lexer, struct dataset *ds)
trns->N = b;
trns->m = trns->t = 0;
trns->frac = frac;
trns->N = b;
trns->m = trns->t = 0;
trns->frac = frac;
- add_transformation (ds,
sample_trns_proc, sample_trns_free
, trns);
+ add_transformation (ds,
&sample_trns_class
, trns);
return CMD_SUCCESS;
}
/* Executes a SAMPLE transformation. */
return CMD_SUCCESS;
}
/* Executes a SAMPLE transformation. */
-static
in
t
+static
enum trns_resul
t
sample_trns_proc (void *t_, struct ccase **c UNUSED,
casenumber case_num UNUSED)
{
sample_trns_proc (void *t_, struct ccase **c UNUSED,
casenumber case_num UNUSED)
{
@@
-154,3
+145,9
@@
sample_trns_free (void *t_)
free (t);
return true;
}
free (t);
return true;
}
+
+static const struct trns_class sample_trns_class = {
+ .name = "SAMPLE",
+ .execute = sample_trns_proc,
+ .destroy = sample_trns_free,
+};