diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-10-28 09:44:20 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-10-28 09:44:20 +0100 |
commit | fbfef469018f47e9f6710a727c5db002539e52f0 (patch) | |
tree | 5c021bd2d97bd43adb91e9f4362d791767f759a9 /src | |
parent | parse filename pattern (diff) | |
download | scrotty-fbfef469018f47e9f6710a727c5db002539e52f0.tar.gz scrotty-fbfef469018f47e9f6710a727c5db002539e52f0.tar.bz2 scrotty-fbfef469018f47e9f6710a727c5db002539e52f0.tar.xz |
m doc
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/scrotty.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/scrotty.c b/src/scrotty.c index 286a30d..c7e98ee 100644 --- a/src/scrotty.c +++ b/src/scrotty.c @@ -320,7 +320,8 @@ static int evaluate(char* restrict buf, size_t n, const char* restrict pattern, char* fmt; time_t t; struct tm tm; - + + /* Expand '$' and '\'. */ while ((c = *pattern++)) { if (dollar) @@ -358,12 +359,15 @@ static int evaluate(char* restrict buf, size_t n, const char* restrict pattern, } buf[i] = '\0'; + /* Check whether there are any '%' to expand. */ if (strchr(buf, '%') == NULL) return 0; + /* Copy the buffer so we can reuse the buffer and use its old content for the format. */ fmt = alloca((strlen(buf) + 1) * sizeof(char)); memcpy(fmt, buf, (strlen(buf) + 1) * sizeof(char)); + /* Expand '%'. */ t = time(NULL); localtime_r(&t, &tm); if (strftime(buf, n, fmt, &tm) == 0) |