summaryrefslogtreecommitdiff
path: root/src/common/util.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-05-24 15:48:53 +0000
committerNick Mathewson <nickm@torproject.org>2007-05-24 15:48:53 +0000
commitfa64904306888059cefe50429ce6f1502f2a19c6 (patch)
tree214be15937a6e7dfc3c72c718a6e2f9095885407 /src/common/util.c
parent5616baa52ac7443cad1039e9ce2585165e5b2159 (diff)
downloadtor-fa64904306888059cefe50429ce6f1502f2a19c6.tar.gz
tor-fa64904306888059cefe50429ce6f1502f2a19c6.zip
r12912@catbus: nickm | 2007-05-24 11:48:49 -0400
Backport minimal parts of r10192 (fix bugs found by Benedikt) and r10248 (handle lack of nul at end of mmap). svn:r10301
Diffstat (limited to 'src/common/util.c')
-rw-r--r--src/common/util.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c
index c566bfe229..3ab72a5745 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -418,6 +418,36 @@ eat_whitespace(const char *s)
}
}
+/** Return a pointer to the first char of s before <b>eos</b> that is not
+ * whitespace and not a comment, or to the terminating NUL or eos if no such
+ * character exists.
+ */
+const char *
+eat_whitespace_eos(const char *s, const char *eos)
+{
+ tor_assert(s);
+ tor_assert(eos && s <= eos);
+
+ while (s < eos) {
+ switch (*s) {
+ case '\0':
+ default:
+ return s;
+ case ' ':
+ case '\t':
+ case '\n':
+ case '\r':
+ ++s;
+ break;
+ case '#':
+ ++s;
+ while (s < eos && *s && *s != '\n')
+ ++s;
+ }
+ }
+ return s;
+}
+
/** Return a pointer to the first char of s that is not a space or a tab,
* or to the terminating NUL if no such character exists. */
const char *