name: don't restrict compare return value to {-1,0,1}

refs #2445

Change-Id: I58d75f397a70564f46a12f7f45d533057e9d1f76
diff --git a/src/name-component.hpp b/src/name-component.hpp
index 0ed3759..c811c9b 100644
--- a/src/name-component.hpp
+++ b/src/name-component.hpp
@@ -523,8 +523,9 @@
    * @brief Compare this to the other Component using NDN canonical ordering
    *
    * @param other The other Component to compare with.
-   * @return 0 If they compare equal, -1 if *this comes before other in the canonical ordering, or
-   *         1 if *this comes after other in the canonical ordering.
+   * @retval negative this comes before other in canonical ordering
+   * @retval zero this equals other
+   * @retval positive this comes after other in canonical ordering
    *
    * @see http://named-data.net/doc/ndn-tlv/name.html#canonical-order
    */
diff --git a/src/name.cpp b/src/name.cpp
index b180ba6..c5adb7d 100644
--- a/src/name.cpp
+++ b/src/name.cpp
@@ -342,7 +342,7 @@
     }
   }
   // [pos1, pos1+count) of this Name equals [pos2, pos2+count) of other Name
-  return (count1 > count2) - (count1 < count2); // signum(count1 - count2)
+  return count1 - count2;
 }
 
 std::ostream&
diff --git a/src/name.hpp b/src/name.hpp
index cf8318f..719cf7f2 100644
--- a/src/name.hpp
+++ b/src/name.hpp
@@ -435,19 +435,22 @@
   /**
    * @brief Compare this to the other Name using NDN canonical ordering.
    *
-   * If the first components of each name are not equal, this returns -1 if the first comes
-   * before the second using the NDN canonical ordering for name components, or 1 if it
-   * comes after.  If they are equal, this compares the second components of each name, etc.
-   * If both names are the same up to the size of the shorter name, this returns -1 if the
-   * first name is shorter than the second or 1 if it is longer.  For example, if you
-   * std::sort gives: /a/b/d /a/b/cc /c /c/a /bb .  This is intuitive because all names with
-   * the prefix /a are next to each other.  But it may be also be counter-intuitive because
-   * /c comes before /bb according to NDN canonical ordering since it is shorter.  @param
-   * other The other Name to compare with.
+   * If the first components of each name are not equal, this returns a negative value if
+   * the first comes before the second using the NDN canonical ordering for name
+   * components, or a positive value if it comes after.  If they are equal, this compares
+   * the second components of each name, etc. If both names are the same up to the size
+   * of the shorter name, this returns a negative value if the first name is shorter than
+   * the second or a positive value if it is longer.  For example, if you std::sort gives:
+   * /a/b/d /a/b/cc /c /c/a /bb .
+   * This is intuitive because all names with the prefix /a are next to each other.
+   * But it may be also be counter-intuitive because /c comes before /bb according
+   * to NDN canonical ordering since it is shorter.
    *
-   * @retval 0 if they compare equal
-   * @retval -1 if *this comes before other in the canonical ordering
-   * @retval 1 if *this comes after other in the canonical ordering
+   * @param other The other Name to compare with.
+   *
+   * @retval negative this comes before other in canonical ordering
+   * @retval zero this equals other
+   * @retval positive this comes after other in canonical ordering
    *
    * @see http://named-data.net/doc/ndn-tlv/name.html#canonical-order
    */