similar to heKey2Entry, except that key is taken as regexp (see above) and number of matches is returned if number of matches > 0, then hentry contains entry for first match if number of matches > 1, matches are printed as komma-separated into global string
| 566 | // if number of matches > 1, matches are printed as komma-separated |
| 567 | // into global string |
| 568 | static int heReKey2Entry (char* filename, char* key, heEntry hentry) |
| 569 | { |
| 570 | int i = 0; |
| 571 | FILE* fd; |
| 572 | char index_key[MAX_HE_ENTRY_LENGTH]; |
| 573 | |
| 574 | if (filename == NULL || key == NULL) return 0; |
| 575 | fd = fopen(filename, "r"); |
| 576 | if (fd == NULL) return 0; |
| 577 | memset(index_key,0,MAX_HE_ENTRY_LENGTH); |
| 578 | while (si_fscanf(fd, "%[^\t]\t%*[^\n]\n", index_key) == 1) |
| 579 | { |
| 580 | if ((index_key[MAX_HE_ENTRY_LENGTH-1]!='\0')) |
| 581 | { |
| 582 | index_key[MAX_HE_ENTRY_LENGTH-1]='\0'; |
| 583 | Werror("index file corrupt at line >>%s<<",index_key); |
| 584 | break; |
| 585 | } |
| 586 | else if (strmatch(index_key, key)) |
| 587 | { |
| 588 | i++; |
| 589 | if (i == 1) |
| 590 | { |
| 591 | heKey2Entry(filename, index_key, hentry); |
| 592 | } |
| 593 | else if (i == 2) |
| 594 | { |
| 595 | StringAppend("?%s; ?%s;", hentry->key, index_key); |
| 596 | } |
| 597 | else |
| 598 | { |
| 599 | StringAppend(" ?%s;", index_key); |
| 600 | } |
| 601 | } |
| 602 | } |
| 603 | fclose(fd); |
| 604 | return i; |
| 605 | } |
| 606 | |
| 607 | // test for h being a string and print it |
| 608 | static void hePrintHelpStr(const idhdl hh,const char *id,const char *pa) |
no test coverage detected