/* Tests for fnmatch function. Copyright (C) 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see . */ #include #include #include #include #include #include #include #include #include static char *next_input (char **line, int first, int last); static int convert_flags (const char *str); static char *flag_output (int flags); static char *escape (const char *str, size_t *reslenp, char **resbuf); int str_isalpha(const char *str) { size_t i = strlen(str); while (i--) if (isascii(str[i]) == 0) return 0; return 1; } int str_has_funk(const char *str, const char x) { size_t i, max = strlen(str); for (i=0; i+1 reslen) { resbuf = (char *) realloc (resbuf, 2 * len + 1); if (resbuf == NULL) error (EXIT_FAILURE, errno, "while allocating buffer for printing"); *reslenp = 2 * len + 1; *resbufp = resbuf; } wp = resbuf; while (*str != '\0') if (*str == '\t') { *wp++ = '\\'; *wp++ = 't'; ++str; } else if (*str == '\n') { *wp++ = '\\'; *wp++ = 'n'; ++str; } else if (*str == '"') { *wp++ = '\\'; *wp++ = '"'; ++str; } else if (*str == '\\') { *wp++ = '\\'; *wp++ = '\\'; ++str; } else *wp++ = *str++; *wp = '\0'; return resbuf; }