« Return to Thread: [darwinbuild-changes] [994] branches/PR-10428083/darwinup/Utils.cpp

[darwinbuild-changes] [994] branches/PR-10428083/darwinup/Utils.cpp

by source_changes :: Rate this Message:

| View in Thread

Some parts of this message have been removed. Learn more about Nabble's security policy.
[994] branches/PR-10428083/darwinup/Utils.cpp
Revision
994
Author
mww@...
Date
2012-01-20 23:07:10 -0800 (Fri, 20 Jan 2012)

Log Message

Fix has_suffix.

Modified Paths

Diff

Modified: branches/PR-10428083/darwinup/Utils.cpp (993 => 994)


--- branches/PR-10428083/darwinup/Utils.cpp	2012-01-21 07:06:49 UTC (rev 993)
+++ branches/PR-10428083/darwinup/Utils.cpp	2012-01-21 07:07:10 UTC (rev 994)
@@ -141,8 +141,11 @@
 }
 
 int has_suffix(const char* str, const char* sfx) {
-	str = strstr(str, sfx);
-	return (str && strcmp(str, sfx) == 0);
+	const char *tmp = str + (strlen(str) - strlen(sfx));
+	if (tmp > str) {
+		return (strcmp(tmp, sfx) == 0);
+	}
+	return false;
 }
 
 int exec_with_args(const char** args) {

_______________________________________________
darwinbuild-changes mailing list
darwinbuild-changes@...
http://lists.macosforge.org/mailman/listinfo.cgi/darwinbuild-changes

 « Return to Thread: [darwinbuild-changes] [994] branches/PR-10428083/darwinup/Utils.cpp