-const char miscutil_rcs[] = "$Id: miscutil.c,v 2.2 2002/08/26 11:16:33 sarantis Exp $";
+const char miscutil_rcs[] = "$Id: miscutil.c,v 2.3 2002/09/25 13:00:41 oes Exp $";
/*********************************************************************
*
- * File : $Source: /cvsroot/ijbswa/current/src/miscutil.c,v $
+ * File : $Source: /cvsroot/ijbswa//current/src/miscutil.c,v $
*
* Purpose : zalloc, hash_string, safe_strerror, strcmpic,
* strncmpic, chomp, and MinGW32 strdup
*
* Revisions :
* $Log: miscutil.c,v $
+ * Revision 2.3 2002/09/25 13:00:41 oes
+ * Made strcmpic and strncmpic safe against NULL arguments
+ * (which are now treated as empty strings).
+ *
* Revision 2.2 2002/08/26 11:16:33 sarantis
* Fix typo.
*
if ((*pat == *txt)
|| ((*pat == ']') && (charmap[*txt / 8] & (1 << (*txt % 8)))) )
{
- /* Sucess, go ahead */
+ /*
+ * Sucess: Go ahead
+ */
pat++;
}
- else
+ else if (!wildcard)
{
- /* In wildcard mode, just try again after failure */
- if(wildcard)
- {
- pat = fallback;
- }
-
- /* Else, bad luck */
- else
- {
- return 1;
- }
+ /*
+ * No match && no wildcard: No luck
+ */
+ return 1;
+ }
+ else if (pat != fallback)
+ {
+ /*
+ * Wildcard mode && nonmatch beyond fallback: Rewind pattern
+ */
+ pat = fallback;
+ continue;
}
txt++;
- }
+ }
/* Cut off extra '*'s */
if(*pat == '*') pat++;