5 /* returns the start of the next token */
6 char *readtoken(char *to
, char *from
, char *delims
)
8 for (; *from
!= '\0' && !strchr(delims
, *from
);)
11 for (; *from
!= '\0' && strchr(delims
, *from
);)
16 /* returns the start of the next word */
17 char *readword(char *to
, char *from
)
19 for (; *from
!= '\0' && isalnum(*from
);)
22 for (; *from
!= '\0' && !isalnum(*from
);)
27 char *nthtoken(char *to
, char *from
, char* delims
, int n
)
30 for (i
= 0; i
< n
; i
++)
31 from
= readtoken(to
, from
, delims
);
35 int startswith(char *heystack
, char *needle
)
37 while (*needle
!= '\0' && *needle
== *heystack
++)
42 int endswith(char *heystack
, char *needle
)
44 char *p
= heystack
+ strlen(heystack
);
45 char *q
= needle
+ strlen(needle
);
46 while (q
!= needle
&& p
!= heystack
&& *--p
== *--q
)
48 return *p
== *q
&& q
== needle
;