summaryrefslogtreecommitdiff
path: root/util-internal.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-11-16 11:13:29 -0500
committerNick Mathewson <nickm@torproject.org>2012-11-16 11:13:29 -0500
commitaa59d805f518d14305310db1096b8eb1904cdec3 (patch)
treed9468ff5cd8a445cacc8a5f669c0614c2775daea /util-internal.h
parent370a2c02133c11d4eaab4aa552e49e9ed8b24658 (diff)
downloadlibevent-aa59d805f518d14305310db1096b8eb1904cdec3.tar.gz
Clean up rtrim implementation
If I understand the C standard correctly, you can't actually point at a position immediately _before_ the start of an object; only at the position immediately after. According to J.2 in the standard, in its big list of undefined behavior: "The behavior is undefined in the following circumstances: ... — Addition or subtraction of a pointer into, or just beyond, an array object and an integer type produces a result that does not point into, or just beyond, the same array object (6.5.6)." So we've got to fix rtrim to not do that. Also, make it unit tested, and give it an evutil_*_ name.
Diffstat (limited to 'util-internal.h')
-rw-r--r--util-internal.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/util-internal.h b/util-internal.h
index da1fb838..dff3d70b 100644
--- a/util-internal.h
+++ b/util-internal.h
@@ -218,6 +218,10 @@ int EVUTIL_ISUPPER_(char c);
char EVUTIL_TOUPPER_(char c);
char EVUTIL_TOLOWER_(char c);
+/** Remove all trailing whitespace from the end of a string */
+void evutil_rtrim_(char *);
+
+
/** Helper macro. If we know that a given pointer points to a field in a
structure, return a pointer to the structure itself. Used to implement
our half-baked C OO. Example: