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 <config.h>
#include <stdio.h>
int
cmd_value_labels (void)
{
- lex_match_id ("VALUE");
- lex_match_id ("LABELS");
return do_value_labels (1);
}
int
cmd_add_value_labels (void)
{
- lex_match_id ("ADD");
- lex_match_id ("VALUE");
- lex_match_id ("LABELS");
return do_value_labels (0);
}
\f
{
struct variable **vars; /* Variable list. */
int var_cnt; /* Number of variables. */
+ int parse_err=0; /* true if error parsing variables */
lex_match ('/');
while (token != '.')
{
- parse_variables (default_dict, &vars, &var_cnt, PV_SAME_TYPE);
+ parse_err = !parse_variables (default_dict, &vars, &var_cnt,
+ PV_SAME_TYPE) ;
+ if (var_cnt < 1)
+ {
+ free(vars);
+ return CMD_FAILURE;
+ }
if (!verify_val_labs (vars, var_cnt))
goto lossage;
if (erase)
goto lossage;
if (token != '/')
+ {
+ free (vars);
break;
+ }
+
lex_get ();
free (vars);
return CMD_TRAILING_GARBAGE;
}
- return CMD_SUCCESS;
+ return parse_err ? CMD_PART_SUCCESS_MAYBE : CMD_SUCCESS;
lossage:
free (vars);
{
struct variable *vp = vars[i];
- if (vp->type == ALPHA && vp->width > 8)
+ if (vp->type == ALPHA && vp->width > MAX_SHORT_STRING)
{
msg (SE, _("It is not possible to assign value labels to long "
"string variables such as %s."), vp->name);
lex_error (_("expecting string"));
return 0;
}
- st_bare_pad_copy (value.s, ds_value (&tokstr), MAX_SHORT_STRING);
+ st_bare_pad_copy (value.s, ds_c_str (&tokstr), MAX_SHORT_STRING);
}
else
{
- if (token != T_NUM)
+ if (!lex_is_number ())
{
lex_error (_("expecting integer"));
return 0;
}
- if (!lex_integer_p ())
+ if (!lex_is_integer ())
msg (SW, _("Value label `%g' is not integer."), tokval);
value.f = tokval;
}
msg (SW, _("Truncating value label to 60 characters."));
ds_truncate (&tokstr, 60);
}
- label = ds_value (&tokstr);
+ label = ds_c_str (&tokstr);
for (i = 0; i < var_cnt; i++)
val_labs_replace (vars[i]->val_labs, value, label);