summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2063b4e)
raw | patch | inline | side by side (parent: 2063b4e)
author | Jonas Fonseca <fonseca@diku.dk> | |
Tue, 17 Feb 2009 01:00:45 +0000 (02:00 +0100) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Tue, 17 Feb 2009 11:55:23 +0000 (12:55 +0100) |
Which means that drawing will have to do some more formatting, however,
the startup time is shorter since gmtime_r() is no longer called. Same
repository as last commit.
18980 fonseca 20 0 17776 15m 872 S 0 0.8 0:01.26 tig
18630 fonseca 20 0 23224 20m 868 S 0 1.0 0:01.26 tig-0.14.1
the startup time is shorter since gmtime_r() is no longer called. Same
repository as last commit.
18980 fonseca 20 0 17776 15m 872 S 0 0.8 0:01.26 tig
18630 fonseca 20 0 23224 20m 868 S 0 1.0 0:01.26 tig-0.14.1
tig.c | patch | blob | history |
index 20f7d5498cf32ef16d0aba335985e6c8456a96f1..5ab9a48eb3f00675f5ce74ef4483518ed02c7701 100644 (file)
--- a/tig.c
+++ b/tig.c
}
+static const char *
+mkdate(const time_t *time)
+{
+ static char buf[DATE_COLS + 1];
+ struct tm tm;
+
+ gmtime_r(time, &tm);
+ return strftime(buf, sizeof(buf), DATE_FORMAT, &tm) ? buf : NULL;
+}
+
+
static bool
argv_from_string(const char *argv[SIZEOF_ARG], int *argc, char *cmd)
{
@@ -1960,15 +1971,9 @@ draw_field(struct view *view, enum line_type type, const char *text, int len, bo
}
static bool
-draw_date(struct view *view, struct tm *time)
+draw_date(struct view *view, time_t *time)
{
- char buf[DATE_COLS];
- char *date;
- int timelen = 0;
-
- if (time)
- timelen = strftime(buf, sizeof(buf), DATE_FORMAT, time);
- date = timelen ? buf : NULL;
+ const char *date = mkdate(time);
return draw_field(view, LINE_DATE, date, DATE_COLS, FALSE);
}
* author <email@address.tld> 1138474660 +0100
*/
static void
-parse_author_line(char *ident, const char **author, struct tm *tm)
+parse_author_line(char *ident, const char **author, time_t *time)
{
char *nameend = strchr(ident, '<');
char *emailend = strchr(ident, '>');
if (emailend && emailend[1] == ' ') {
char *secs = emailend + 2;
char *zone = strchr(secs, ' ');
- time_t time = (time_t) atol(secs);
- if (zone && strlen(zone) == STRING_SIZE(" +0700"))
- parse_timezone(&time, zone + 1);
+ *time = (time_t) atol(secs);
- gmtime_r(&time, tm);
+ if (zone && strlen(zone) == STRING_SIZE(" +0700"))
+ parse_timezone(time, zone + 1);
}
}
struct tree_entry {
char id[SIZEOF_REV];
mode_t mode;
- struct tm time; /* Date from the author ident. */
+ time_t time; /* Date from the author ident. */
const char *author; /* Author of the commit. */
char name[1];
};
tree_read_date(struct view *view, char *text, bool *read_date)
{
static const char *author_name;
- static struct tm author_time;
+ static time_t author_time;
if (!text && *read_date) {
*read_date = FALSE;
continue;
entry->author = author_name;
- memcpy(&entry->time, &author_time, sizeof(entry->time));
+ entry->time = author_time;
line->dirty = 1;
break;
}
char id[SIZEOF_REV]; /* SHA1 ID. */
char title[128]; /* First line of the commit message. */
const char *author; /* Author of the commit. */
- struct tm time; /* Date from the author ident. */
+ time_t time; /* Date from the author ident. */
char filename[128]; /* Name of file. */
bool has_previous; /* Was a "previous" line detected. */
};
{
static struct blame_commit *commit = NULL;
static int blamed = 0;
- static time_t author_time;
static bool read_file = TRUE;
if (read_file)
commit->author = get_author(line);
} else if (match_blame_header("author-time ", &line)) {
- author_time = (time_t) atol(line);
+ commit->time = (time_t) atol(line);
} else if (match_blame_header("author-tz ", &line)) {
- parse_timezone(&author_time, line);
- gmtime_r(&author_time, &commit->time);
+ parse_timezone(&commit->time, line);
} else if (match_blame_header("summary ", &line)) {
string_ncopy(commit->title, line, strlen(line));
blame_draw(struct view *view, struct line *line, unsigned int lineno)
{
struct blame *blame = line->data;
- struct tm *time = NULL;
+ time_t *time = NULL;
const char *id = NULL, *author = NULL;
char text[SIZEOF_STR];
(on && *text && regexec(view->regex, text, 1, &pmatch, 0) != REG_NOMATCH)
if (commit) {
- char buf[DATE_COLS + 1];
-
if (MATCH(commit->title, 1) ||
MATCH(commit->author, opt_author) ||
MATCH(commit->id, opt_date))
return TRUE;
- if (strftime(buf, sizeof(buf), DATE_FORMAT, &commit->time) &&
- MATCH(buf, 1))
+ if (MATCH(mkdate(&commit->time), 1))
return TRUE;
}
char id[SIZEOF_REV]; /* SHA1 ID. */
char title[128]; /* First line of the commit message. */
const char *author; /* Author of the commit. */
- struct tm time; /* Date from the author ident. */
+ time_t time; /* Date from the author ident. */
struct ref **refs; /* Repository references. */
chtype graph[SIZEOF_REVGRAPH]; /* Ancestry chain graphics. */
size_t graph_size; /* The width of the graph array. */
{
struct commit *commit = line->data;
enum { S_TITLE, S_AUTHOR, S_DATE, S_REFS, S_END } state;
- char buf[DATE_COLS + 1];
regmatch_t pmatch;
for (state = S_TITLE; state < S_END; state++) {
case S_DATE:
if (!opt_date)
continue;
- if (!strftime(buf, sizeof(buf), DATE_FORMAT, &commit->time))
+ text = mkdate(&commit->time);
+ if (!text)
continue;
- text = buf;
break;
case S_REFS:
if (!opt_show_refs)