Changeset 2548 for trunk/src/kmk/misc.c
- Timestamp:
- Nov 8, 2011, 10:28:16 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/misc.c
r2101 r2548 727 727 #endif 728 728 } 729 #ifdef KMK 730 731 /* Same as find_next_token with two exception: 732 - The string ends at EOS or '\0'. 733 - We keep track of $() and ${}, allowing functions to be used. */ 734 735 char * 736 find_next_token_eos (const char **ptr, const char *eos, unsigned int *lengthptr) 737 { 738 const char *p = *ptr; 739 const char *e; 740 int level = 0; 741 742 /* skip blanks */ 743 for (; p != eos; p++) 744 { 745 unsigned char ch = *p; 746 if (!MY_IS_BLANK(ch)) 747 { 748 if (!ch) 749 return NULL; 750 break; 751 } 752 } 753 if (p == eos) 754 return NULL; 755 756 /* skip ahead until EOS or blanks. */ 757 for (e = p; e != eos; e++) 758 { 759 unsigned char ch = *e; 760 if (MY_IS_BLANK_OR_EOS(ch)) 761 { 762 if (!ch || level == 0) 763 break; 764 } 765 else if (ch == '$') 766 { 767 if (&e[1] != eos && (e[1] == '(' || e[1] == '{')) 768 { 769 level++; 770 e++; 771 } 772 } 773 else if ((ch == ')' || ch == '}') && level > 0) 774 level--; 775 } 776 777 *ptr = e; 778 if (lengthptr != 0) 779 *lengthptr = e - p; 780 781 return (char *)p; 782 } 783 784 #endif /* KMK */ 729 785 730 786
Note:
See TracChangeset
for help on using the changeset viewer.