Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-07-25 22:05:24 +0300
committerJunio C Hamano <gitster@pobox.com>2023-07-25 22:05:24 +0300
commit02f50d0d1901759d9e7aec1367902cab09db63a6 (patch)
treeff5507b2c2c57f454f0fae4caf7eb8e6eca80ca4 /strbuf.c
parent261ff512e12c124f211124c2b342eb449fca6b3b (diff)
parent945c72250afcf50a0f5394151b76d5da28fa6f94 (diff)
Merge branch 'rs/strbuf-addftime-simplify'
Code clean-up. * rs/strbuf-addftime-simplify: strbuf: use skip_prefix() in strbuf_addftime()
Diffstat (limited to 'strbuf.c')
-rw-r--r--strbuf.c24
1 files changed, 6 insertions, 18 deletions
diff --git a/strbuf.c b/strbuf.c
index f65d7bee4c..4c9ac6dc5e 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -936,31 +936,19 @@ void strbuf_addftime(struct strbuf *sb, const char *fmt, const struct tm *tm,
* of seconds.
*/
while (strbuf_expand_step(&munged_fmt, &fmt)) {
- switch (*fmt) {
- case '%':
+ if (skip_prefix(fmt, "%", &fmt))
strbuf_addstr(&munged_fmt, "%%");
- fmt++;
- break;
- case 's':
+ else if (skip_prefix(fmt, "s", &fmt))
strbuf_addf(&munged_fmt, "%"PRItime,
(timestamp_t)tm_to_time_t(tm) -
3600 * (tz_offset / 100) -
60 * (tz_offset % 100));
- fmt++;
- break;
- case 'z':
+ else if (skip_prefix(fmt, "z", &fmt))
strbuf_addf(&munged_fmt, "%+05d", tz_offset);
- fmt++;
- break;
- case 'Z':
- if (suppress_tz_name) {
- fmt++;
- break;
- }
- /* FALLTHROUGH */
- default:
+ else if (suppress_tz_name && skip_prefix(fmt, "Z", &fmt))
+ ; /* nothing */
+ else
strbuf_addch(&munged_fmt, '%');
- }
}
fmt = munged_fmt.buf;