returns 0 on error */
| 435 | |
| 436 | /* returns 0 on error */ |
| 437 | int |
| 438 | parse_sym_line(char *buf, int which_set) |
| 439 | { |
| 440 | int val, i; |
| 441 | const struct symparse *symp = (struct symparse *) 0; |
| 442 | char *bufp, *commentp, *altp; |
| 443 | int glyph = NO_GLYPH; |
| 444 | boolean enhanced_unavailable = FALSE, is_glyph = FALSE; |
| 445 | |
| 446 | if (strlen(buf) >= BUFSZ) |
| 447 | buf[BUFSZ - 1] = '\0'; |
| 448 | /* convert each instance of whitespace (tabs, consecutive spaces) |
| 449 | into a single space; leading and trailing spaces are stripped */ |
| 450 | mungspaces(buf); |
| 451 | |
| 452 | /* remove trailing comment, if any (this isn't strictly needed for |
| 453 | individual symbols, and it won't matter if "X#comment" without |
| 454 | separating space slips through; for handling or set description, |
| 455 | symbol set creator is responsible for preceding '#' with a space |
| 456 | and that comment itself doesn't contain " #") */ |
| 457 | if ((commentp = strrchr(buf, '#')) != 0 && commentp[-1] == ' ') |
| 458 | commentp[-1] = '\0'; |
| 459 | |
| 460 | /* find the '=' or ':' */ |
| 461 | bufp = strchr(buf, '='); |
| 462 | altp = strchr(buf, ':'); |
| 463 | |
| 464 | if (!bufp || (altp && altp < bufp)) |
| 465 | bufp = altp; |
| 466 | |
| 467 | if (!bufp) { |
| 468 | if (strncmpi(buf, "finish", 6) == 0) { |
| 469 | /* end current graphics set */ |
| 470 | if (gc.chosen_symset_start) |
| 471 | gc.chosen_symset_end = TRUE; |
| 472 | gc.chosen_symset_start = FALSE; |
| 473 | return 1; |
| 474 | } |
| 475 | config_error_add("No \"finish\""); |
| 476 | return 0; |
| 477 | } |
| 478 | /* skip '=' and space which follows, if any */ |
| 479 | ++bufp; |
| 480 | if (*bufp == ' ') |
| 481 | ++bufp; |
| 482 | |
| 483 | symp = match_sym(buf); |
| 484 | if (!symp && buf[0] == 'G' && buf[1] == '_') { |
| 485 | if (gc.chosen_symset_start) { |
| 486 | is_glyph = match_glyph(buf); |
| 487 | } else { |
| 488 | is_glyph = TRUE; /* report error only once */ |
| 489 | } |
| 490 | #ifdef ENHANCED_SYMBOLS |
| 491 | enhanced_unavailable = FALSE; |
| 492 | #else |
| 493 | enhanced_unavailable = TRUE; |
| 494 | #endif |
no test coverage detected