gcc/testsuite/gcc.c-torture/execute/builtins/lib/strrchr.c
raw| 1 | extern void abort (void); |
| 2 | extern int inside_main; |
| 3 | |
| 4 | __attribute__ ((__noinline__)) |
| 5 | char * |
| 6 | strrchr (const char *s, int c) |
| 7 | { |
| 8 | __SIZE_TYPE__ i; |
| 9 | |
| 10 | #ifdef __OPTIMIZE__ |
| 11 | if (inside_main) |
| 12 | abort (); |
| 13 | #endif |
| 14 | |
| 15 | i = 0; |
| 16 | while (s[i] != 0) |
| 17 | i++; |
| 18 | |
| 19 | do |
| 20 | if (s[i] == c) |
| 21 | return (char *) s + i; |
| 22 | while (i-- != 0); |
| 23 | |
| 24 | return 0; |
| 25 | } |
| 26 | |
| 27 | __attribute__ ((__noinline__)) |
| 28 | char * |
| 29 | rindex (const char *s, int c) |
| 30 | { |
| 31 | return strrchr (s, c); |
| 32 | } |