65 |
|
VARIABLE *(*mv)(const char*) |
66 |
|
) |
67 |
|
{ |
68 |
+ |
int quote = '\0'; |
69 |
|
char varname[32]; |
70 |
|
int n; |
71 |
|
char *cp; |
107 |
|
perror(progname); |
108 |
|
quit(1); |
109 |
|
} |
110 |
< |
cp = vp->value+i; /* copy value, squeezing spaces */ |
110 |
> |
cp = vp->value+i; /* copy value */ |
111 |
|
*cp = *ass; |
112 |
|
for (i = 1; i <= n; i++) { |
113 |
|
if (ass[i] == NOCHAR) |
114 |
|
continue; |
115 |
< |
if (isspace(*cp)) |
116 |
< |
while (isspace(ass[i])) |
117 |
< |
i++; |
115 |
> |
if (quote) { /* don't change quoted parts */ |
116 |
> |
quote *= (ass[i] != quote); |
117 |
> |
} else { /* otherwise, squeeze spaces */ |
118 |
> |
if (isspace(*cp)) |
119 |
> |
while (isspace(ass[i])) |
120 |
> |
i++; |
121 |
> |
if ((ass[i] == '"') | (ass[i] == '\'')) |
122 |
> |
quote = ass[i]; |
123 |
> |
} |
124 |
|
*++cp = ass[i]; |
125 |
|
} |
126 |
|
if (isspace(*cp)) /* remove trailing space */ |
264 |
|
fprintf(stderr, "%s: illegal value for qualitative variable '%s'\n", |
265 |
|
progname, vp->name); |
266 |
|
quit(1); |
267 |
+ |
} |
268 |
+ |
|
269 |
+ |
void |
270 |
+ |
strvalue( /* check for single (quoted) string value */ |
271 |
+ |
VARIABLE *vp |
272 |
+ |
) |
273 |
+ |
{ |
274 |
+ |
if (!vp->nass) return; |
275 |
+ |
onevalue(vp); |
276 |
+ |
if ((vp->value[0] == '"') | (vp->value[0] == '\'')) { |
277 |
+ |
char *cp = vp->value + strlen(vp->value+1); |
278 |
+ |
if ((cp != vp->value) & (*cp == vp->value[0])) { |
279 |
+ |
vp->value++; /* elide quotation marks */ |
280 |
+ |
*cp = '\0'; |
281 |
+ |
} |
282 |
+ |
} |
283 |
|
} |
284 |
|
|
285 |
|
|