X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fexpressions%2Fevaluate.c;h=4331d030ff65285761e1a5cf1f50287eedd156ea;hb=bbe7ad1a7454599693c188fe1eaf8f5d6e154206;hp=c2868429b246b6f9dc06d5d739b0629ce80c01e3;hpb=d807ad29cc0d3caa4f0e04ee4b75c70a225cfeaf;p=pspp diff --git a/src/expressions/evaluate.c b/src/expressions/evaluate.c index c2868429b2..4331d030ff 100644 --- a/src/expressions/evaluate.c +++ b/src/expressions/evaluate.c @@ -14,23 +14,12 @@ 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., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ #include #include "private.h" -#if TIME_WITH_SYS_TIME -#include -#include -#else -#if HAVE_SYS_TIME_H -#include -#else -#include -#endif -#endif - #include #include "alloc.h" #include "error.h" @@ -102,7 +91,7 @@ expr_evaluate_str (struct expression *e, const struct ccase *c, int case_idx, assert (e->type == OP_string); assert ((dst == NULL) == (dst_size == 0)); expr_evaluate (e, c, case_idx, &s); - st_bare_pad_len_copy (dst, s.string, dst_size, s.length); + buf_copy_rpad (dst, dst_size, s.string, s.length); } #include "lexer.h" @@ -127,7 +116,7 @@ cmd_debug_evaluate (void) dump_postfix = 1; else if (lex_match ('(')) { - char name[MAX_VAR_NAME_LEN + 1]; + char name[LONG_NAME_LEN + 1]; struct variable *v; size_t old_value_cnt; int width; @@ -140,7 +129,7 @@ cmd_debug_evaluate (void) if (!lex_force_match ('=')) goto done; - if (token == T_NUM) + if (lex_is_number ()) { width = 0; fprintf (stderr, "(%s = %.2f)", name, tokval); @@ -174,7 +163,7 @@ cmd_debug_evaluate (void) } case_resize (c, old_value_cnt, dict_get_next_value_idx (d)); - if (token == T_NUM) + if (lex_is_number ()) case_data_rw (c, v->fv)->f = tokval; else memcpy (case_data_rw (c, v->fv)->s, ds_data (&tokstr), @@ -198,7 +187,7 @@ cmd_debug_evaluate (void) lex_get (); expr = expr_parse_any (d, optimize); - if (!expr || token != '.') + if (!expr || lex_end_of_command () != CMD_SUCCESS) { if (expr != NULL) expr_free (expr); @@ -248,8 +237,12 @@ cmd_debug_evaluate (void) retval = CMD_SUCCESS; done: - if (c != NULL) - case_destroy (c); + if (c != NULL) + { + case_destroy (c); + free (c); + } + dict_destroy (d); return retval; } @@ -285,7 +278,8 @@ expr_debug_print_postfix (const struct expression *e) break; case OP_string: fprintf (stderr, "s<%.*s>", - (int) op->string.length, op->string.string); + (int) op->string.length, + op->string.string != NULL ? op->string.string : ""); break; case OP_format: fprintf (stderr, "f<%s%d.%d>",