Browse Source

Bugfix on datemax > max date

Yann Weber 7 years ago
parent
commit
2283a16991
2 changed files with 9 additions and 6 deletions
  1. 3
    4
      src/ttail_init.c
  2. 6
    2
      src/ttail_search_files.c

+ 3
- 4
src/ttail_init.c View File

@@ -58,8 +58,8 @@ ttail_t *ttail_init(int argc, char **argv)
58 58
 	res->logfile_sz = 0;
59 59
 	res->prefix_sz = -1;
60 60
 	res->session = NULL;
61
-	memset(&(res->date_min), 0, sizeof(struct tm));
62
-	memset(&(res->date_max), 0, sizeof(struct tm));
61
+	ttail_tm_init(&(res->date_min));
62
+	ttail_tm_init(&(res->date_max));
63 63
 
64 64
 	while(1)
65 65
 	{
@@ -384,8 +384,7 @@ int ttail_set_dates(ttail_t* res, char* dates[2])
384 384
 
385 385
 	for(c=0;c<2;c++)
386 386
 	{
387
-		memset(c==0?&(res->date_min):&(res->date_max), 0, \
388
-			sizeof(struct tm));
387
+		ttail_tm_init(c==0?&(res->date_min):&(res->date_max));
389 388
 		if(!dates[c])
390 389
 		{
391 390
 			continue;

+ 6
- 2
src/ttail_search_files.c View File

@@ -268,8 +268,7 @@ int _ttail_search_files_binary_search(ttail_t* t, const struct tm* in,
268 268
 			off = 0;
269 269
 			return 0;
270 270
 		}
271
-		else if(*id == t->logfile_sz - 1 ||
272
-			cmax > 0)
271
+		else if(cmax > 0)
273 272
 		{
274 273
 			/* somewhere in current file */
275 274
 			ret = _ttail_search_file_binary_search(t, in, ftm, min);
@@ -312,6 +311,11 @@ running binary search algorithm in '%s'\n", t->logfile_name[*id]);
312 311
 			}
313 312
 			return 0;
314 313
 		}
314
+		else if(*id == t->logfile_sz - 1 && cmax < 0)
315
+		{
316
+			*off = t->session->file.file_sz[*id];
317
+			return 0;
318
+		}
315 319
 		(*id)++;
316 320
 	}
317 321
 	if(!valid)

Loading…
Cancel
Save