X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=inline;f=src%2Flanguage%2Fexpressions%2Fevaluate.c;h=9398b41cd239b285061cffca4522e87f806d15ca;hb=762876f19fa870401ae882515de1b58703b73ac4;hp=e5f605b797966f7009ca5c48ef0d09694f530e2e;hpb=dcf9b154cbcaa35c3d8459a201b77eec8bcb30bd;p=pspp-builds.git diff --git a/src/language/expressions/evaluate.c b/src/language/expressions/evaluate.c index e5f605b7..9398b41c 100644 --- a/src/language/expressions/evaluate.c +++ b/src/language/expressions/evaluate.c @@ -21,11 +21,11 @@ #include "private.h" #include -#include "alloc.h" -#include "message.h" +#include +#include #include "helpers.h" #include "evaluate.h" -#include "pool.h" +#include static void expr_evaluate (struct expression *e, const struct ccase *c, int case_idx, @@ -34,7 +34,7 @@ expr_evaluate (struct expression *e, const struct ccase *c, int case_idx, union operation_data *op = e->ops; double *ns = e->number_stack; - struct fixed_string *ss = e->string_stack; + struct substring *ss = e->string_stack; assert ((c != NULL) == (e->dict != NULL)); pool_clear (e->eval_pool); @@ -51,7 +51,7 @@ expr_evaluate (struct expression *e, const struct ccase *c, int case_idx, case OP_string: { - const struct fixed_string *s = &op++->string; + const struct substring *s = &op++->string; *ss++ = copy_string (e, s->string, s->length); } break; @@ -61,7 +61,7 @@ expr_evaluate (struct expression *e, const struct ccase *c, int case_idx, return; case OP_return_string: - *(struct fixed_string *) result = ss[-1]; + *(struct substring *) result = ss[-1]; return; #include "evaluate.inc" @@ -82,20 +82,23 @@ expr_evaluate_num (struct expression *e, const struct ccase *c, int case_idx) return d; } + + void expr_evaluate_str (struct expression *e, const struct ccase *c, int case_idx, char *dst, size_t dst_size) { - struct fixed_string s; + struct substring s; assert (e->type == OP_string); assert ((dst == NULL) == (dst_size == 0)); expr_evaluate (e, c, case_idx, &s); + buf_copy_rpad (dst, dst_size, s.string, s.length); } -#include "lexer.h" -#include "command.h" +#include +#include int cmd_debug_evaluate (void) @@ -137,7 +140,7 @@ cmd_debug_evaluate (void) else if (token == T_STRING) { width = ds_length (&tokstr); - fprintf (stderr, "(%s = \"%.2s\")", name, ds_c_str (&tokstr)); + fprintf (stderr, "(%s = \"%.2s\")", name, ds_cstr (&tokstr)); } else { @@ -220,7 +223,7 @@ cmd_debug_evaluate (void) case OP_string: { - struct fixed_string s; + struct substring s; expr_evaluate (expr, c, 0, &s); fputc ('"', stderr);