| 7 |
|
|
| 8 |
|
#include "copyright.h" |
| 9 |
|
|
| 10 |
– |
#include <stdio.h> |
| 11 |
– |
#include <stdlib.h> |
| 10 |
|
#include <ctype.h> |
| 11 |
|
|
| 12 |
|
#include "standard.h" |
| 13 |
+ |
#include "paths.h" |
| 14 |
|
#include "vars.h" |
| 15 |
|
|
| 16 |
|
#define NOCHAR 127 /* constant for character to delete */ |
| 64 |
|
VARIABLE *(*mv)(const char*) |
| 65 |
|
) |
| 66 |
|
{ |
| 67 |
+ |
int quote = '\0'; |
| 68 |
|
char varname[32]; |
| 69 |
|
int n; |
| 70 |
|
char *cp; |
| 106 |
|
perror(progname); |
| 107 |
|
quit(1); |
| 108 |
|
} |
| 109 |
< |
cp = vp->value+i; /* copy value, squeezing spaces */ |
| 109 |
> |
cp = vp->value+i; /* copy value */ |
| 110 |
|
*cp = *ass; |
| 111 |
|
for (i = 1; i <= n; i++) { |
| 112 |
|
if (ass[i] == NOCHAR) |
| 113 |
|
continue; |
| 114 |
< |
if (isspace(*cp)) |
| 115 |
< |
while (isspace(ass[i])) |
| 116 |
< |
i++; |
| 114 |
> |
if (quote) { /* don't change quoted parts */ |
| 115 |
> |
quote *= (ass[i] != quote); |
| 116 |
> |
} else { /* otherwise, squeeze spaces */ |
| 117 |
> |
if (isspace(*cp)) |
| 118 |
> |
while (isspace(ass[i])|(ass[i]==NOCHAR)) |
| 119 |
> |
i++; |
| 120 |
> |
if ((ass[i] == '"') | (ass[i] == '\'')) |
| 121 |
> |
quote = ass[i]; |
| 122 |
> |
} |
| 123 |
|
*++cp = ass[i]; |
| 124 |
|
} |
| 125 |
|
if (isspace(*cp)) /* remove trailing space */ |
| 265 |
|
quit(1); |
| 266 |
|
} |
| 267 |
|
|
| 268 |
+ |
void |
| 269 |
+ |
strvalue( /* check for single (quoted) string value */ |
| 270 |
+ |
VARIABLE *vp |
| 271 |
+ |
) |
| 272 |
+ |
{ |
| 273 |
+ |
if (!vp->nass) return; |
| 274 |
+ |
onevalue(vp); |
| 275 |
+ |
if ((vp->value[0] == '"') | (vp->value[0] == '\'')) { |
| 276 |
+ |
char *cp = vp->value + strlen(vp->value+1); |
| 277 |
+ |
if ((cp != vp->value) & (*cp == vp->value[0])) { |
| 278 |
+ |
vp->value++; /* elide quotation marks */ |
| 279 |
+ |
*cp = '\0'; |
| 280 |
+ |
} |
| 281 |
+ |
} |
| 282 |
+ |
} |
| 283 |
|
|
| 284 |
+ |
|
| 285 |
|
void |
| 286 |
|
intvalue( /* check integer variable for legal values */ |
| 287 |
|
VARIABLE *vp |
| 310 |
|
} |
| 311 |
|
|
| 312 |
|
|
| 313 |
+ |
int |
| 314 |
+ |
singlevar( /* assigned single value? */ |
| 315 |
+ |
VARIABLE *vp |
| 316 |
+ |
) |
| 317 |
+ |
{ |
| 318 |
+ |
if (vp->fixval == catvalues) |
| 319 |
+ |
return(0); |
| 320 |
+ |
|
| 321 |
+ |
return((vp->fixval == strvalue) | |
| 322 |
+ |
(vp->fixval == fltvalue) | |
| 323 |
+ |
(vp->fixval == intvalue) | |
| 324 |
+ |
(vp->fixval == qualvalue) | |
| 325 |
+ |
(vp->fixval == boolvalue)); |
| 326 |
+ |
} |
| 327 |
+ |
|
| 328 |
|
void |
| 329 |
|
printvars( /* print variable values */ |
| 330 |
|
FILE *fp |
| 336 |
|
for (i = 0; i < NVARS; i++) /* print each variable */ |
| 337 |
|
for (j = 0; j < vdef(i); j++) { /* print each assignment */ |
| 338 |
|
fputs(vnam(i), fp); |
| 339 |
< |
fputs("= ", fp); |
| 339 |
> |
fputc('=', fp); |
| 340 |
> |
if (!singlevar(&vv[i])) |
| 341 |
> |
fputc(' ', fp); |
| 342 |
|
k = clipline = ( vv[i].fixval == catvalues ? 64 : 236 ) |
| 343 |
|
- strlen(vnam(i)) ; |
| 344 |
|
cp = nvalue(i, j); |