From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: Michael Haggerty <mhagger@alum.mit.edu>,
Jonathan Nieder <jrnieder@gmail.com>,
Stefan Beller <sbeller@google.com>,
Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 6/7] strbuf.h: drop boilerplate descriptions of strbuf_split_*
Date: Fri, 16 Jan 2015 04:05:57 -0500 [thread overview]
Message-ID: <20150116090556.GF31113@peff.net> (raw)
In-Reply-To: <20150116090225.GA30797@peff.net>
The description of strbuf_split_buf says most of what
needs to be said for all of the split variants that take
strings, raw memory, etc. We have a boilerplate comment
above each that points to the first. This boilerplate
ends up making it harder to read, because it spaces out the
functions, which could otherwise be read as a group.
Let's drop the boilerplate completely, and mention the
variants in the top comment. This is perhaps slightly worse
for a hypothetical system which pulls the documentation for
each function out of the comment immediately preceding it.
But such a system does not yet exist, and anyway, the end
result of extracting the boilerplate comments would not lead
to a very easy-to-read result. We would do better in the
long run to teach the extraction system about groups of
related functions.
Signed-off-by: Jeff King <peff@peff.net>
---
strbuf.h | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/strbuf.h b/strbuf.h
index 6fa7156..61c9c73 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -441,36 +441,29 @@ static inline int strbuf_strip_suffix(struct strbuf *sb, const char *suffix)
* substring containing everything following the (max-1)th terminator
* character).
*
+ * The most generic form is `strbuf_split_buf`, which takes an arbitrary
+ * pointer/len buffer. The `_str` variant takes a NUL-terminated string,
+ * the `_max` variant takes a strbuf, and just `strbuf_split` is a convenience
+ * wrapper to drop the `max` parameter.
+ *
* For lighter-weight alternatives, see string_list_split() and
* string_list_split_in_place().
*/
extern struct strbuf **strbuf_split_buf(const char *, size_t,
int terminator, int max);
-/**
- * Split a NUL-terminated string at the specified terminator
- * character. See strbuf_split_buf() for more information.
- */
static inline struct strbuf **strbuf_split_str(const char *str,
int terminator, int max)
{
return strbuf_split_buf(str, strlen(str), terminator, max);
}
-/**
- * Split a strbuf at the specified terminator character. See
- * strbuf_split_buf() for more information.
- */
static inline struct strbuf **strbuf_split_max(const struct strbuf *sb,
int terminator, int max)
{
return strbuf_split_buf(sb->buf, sb->len, terminator, max);
}
-/**
- * Split a strbuf at the specified terminator character. See
- * strbuf_split_buf() for more information.
- */
static inline struct strbuf **strbuf_split(const struct strbuf *sb,
int terminator)
{
--
2.2.1.425.g441bb3c
next prev parent reply other threads:[~2015-01-16 9:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-16 9:02 [PATCH 0/7] migrate api-strbuf.txt into strbuf.h Jeff King
2015-01-16 9:04 ` [PATCH 1/7] strbuf.h: integrate api-strbuf.txt documentation Jeff King
2015-01-16 9:04 ` [PATCH 2/7] strbuf.h: unify documentation comments beginnings Jeff King
2015-01-16 9:05 ` [PATCH 3/7] strbuf.h: drop asciidoc list formatting from API docs Jeff King
2015-01-16 9:05 ` [PATCH 4/7] strbuf.h: format asciidoc code blocks as 4-space indent Jeff King
2015-01-16 9:05 ` [PATCH 5/7] strbuf.h: reorganize api function grouping headers Jeff King
2015-01-16 9:05 ` Jeff King [this message]
2015-01-16 9:06 ` [PATCH 7/7] strbuf.h: group documentation for trim functions Jeff King
2015-02-12 23:01 ` [PATCH 0/7] migrate api-strbuf.txt into strbuf.h Junio C Hamano
2015-02-12 23:05 ` Jeff King
2015-02-16 22:41 ` Junio C Hamano
2015-02-17 23:00 ` Jonathan Nieder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150116090556.GF31113@peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=mhagger@alum.mit.edu \
--cc=sbeller@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).