X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Frecode.c;h=90792afa4197d5a204423b312847e3c2d4d51127;hb=1f053e35b27208cad9bec322c67ba4ef022c1dc1;hp=034ae959e83c2bd7aa02e5c2bbfd26b3fd954aa4;hpb=b321086267ad1014dc5d09886396cde30f094437;p=pspp-builds.git diff --git a/src/recode.c b/src/recode.c index 034ae959..90792afa 100644 --- a/src/recode.c +++ b/src/recode.c @@ -14,8 +14,8 @@ 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 "error.h" @@ -66,7 +66,7 @@ struct rcd_var struct variable *src; /* Source variable. */ struct variable *dest; /* Destination variable. */ - char dest_name[9]; /* Name of dest variable if we're creating it. */ + char dest_name[LONG_NAME_LEN + 1]; /* Name of dest variable if we're creating it. */ int has_sysmis; /* Do we recode for SYSMIS? */ union value sysmis; /* Coding for SYSMIS (if src is numeric). */ @@ -378,7 +378,7 @@ cmd_recode (void) /* The NULL is only really necessary for the debugging code. */ char *repl = xmalloc (max_dst_width + 1); - st_pad_copy (repl, cp->t.c, max_dst_width + 1); + str_copy_rpad (repl, max_dst_width + 1, cp->t.c); free (cp->t.c); cp->t.c = repl; } @@ -412,7 +412,7 @@ cmd_recode (void) rcd->dest = dict_create_var (default_dict, rcd->dest_name, 0); if (!rcd->dest) { - /* FIXME: This can occur if a destname is duplicated. + /* FIXME: This can fail if a destname is duplicated. We could give an error at parse time but I don't care enough. */ rcd->dest = dict_lookup_var_assert (default_dict, rcd->dest_name); @@ -445,7 +445,7 @@ parse_dest_spec (struct rcd_var * rcd, union value * v, size_t *max_dst_width) v->c = NULL; - if (token == T_NUM) + if (lex_is_number ()) { v->f = tokval; lex_get (); @@ -463,7 +463,7 @@ parse_dest_spec (struct rcd_var * rcd, union value * v, size_t *max_dst_width) if (toklen > max) max = toklen; v->c = xmalloc (max + 1); - st_pad_copy (v->c, ds_c_str (&tokstr), max + 1); + str_copy_rpad (v->c, max + 1, ds_c_str (&tokstr)); flags = RCD_DEST_STRING; *max_dst_width = max; lex_get (); @@ -540,7 +540,7 @@ parse_src_spec (struct rcd_var * rcd, int type, size_t max_src_width) return 0; if (lex_match_id ("HI") || lex_match_id ("HIGHEST")) c->type = RCD_ELSE; - else if (token == T_NUM) + else if (lex_is_number ()) { c->type = RCD_LOW; c->f1.f = tokval; @@ -568,7 +568,7 @@ parse_src_spec (struct rcd_var * rcd, int type, size_t max_src_width) return 0; } } - else if (token == T_NUM) + else if (lex_is_number ()) { c->f1.f = tokval; lex_get (); @@ -576,7 +576,7 @@ parse_src_spec (struct rcd_var * rcd, int type, size_t max_src_width) { if (lex_match_id ("HI") || lex_match_id ("HIGHEST")) c->type = RCD_HIGH; - else if (token == T_NUM) + else if (lex_is_number ()) { c->type = RCD_RANGE; c->f2.f = tokval; @@ -626,7 +626,7 @@ parse_src_spec (struct rcd_var * rcd, int type, size_t max_src_width) if (!lex_force_string ()) return 0; c->f1.c = xmalloc (max_src_width + 1); - st_pad_copy (c->f1.c, ds_c_str (&tokstr), max_src_width + 1); + str_copy_rpad (c->f1.c, max_src_width + 1, ds_c_str (&tokstr)); lex_get (); } } @@ -811,9 +811,9 @@ recode_trns_proc (struct trns_header * t, struct ccase * c, if (val == NULL) { if (v->dest->fv != v->src->fv) - st_bare_pad_len_copy (case_data_rw (c, v->dest->fv)->s, - case_str (c, v->src->fv), - v->dest->width, v->src->width); + buf_copy_rpad (case_data_rw (c, v->dest->fv)->s, + v->dest->width, + case_str (c, v->src->fv), v->src->width); } else memcpy (case_data_rw (c, v->dest->fv)->s, cp->t.c, v->dest->width);