mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05: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;
 | 
						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);
 | 
						long pos = ftell(file);
 | 
				
			||||||
	size_t length = 1;
 | 
						size_t length = 0;
 | 
				
			||||||
	char *line = calloc(1, length);
 | 
						char *line = NULL;
 | 
				
			||||||
	for (int i = 0; i <= offset; i++) {
 | 
						for (int i = 0; i <= line_offset; i++) {
 | 
				
			||||||
		ssize_t read = getline(&line, &length, file);
 | 
							ssize_t read = getline(&line, &length, file);
 | 
				
			||||||
		if (read < 0) {
 | 
							if (read < 0) {
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,7 +4,7 @@
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
char *read_line(FILE *file);
 | 
					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);
 | 
					char *read_line_buffer(FILE *file, char *string, size_t string_len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue