MCPcopy Create free account
hub / github.com/NetHack/NetHack / get_uchars

Function get_uchars

src/cfgfiles.c:380–437  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

378 * location is unchanged. Callers must handle zeros if modlist is FALSE.
379 */
380staticfn int
381get_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}

Callers 2

cnf_line_BOULDERFunction · 0.85
cnf_line_WARNINGSFunction · 0.85

Calls 2

wait_synchFunction · 0.85
raw_printfFunction · 0.70

Tested by

no test coverage detected