From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: Miklos Vajna <vmiklos@frugalware.org>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH] Strbuf documentation: document most functions
Date: Tue, 03 Jun 2008 17:41:38 +0200 [thread overview]
Message-ID: <48456632.9040103@lsrfire.ath.cx> (raw)
In-Reply-To: <1212447591-4870-1-git-send-email-vmiklos@frugalware.org>
Miklos Vajna schrieb:
> Actually this is a bit of request for help, I haven't figured out what
> strbuf_expand() does [...]
It can be used to expand a format string containing placeholders. To
that end, it parses the string and calls the specified function for
every percent sign found.
The callback function is given a pointer to the character after the '%'
and a pointer to the struct strbuf. It is expected to add the expanded
version of the placeholder to the strbuf, e.g. to add a newline
character if the letter 'n' appears after a '%'. The function returns
the length of the placeholder recognized and strbuf_expand skips over it.
All other characters (non-percent and not skipped ones) are copied
verbatim to the strbuf. If the callback returned zero, meaning that the
placeholder is unknown, then the percent sign is copied, too.
In order to facilitate caching and to make it possible to give
parameters to the callback, strbuf_expand passes a context pointer,
which can be used by the programmer of the callback as she sees fit.
You can see it in action in pretty.c, where it expands --pretty=format:
placeholder strings. The callback may be a bit heavy for a first
encounter, though. ;-)
René
next prev parent reply other threads:[~2008-06-03 15:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-02 22:59 [PATCH] Strbuf documentation: document most functions Miklos Vajna
2008-06-02 23:39 ` Junio C Hamano
2008-06-03 0:00 ` Johannes Schindelin
2008-06-03 8:42 ` Pierre Habouzit
2008-06-03 15:41 ` René Scharfe [this message]
2008-06-04 1:15 ` Miklos Vajna
2008-06-04 7:45 ` Junio C Hamano
2008-06-04 21:20 ` Miklos Vajna
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=48456632.9040103@lsrfire.ath.cx \
--to=rene.scharfe@lsrfire.ath.cx \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=vmiklos@frugalware.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.