mirror of
https://github.com/swaywm/sway.git
synced 2024-12-27 15:36:29 +01:00
Address emersion's feedback on peek_line
This commit is contained in:
parent
fbca3bbacb
commit
af87c7a1af
2 changed files with 5 additions and 5 deletions
|
@ -49,11 +49,11 @@ char *read_line(FILE *file) {
|
|||
return string;
|
||||
}
|
||||
|
||||
char *peek_line(FILE *file, int offset, long *position) {
|
||||
char *peek_line(FILE *file, int line_offset, long *position) {
|
||||
long pos = ftell(file);
|
||||
size_t length = 1;
|
||||
char *line = calloc(1, length);
|
||||
for (int i = 0; i <= offset; i++) {
|
||||
size_t length = 0;
|
||||
char *line = NULL;
|
||||
for (int i = 0; i <= line_offset; i++) {
|
||||
ssize_t read = getline(&line, &length, file);
|
||||
if (read < 0) {
|
||||
break;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
char *read_line(FILE *file);
|
||||
char *peek_line(FILE *file, int offset, long *position);
|
||||
char *peek_line(FILE *file, int line_offset, long *position);
|
||||
char *read_line_buffer(FILE *file, char *string, size_t string_len);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue