diff options
Diffstat (limited to 'common/readline.c')
-rw-r--r-- | common/readline.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/common/readline.c b/common/readline.c index ed5801de..abe986c4 100644 --- a/common/readline.c +++ b/common/readline.c | |||
@@ -48,6 +48,20 @@ char *read_line(FILE *file) { | |||
48 | return string; | 48 | return string; |
49 | } | 49 | } |
50 | 50 | ||
51 | char *peek_line(FILE *file, int offset) { | ||
52 | int pos = ftell(file); | ||
53 | char *line = NULL; | ||
54 | for (int i = 0; i <= offset; i++) { | ||
55 | free(line); | ||
56 | line = read_line(file); | ||
57 | if (!line) { | ||
58 | break; | ||
59 | } | ||
60 | } | ||
61 | fseek(file, pos, SEEK_SET); | ||
62 | return line; | ||
63 | } | ||
64 | |||
51 | char *read_line_buffer(FILE *file, char *string, size_t string_len) { | 65 | char *read_line_buffer(FILE *file, char *string, size_t string_len) { |
52 | size_t length = 0; | 66 | size_t length = 0; |
53 | if (!string) { | 67 | if (!string) { |