| 866 | ****************************************************************************/ |
| 867 | |
| 868 | static char *get_token(void) |
| 869 | { |
| 870 | char *pbegin; |
| 871 | char *pend = NULL; |
| 872 | |
| 873 | /* The position to begin/resume parsing is in g_lnptr. */ |
| 874 | |
| 875 | if (g_lnptr && *g_lnptr) |
| 876 | { |
| 877 | pbegin = g_lnptr; |
| 878 | } |
| 879 | else |
| 880 | { |
| 881 | return NULL; |
| 882 | } |
| 883 | |
| 884 | /* Find the beginning of the next token */ |
| 885 | |
| 886 | for (; |
| 887 | *pbegin && strchr(g_delimiters, *pbegin) != NULL; |
| 888 | pbegin++); |
| 889 | |
| 890 | /* If we are at the end of the string with nothing |
| 891 | * but delimiters found, then return NULL. |
| 892 | */ |
| 893 | |
| 894 | if (!*pbegin) |
| 895 | { |
| 896 | g_lnptr = pbegin; |
| 897 | return NULL; |
| 898 | } |
| 899 | |
| 900 | /* Get if the token is a quoted string */ |
| 901 | |
| 902 | if (*pbegin == '"') |
| 903 | { |
| 904 | /* Search for the trailing quotation mark */ |
| 905 | |
| 906 | pend = findchar(pbegin + 1, '"'); |
| 907 | |
| 908 | /* Did we find the trailing quotation mark */ |
| 909 | |
| 910 | if (pend) |
| 911 | { |
| 912 | /* Yes.. skip over it */ |
| 913 | |
| 914 | pend++; |
| 915 | } |
| 916 | } |
| 917 | else |
| 918 | { |
| 919 | /* Find the end of the token */ |
| 920 | |
| 921 | for (pend = pbegin + 1; |
| 922 | *pend && strchr(g_delimiters, *pend) == NULL; |
| 923 | pend++); |
| 924 | } |
| 925 |
no test coverage detected