From dfe9b38635d80cb5253187c1ddf90923e1b9effd Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Fri, 7 Oct 2016 13:32:12 -0400
Subject: [PATCH] SystemTools: Re-implement Strucmp

The current implementation was added by commit 5c8693bc (remove
redundant function and eliminate need for strcasecmp, 2003-04-11).  The
code was taken from Graphviz in 2003 from a source file that at the time
was distributed under terms of the Common Public License, Version 1.0.
While the actual content is simple and likely not copyrightable, clarify
the licensing status by simply re-implementing the function from scratch
using another approach.

Change-Id: I44f72b215577af9e3de234b5ef03113c580a3bd6
---
 SystemTools.cxx | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/SystemTools.cxx b/SystemTools.cxx
index c97af25..5da715f 100644
--- a/SystemTools.cxx
+++ b/SystemTools.cxx
@@ -2716,17 +2716,15 @@ unsigned long SystemTools::FileLength(const std::string& filename)
   return length;
 }
 
-int SystemTools::Strucmp(const char *s1, const char *s2)
-{
-  // lifted from Graphvis http://www.graphviz.org
-  while ((*s1 != '\0')
-         && (tolower(*s1) == tolower(*s2)))
-    {
-      s1++;
-      s2++;
-    }
-
-  return tolower(*s1) - tolower(*s2);
+int SystemTools::Strucmp(const char* l, const char* r)
+{
+  int lc;
+  int rc;
+  do {
+    lc = tolower(*l++);
+    rc = tolower(*r++);
+  } while(lc == rc && lc);
+  return lc - rc;
 }
 
 // return file's modified time
-- 
GitLab