trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject [trafficserver] branch master updated: MemView: Fix strlen issue for OmniOS.
Date Sat, 25 Feb 2017 21:24:16 GMT
This is an automated email from the ASF dual-hosted git repository.

amc pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

The following commit(s) were added to refs/heads/master by this push:
       new  52037d9   MemView: Fix strlen issue for OmniOS.
52037d9 is described below

commit 52037d977d91c2dd3a13236eea930fd585b9f4ad
Author: Alan M. Carroll <amc@apache.org>
AuthorDate: Fri Feb 24 19:30:25 2017 -0600

    MemView: Fix strlen issue for OmniOS.
---
 lib/ts/MemView.cc |  9 ++++++++-
 lib/ts/MemView.h  | 27 ++++++++++++++++++++++++---
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/lib/ts/MemView.cc b/lib/ts/MemView.cc
index f0f3eb9..bf0c1c9 100644
--- a/lib/ts/MemView.cc
+++ b/lib/ts/MemView.cc
@@ -26,9 +26,14 @@
 #include <ts/MemView.h>
 #include <sstream>
 #include <ctype.h>
+#include <ts/ink_platform.h>
 
 namespace ts
 {
+StringView::StringView(const char *s) : _ptr(s), _size(strlen(s))
+{
+}
+
 int
 memcmp(MemView const &lhs, MemView const &rhs)
 {
@@ -69,7 +74,9 @@ intmax_t
 svtoi(StringView src, StringView *out, int base)
 {
   static const int8_t convert[256] = {
-    //   0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
+    /* [can't do this nicely because clang format won't allow exdented comments]
+     0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
+    */
     -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 00
     -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 10
     -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 20
diff --git a/lib/ts/MemView.h b/lib/ts/MemView.h
index 39136f3..42388bc 100644
--- a/lib/ts/MemView.h
+++ b/lib/ts/MemView.h
@@ -40,8 +40,32 @@ namespace ts
 class MemView;
 class StringView;
 
+/// Compare the memory in two views.
+/// Return based on the first different byte. If one argument is a prefix of the other, the
prefix
+/// is considered the "smaller" value.
+/// @return
+/// - -1 if @a lhs byte is less than @a rhs byte.
+/// -  1 if @a lhs byte is greater than @a rhs byte.
+/// -  0 if the views contain identical memory.
 int memcmp(MemView const &lhs, MemView const &rhs);
+/// Compare the strings in two views.
+/// Return based on the first different character. If one argument is a prefix of the other,
the prefix
+/// is considered the "smaller" value.
+/// @return
+/// - -1 if @a lhs char is less than @a rhs char.
+/// -  1 if @a lhs char is greater than @a rhs char.
+/// -  0 if the views contain identical strings.
 int strcmp(StringView const &lhs, StringView const &rhs);
+/// Compare the strings in two views.
+/// Return based on the first different character. If one argument is a prefix of the other,
the prefix
+/// is considered the "smaller" value. The values are compared ignoring case.
+/// @return
+/// - -1 if @a lhs char is less than @a rhs char.
+/// -  1 if @a lhs char is greater than @a rhs char.
+/// -  0 if the views contain identical strings.
+///
+/// @internal Why not <const&>? Because the implementation would make copies anyway,
might as well save
+/// the cost of passing the pointers.
 int strcasecmp(StringView lhs, StringView rhs);
 
 /** Convert the text in @c StringView @a src to a numeric value.
@@ -837,9 +861,6 @@ inline constexpr StringView::StringView(const char *ptr, size_t n) : _ptr(ptr),
 inline constexpr StringView::StringView(const char *start, const char *end) : _ptr(start),
_size(end - start)
 {
 }
-inline StringView::StringView(const char *s) : _ptr(s), _size(strlen(s))
-{
-}
 inline constexpr StringView::StringView(std::nullptr_t) : _ptr(nullptr), _size(0)
 {
 }

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>'].

Mime
View raw message