* Retrieve a list of integers from buf into a uchar array. * * NOTE: zeros are inserted unless modlist is TRUE, in which case the list * location is unchanged. Callers must handle zeros if modlist is FALSE. */
| 378 | * location is unchanged. Callers must handle zeros if modlist is FALSE. |
| 379 | */ |
| 380 | staticfn int |
| 381 | get_uchars(char *bufp, /* current pointer */ |
| 382 | uchar *list, /* return list */ |
| 383 | boolean modlist, /* TRUE: list is being modified in place */ |
| 384 | int size, /* return list size */ |
| 385 | const char *name) /* name of option for error message */ |
| 386 | { |
| 387 | unsigned int num = 0; |
| 388 | int count = 0; |
| 389 | boolean havenum = FALSE; |
| 390 | |
| 391 | while (1) { |
| 392 | switch (*bufp) { |
| 393 | case ' ': |
| 394 | case '\0': |
| 395 | case '\t': |
| 396 | case '\n': |
| 397 | if (havenum) { |
| 398 | /* if modifying in place, don't insert zeros */ |
| 399 | if (num || !modlist) |
| 400 | list[count] = num; |
| 401 | count++; |
| 402 | num = 0; |
| 403 | havenum = FALSE; |
| 404 | } |
| 405 | if (count == size || !*bufp) |
| 406 | return count; |
| 407 | bufp++; |
| 408 | break; |
| 409 | |
| 410 | case '0': |
| 411 | case '1': |
| 412 | case '2': |
| 413 | case '3': |
| 414 | case '4': |
| 415 | case '5': |
| 416 | case '6': |
| 417 | case '7': |
| 418 | case '8': |
| 419 | case '9': |
| 420 | havenum = TRUE; |
| 421 | num = num * 10 + (*bufp - '0'); |
| 422 | bufp++; |
| 423 | break; |
| 424 | |
| 425 | case '\\': |
| 426 | goto gi_error; |
| 427 | break; |
| 428 | |
| 429 | default: |
| 430 | gi_error: |
| 431 | raw_printf("Syntax error in %s", name); |
| 432 | wait_synch(); |
| 433 | return count; |
| 434 | } |
| 435 | } |
| 436 | /*NOTREACHED*/ |
| 437 | } |
no test coverage detected