1 #include "builtin.ih" 2 eb_findPercent(char * ptr)3char *eb_findPercent(char *ptr) 4 { 5 while (1) /* search the string */ 6 { 7 ptr += strcspn(ptr, "\\%"); /* ptr -> \, % or \0 */ 8 9 switch (*ptr) 10 { 11 case 0: /* at end of string */ 12 return ptr; 13 14 case '\\': /* at a backslash */ 15 if (*++ptr) /* skip the next char */ 16 ++ptr; 17 break; 18 19 default: /* at % */ 20 if (isdigit(ptr[1])) /* if at %<nr> */ 21 return ptr; /* return ptr -> % */ 22 ++ptr; /* or skip % and continue */ 23 break; 24 } 25 } 26 } 27