searches for common compounds, ex. lump of royal jelly */
| 2780 | |
| 2781 | /* searches for common compounds, ex. lump of royal jelly */ |
| 2782 | staticfn char * |
| 2783 | singplur_compound(char *str) |
| 2784 | { |
| 2785 | /* if new entries are added, be sure to keep compound_start[] in sync */ |
| 2786 | static const char *const compounds[] = |
| 2787 | { |
| 2788 | " of ", " labeled ", " called ", |
| 2789 | " named ", " above", /* lurkers above */ |
| 2790 | " versus ", " from ", " in ", |
| 2791 | " on ", " a la ", " with", /* " with "? */ |
| 2792 | " de ", " d'", " du ", |
| 2793 | " au ", "-in-", "-at-", |
| 2794 | 0 |
| 2795 | }, /* list of first characters for all compounds[] entries */ |
| 2796 | compound_start[] = " -"; |
| 2797 | |
| 2798 | const char *const *cmpd; |
| 2799 | char *p; |
| 2800 | |
| 2801 | for (p = str; *p; ++p) { |
| 2802 | /* substring starting at p can only match if *p is found |
| 2803 | within compound_start[] */ |
| 2804 | if (!strchr(compound_start, *p)) |
| 2805 | continue; |
| 2806 | |
| 2807 | /* check current substring against all words in the compound[] list */ |
| 2808 | for (cmpd = compounds; *cmpd; ++cmpd) |
| 2809 | if (!strncmpi(p, *cmpd, (int) strlen(*cmpd))) |
| 2810 | return p; |
| 2811 | } |
| 2812 | /* wasn't recognized as a compound phrase */ |
| 2813 | return 0; |
| 2814 | } |
| 2815 | |
| 2816 | /* Plural routine; once upon a time it may have been chiefly used for |
| 2817 | * user-defined fruits, but it is now used extensively throughout the |
no test coverage detected