/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1985-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* David Korn <[email protected]> *18* Phong Vo <[email protected]> *19* *20***********************************************************************/21#pragma prototyped22/*23* Glenn Fowler24* AT&T Bell Laboratories25*26* time conversion support27*/2829#include <ast.h>30#include <tm.h>31#include <ctype.h>3233/*34* match s against t ignoring case and .'s35*36* suf is an n element table of suffixes that may trail s37* if all isalpha() chars in s match then 1 is returned38* and if e is non-null it will point to the first unmatched39* char in s, otherwise 0 is returned40*/4142int43tmword(register const char* s, char** e, register const char* t, char** suf, int n)44{45register int c;46const char* b;4748if (*s && *t)49{50b = s;51while (c = *s++)52{53if (c != '.')54{55if (!isalpha(c) || c != *t && (islower(c) ? toupper(c) : tolower(c)) != *t)56break;57t++;58}59}60s--;61if (!isalpha(c))62{63if (c == '_')64s++;65if (e)66*e = (char*)s;67return s > b;68}69if (!*t && s > (b + 1))70{71b = s;72while (n-- && (t = *suf++))73{74s = b;75while (isalpha(c = *s++) && (c == *t || (islower(c) ? toupper(c) : tolower(c)) == *t)) t++;76if (!*t && !isalpha(c))77{78if (c != '_')79s--;80if (e)81*e = (char*)s;82return 1;83}84}85}86}87return 0;88}899091