summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--parsing.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/parsing.c b/parsing.c
index 8875f61..3f38681 100644
--- a/parsing.c
+++ b/parsing.c
@@ -18,6 +18,8 @@
#define TIME_BUFFER_SIZE 0xf
#define DATE_BUFFER_SIZE 0x20
+#define max(a, b) ((a) > (b) ? (a) : (b))
+
static pthread_mutex_t user_mutex, word_mutex, channel_mutex, time_mutex;
static struct user_t *last_user = NULL;
@@ -111,10 +113,10 @@ static void process_file(FILE *f, struct channel_t *channel, struct regexset_t *
user->characters += wcslen(wtext);
user->lines[time_i]++;
- if(user->seen_first == 0) {
+ if(user->seen_first == 0 || now_ut < user->seen_first) {
user->seen_first = now_ut;
}
- user->seen_last = now_ut;
+ user->seen_last = max(now_ut, user->seen_last);
pthread_mutex_unlock(&user_mutex);
pthread_mutex_lock(&channel_mutex);
@@ -167,10 +169,10 @@ static void process_file(FILE *f, struct channel_t *channel, struct regexset_t *
pthread_mutex_lock(&user_mutex);
struct user_t *user = user_get(nick);
- if(user->seen_first == 0) {
+ if(user->seen_first == 0 || now_ut < user->seen_first) {
user->seen_first = now_ut;
}
- user->seen_last = now_ut;
+ user->seen_last = max(now_ut, user->seen_last);
pthread_mutex_unlock(&user_mutex);
continue;
@@ -198,10 +200,10 @@ static void process_file(FILE *f, struct channel_t *channel, struct regexset_t *
pthread_mutex_lock(&user_mutex);
struct user_t *user = user_get(nick);
- if(user->seen_first == 0) {
+ if(user->seen_first == 0 || now_ut < user->seen_first) {
user->seen_first = now_ut;
}
- user->seen_last = now_ut;
+ user->seen_last = max(now_ut, user->seen_last);
pthread_mutex_unlock(&user_mutex);
continue;
@@ -229,10 +231,10 @@ static void process_file(FILE *f, struct channel_t *channel, struct regexset_t *
pthread_mutex_lock(&user_mutex);
struct user_t *user = user_get(nick);
- if(user->seen_first == 0) {
+ if(user->seen_first == 0 || now_ut < user->seen_first) {
user->seen_first = now_ut;
}
- user->seen_last = now_ut;
+ user->seen_last = max(now_ut, user->seen_last);
pthread_mutex_unlock(&user_mutex);
continue;
@@ -260,10 +262,10 @@ static void process_file(FILE *f, struct channel_t *channel, struct regexset_t *
pthread_mutex_lock(&user_mutex);
struct user_t *user = user_get(newnick);
- if(user->seen_first == 0) {
+ if(user->seen_first == 0 || now_ut < user->seen_first) {
user->seen_first = now_ut;
}
- user->seen_last = now_ut;
+ user->seen_last = max(now_ut, user->seen_last);
pthread_mutex_unlock(&user_mutex);
continue;
@@ -338,10 +340,10 @@ static void process_file(FILE *f, struct channel_t *channel, struct regexset_t *
user->kicks++;
victim_user->kicked++;
- if(user->seen_first == 0) {
+ if(user->seen_first == 0 || now_ut < user->seen_first) {
user->seen_first = now_ut;
}
- user->seen_last = now_ut;
+ user->seen_last = max(now_ut, user->seen_last);
pthread_mutex_unlock(&user_mutex);
continue;