src/temp_in.c
/*
**	This function will create the temp-space in memory, read the input file
**	through the preprocessor line-by-line, and save it into the temp-space. It
**	also closes the input file on completion. (It shouldn't be needed again.)
**	A pointer to the temp-space will be put in g_temp_in.
**	Note: This is not the most efficient way possible to do this due to the
**	allocated space not being completely used(some whitespace will be trimmed
**	during preprocessing). But it is the simplest solution requiring the least
**	memory operations.
*/
This function will create the temp-space in memory, read the input file
through the preprocessor line-by-line, and save it into the temp-space. It
also closes the input file on completion. (It shouldn't be needed again.)
A pointer to the temp-space will be put in g_temp_in.
Note: This is not the most efficient way possible to do this due to the
allocated space not being completely used(some whitespace will be trimmed
during preprocessing). But it is the simplest solution requiring the least
memory operations.
This function will create the temp - space in memory read the input file through the preprocessor line - by - line and save it into the temp - space . It also closes the input file on completion . ( It shouldn ' t be needed again . ) A pointer to the temp - space will be put in g_temp_in . Note : This is not the most efficient way possible to do this due to the allocated space not being completely used ( some whitespace will be trimmed during preprocessing ) . But it is the simplest solution requiring the least memory operations .
void			read_file(char *filename)
{
	char	*line;
	int		fd;
	int		ln;
	fd = open(filename, O_RDONLY);
	if (fd == -1)
		read_error(filename);
	g_temp_in = ft_strnew(lseek(fd, 0, SEEK_END));
	lseek(fd, 0, SEEK_SET);
	ln = 0;
	while (get_next_line(fd, &line) == 1)
	{
		++ln;
		if (line[0] && !name_comment(line) && line[0] != COMMENT_CHAR)
		{
			check_error(ln, line);
			line = format_line(line);
			write_temp(line);
			write_temp("\n");
		}
		ft_strdel(&line);
	}
	close(fd);
	write_temp("\0");
}
void read_file ( char * filename ) { char * line ; int fd ; int ln ; fd = open ( filename , O_RDONLY ) ; if ( fd == -1 ) read_error ( filename ) ; g_temp_in = ft_strnew ( lseek ( fd , 0 , SEEK_END ) ) ; lseek ( fd , 0 , SEEK_SET ) ; ln = 0 ; while ( get_next_line ( fd , & line ) == 1 ) { ++ ln ; if ( line [ 0 ] && ! name_comment ( line ) && line [ 0 ] != COMMENT_CHAR ) { check_error ( ln , line ) ; line = format_line ( line ) ; write_temp ( line ) ; write_temp ( " \n " ) ; } ft_strdel ( & line ) ; } close ( fd ) ; write_temp ( " \0 " ) ; }
This function will create the temp-space in memory, read the input file
through the preprocessor line-by-line, and save it into the temp-space.
This function will create the temp - space in memory read the input file through the preprocessor line - by - line and save it into the temp - space .