strlen() but returns unsigned and panics if string is unreasonably long; used by dlb as well as by nethack */
| 79 | /* strlen() but returns unsigned and panics if string is unreasonably long; |
| 80 | used by dlb as well as by nethack */ |
| 81 | unsigned |
| 82 | Strlen_( |
| 83 | const char *str, |
| 84 | const char *file, |
| 85 | int line) |
| 86 | { |
| 87 | const char *p; |
| 88 | size_t len; |
| 89 | |
| 90 | /* strnlen(str, LARGEST_INT) w/o requiring posix.1 headers or libraries */ |
| 91 | for (p = str, len = 0; len < LARGEST_INT; ++len) |
| 92 | if (*p++ == '\0') |
| 93 | break; |
| 94 | |
| 95 | if (len == LARGEST_INT) |
| 96 | panic("%s:%d string too long", file, line); |
| 97 | return (unsigned) len; |
| 98 | } |
| 99 | |
| 100 | staticfn boolean pmatch_internal(const char *, const char *, boolean, |
| 101 | const char *); |