75 |
union value sysmis; /* Coding for SYSMIS (if src is numeric). */ |
union value sysmis; /* Coding for SYSMIS (if src is numeric). */ |
76 |
|
|
77 |
struct coding *map; /* Coding for other values. */ |
struct coding *map; /* Coding for other values. */ |
78 |
int nmap, mmap; /* Length of map, max capacity of map. */ |
size_t nmap, mmap; /* Length of map, max capacity of map. */ |
79 |
}; |
}; |
80 |
|
|
81 |
/* RECODE transformation. */ |
/* RECODE transformation. */ |
118 |
int |
int |
119 |
cmd_recode (void) |
cmd_recode (void) |
120 |
{ |
{ |
121 |
int i; |
size_t i; |
122 |
|
|
123 |
/* Transformation that we're constructing. */ |
/* Transformation that we're constructing. */ |
124 |
struct rcd_var *rcd; |
struct rcd_var *rcd; |
145 |
|
|
146 |
/* Variables in the current part of the recoding. */ |
/* Variables in the current part of the recoding. */ |
147 |
struct variable **v; |
struct variable **v; |
148 |
int nv; |
size_t nv; |
149 |
|
|
150 |
/* Parses each specification between slashes. */ |
/* Parses each specification between slashes. */ |
151 |
head = rcd = xmalloc (sizeof *rcd); |
head = rcd = xmalloc (sizeof *rcd); |
190 |
for (;;) |
for (;;) |
191 |
{ |
{ |
192 |
/* Get the input value (before the `='). */ |
/* Get the input value (before the `='). */ |
193 |
int mark = rcd->nmap; |
size_t mark = rcd->nmap; |
194 |
int code = parse_src_spec (rcd, type, max_src_width); |
int code = parse_src_spec (rcd, type, max_src_width); |
195 |
if (!code) |
if (!code) |
196 |
goto lossage; |
goto lossage; |
271 |
if (lex_match_id ("INTO")) |
if (lex_match_id ("INTO")) |
272 |
{ |
{ |
273 |
char **names; |
char **names; |
274 |
int nnames; |
size_t nnames; |
275 |
|
|
276 |
int success = 0; |
int success = 0; |
277 |
|
|
283 |
for (i = 0; i < nnames; i++) |
for (i = 0; i < nnames; i++) |
284 |
free (names[i]); |
free (names[i]); |
285 |
free (names); |
free (names); |
286 |
msg (SE, _("%d variable(s) cannot be recoded into " |
msg (SE, _("%u variable(s) cannot be recoded into " |
287 |
"%d variable(s). Specify the same number " |
"%u variable(s). Specify the same number " |
288 |
"of variables as input and output variables."), |
"of variables as input and output variables."), |
289 |
nv, nnames); |
(unsigned) nv, (unsigned) nnames); |
290 |
goto lossage; |
goto lossage; |
291 |
} |
} |
292 |
|
|
298 |
if (!v) |
if (!v) |
299 |
{ |
{ |
300 |
msg (SE, _("There is no string variable named " |
msg (SE, _("There is no string variable named " |
301 |
"%s. (All string variables specified " |
"%s. (All string variables specified " |
302 |
"on INTO must already exist. Use the " |
"on INTO must already exist. Use the " |
303 |
"STRING command to create a string " |
"STRING command to create a string " |
304 |
"variable.)"), names[i]); |
"variable.)"), |
305 |
|
names[i]); |
306 |
goto INTO_fail; |
goto INTO_fail; |
307 |
} |
} |
308 |
if (v->type != ALPHA) |
if (v->type != ALPHA) |
309 |
{ |
{ |
310 |
msg (SE, _("Type mismatch between input and output " |
msg (SE, _("Type mismatch between input and output " |
311 |
"variables. Output variable %s is not " |
"variables. Output variable %s is not " |
312 |
"a string variable, but all the input " |
"a string variable, but all the input " |
313 |
"variables are string variables."), v->name); |
"variables are string variables."), |
314 |
|
v->name); |
315 |
goto INTO_fail; |
goto INTO_fail; |
316 |
} |
} |
317 |
if (v->width > (int) max_dst_width) |
if (v->width > (int) max_dst_width) |
521 |
|
|
522 |
for (;;) |
for (;;) |
523 |
{ |
{ |
524 |
if (rcd->nmap >= rcd->mmap - 1) |
if (rcd->nmap + 1 >= rcd->mmap) |
525 |
{ |
{ |
526 |
rcd->mmap += 16; |
rcd->mmap += 16; |
527 |
rcd->map = xrealloc (rcd->map, rcd->mmap * sizeof *rcd->map); |
rcd->map = xrealloc (rcd->map, rcd->mmap * sizeof *rcd->map); |
651 |
static void |
static void |
652 |
recode_trns_free (struct trns_header * t) |
recode_trns_free (struct trns_header * t) |
653 |
{ |
{ |
654 |
int i; |
size_t i; |
655 |
struct rcd_var *head, *next; |
struct rcd_var *head, *next; |
656 |
|
|
657 |
head = ((struct recode_trns *) t)->codings; |
head = ((struct recode_trns *) t)->codings; |
836 |
string_to_long (const char *nptr, int width, const char **endptr) |
string_to_long (const char *nptr, int width, const char **endptr) |
837 |
{ |
{ |
838 |
int negative; |
int negative; |
839 |
register unsigned long int cutoff; |
unsigned long int cutoff; |
840 |
register unsigned int cutlim; |
unsigned int cutlim; |
841 |
register unsigned long int i; |
unsigned long int i; |
842 |
register const char *s; |
const char *s; |
843 |
register unsigned char c; |
unsigned char c; |
844 |
const char *save; |
const char *save; |
845 |
|
|
846 |
s = nptr; |
s = nptr; |
911 |
static double |
static double |
912 |
convert_to_double (const char *s, int width) |
convert_to_double (const char *s, int width) |
913 |
{ |
{ |
914 |
register const char *end = &s[width]; |
const char *end = &s[width]; |
915 |
|
|
916 |
short int sign; |
short int sign; |
917 |
|
|