| Line | |
|---|
| 1 | /*
|
|---|
| 2 | * strchr --- search a string for a character
|
|---|
| 3 | *
|
|---|
| 4 | * We supply this routine for those systems that aren't standard yet.
|
|---|
| 5 | */
|
|---|
| 6 |
|
|---|
| 7 | #if 0
|
|---|
| 8 | #include <stdio.h>
|
|---|
| 9 | #endif
|
|---|
| 10 |
|
|---|
| 11 | char *
|
|---|
| 12 | strchr(str, c)
|
|---|
| 13 | register const char *str, c;
|
|---|
| 14 | {
|
|---|
| 15 | if (c == '\0') {
|
|---|
| 16 | /* thanks to Mike Brennan ... */
|
|---|
| 17 | do {
|
|---|
| 18 | if (*str == c)
|
|---|
| 19 | return (char *) str;
|
|---|
| 20 | } while (*str++);
|
|---|
| 21 | } else {
|
|---|
| 22 | for (; *str; str++)
|
|---|
| 23 | if (*str == c)
|
|---|
| 24 | return (char *) str;
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | return NULL;
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | /*
|
|---|
| 31 | * strrchr --- find the last occurrence of a character in a string
|
|---|
| 32 | *
|
|---|
| 33 | * We supply this routine for those systems that aren't standard yet.
|
|---|
| 34 | */
|
|---|
| 35 |
|
|---|
| 36 | char *
|
|---|
| 37 | strrchr(str, c)
|
|---|
| 38 | register const char *str, c;
|
|---|
| 39 | {
|
|---|
| 40 | register const char *save = NULL;
|
|---|
| 41 |
|
|---|
| 42 | for (; *str; str++)
|
|---|
| 43 | if (*str == c)
|
|---|
| 44 | save = str;
|
|---|
| 45 |
|
|---|
| 46 | return (char *) save;
|
|---|
| 47 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.