Yann Weber 7 lat temu
rodzic
commit
92d5f72ddc
2 zmienionych plików z 7 dodań i 3 usunięć
  1. 1
    1
      src/ttail_search_files.c
  2. 6
    2
      tests/ttail_search_check.c

+ 1
- 1
src/ttail_search_files.c Wyświetl plik

200
 		}
200
 		}
201
 		last = -1; /* last pos we saw a '\n' */
201
 		last = -1; /* last pos we saw a '\n' */
202
 		cur = read_beg;
202
 		cur = read_beg;
203
-		while(cur < start)
203
+		while(cur <= start)
204
 		{
204
 		{
205
 			c = getc(f);
205
 			c = getc(f);
206
 			if(c == EOF)
206
 			if(c == EOF)

+ 6
- 2
tests/ttail_search_check.c Wyświetl plik

125
 	long res;
125
 	long res;
126
 	fseek(fpl, -1, SEEK_END);
126
 	fseek(fpl, -1, SEEK_END);
127
 	res = _ttail_file_start_line(fpl);
127
 	res = _ttail_file_start_line(fpl);
128
-	printf("%ld\n", res);
128
+	ck_assert(res == 357);
129
+	res = _ttail_file_start_line(fpl);
129
 	ck_assert(res == 357);
130
 	ck_assert(res == 357);
130
 	fseek(fpl, -1, SEEK_CUR);
131
 	fseek(fpl, -1, SEEK_CUR);
131
 	res = _ttail_file_start_line(fpl);
132
 	res = _ttail_file_start_line(fpl);
132
-	printf("%ld\n", res);
133
 	ck_assert(res == 298);
133
 	ck_assert(res == 298);
134
+	fseek(fpl, -1, SEEK_CUR);
134
 	res = _ttail_file_start_line(fpl);
135
 	res = _ttail_file_start_line(fpl);
135
 	ck_assert(res == 221);
136
 	ck_assert(res == 221);
137
+	fseek(fpl, -1, SEEK_CUR);
136
 	res = _ttail_file_start_line(fpl);
138
 	res = _ttail_file_start_line(fpl);
137
 	ck_assert(res == 136);
139
 	ck_assert(res == 136);
140
+	fseek(fpl, -1, SEEK_CUR);
138
 	res = _ttail_file_start_line(fpl);
141
 	res = _ttail_file_start_line(fpl);
139
 	ck_assert(res == 77);
142
 	ck_assert(res == 77);
143
+	fseek(fpl, -1, SEEK_CUR);
140
 	res = _ttail_file_start_line(fpl);
144
 	res = _ttail_file_start_line(fpl);
141
 	ck_assert(res == 0);
145
 	ck_assert(res == 0);
142
 }
146
 }

Loading…
Anuluj
Zapisz