[112607] trunk/base/src/darwintracelib1.0/darwintrace.c
cal at macports.org
cal at macports.org
Sun Oct 27 16:58:09 PDT 2013
Revision: 112607
https://trac.macports.org/changeset/112607
Author: cal at macports.org
Date: 2013-10-27 16:58:09 -0700 (Sun, 27 Oct 2013)
Log Message:
-----------
darwintrace: use bools instead of int return values, avoid call to strcmp
Modified Paths:
--------------
trunk/base/src/darwintracelib1.0/darwintrace.c
Modified: trunk/base/src/darwintracelib1.0/darwintrace.c
===================================================================
--- trunk/base/src/darwintracelib1.0/darwintrace.c 2013-10-27 22:36:08 UTC (rev 112606)
+++ trunk/base/src/darwintracelib1.0/darwintrace.c 2013-10-27 23:58:09 UTC (rev 112607)
@@ -111,8 +111,6 @@
#define DARWINTRACE_DEBUG (0)
#endif
-static inline int __darwintrace_strbeginswith(const char *str, const char *prefix);
-static inline int __darwintrace_pathbeginswith(const char *str, const char *prefix);
static inline void __darwintrace_log_op(const char *op, const char *path, int fd);
static void __darwintrace_copy_env() __attribute__((constructor));
static void __darwintrace_setup_tls() __attribute__((constructor));
@@ -254,16 +252,16 @@
}
/**
- * Return 0 if str doesn't begin with prefix, 1 otherwise. Note that this is
- * not a simple string comparison, but works on a path component level.
+ * Return false if str doesn't begin with prefix, true otherwise. Note that
+ * this is not a simple string comparison, but works on a path component level.
* A prefix of /var/tmp will not match a string of /var/tmpfoo.
*/
-static inline int __darwintrace_pathbeginswith(const char *str, const char *prefix) {
+static inline bool __darwintrace_pathbeginswith(const char *str, const char *prefix) {
char s;
char p;
/* '/' is the allow all wildcard */
- if (strcmp(str, "/") == 0) {
+ if (str[0] == '\0' || (str[0] == '/' && str[1] == '\0')) {
return 1;
}
@@ -271,20 +269,20 @@
s = *str++;
p = *prefix++;
} while (p && (p == s));
- return (p == 0 && (s == '/' || s == '\0'));
+ return (p == '\0' && (s == '/' || s == '\0'));
}
/**
- * Return 0 if str doesn't begin with prefix, 1 otherwise.
+ * Return false if str doesn't begin with prefix, true otherwise.
*/
-static inline int __darwintrace_strbeginswith(const char *str, const char *prefix) {
+static inline bool __darwintrace_strbeginswith(const char *str, const char *prefix) {
char s;
char p;
do {
s = *str++;
p = *prefix++;
} while (p && (p == s));
- return (p == 0);
+ return (p == '\0');
}
/*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20131027/f0a20fa1/attachment.html>
More information about the macports-changes
mailing list