src/error_handling.c
/*
**	This function counts how many parameters there are. If it doesn't match the
**	definition in op.c, then it'll display an error and cleanly exit.
*/
This function counts how many parameters there are. If it doesn't match the
definition in op.c, then it'll display an error and cleanly exit.
This function counts how many parameters there are . If it doesn ' t match the definition in op . c then it ' ll display an error and cleanly exit .
void			verify_params_num(int ln, char *line, char *clean_line)
{
	char	**words;
	int		wordcount;
	if (identify_line(clean_line) == 5)
	{
		while (*clean_line && *clean_line != '\n')
			++clean_line;
		++clean_line;
	}
	else if (!clean_line[0])
		return ;
	words = ft_strsplit(clean_line, ' ');
	wordcount = 0;
	while (words[wordcount])
		++wordcount;
	if (wordcount > instruction_params_num(words[0]) + 1)
		error(ln, line, "Too many parameters");
	if (wordcount < instruction_params_num(words[0]) + 1)
		error(ln, line, "Too few parameters");
	ft_strarrdel(&words);
}
void verify_params_num ( int ln , char * line , char * clean_line ) { char * * words ; int wordcount ; if ( identify_line ( clean_line ) == 5 ) { while ( * clean_line && * clean_line != ' \n ' ) ++ clean_line ; ++ clean_line ; } else if ( ! clean_line [ 0 ] ) return ; words = ft_strsplit ( clean_line , ' ' ) ; wordcount = 0 ; while ( words [ wordcount ] ) ++ wordcount ; if ( wordcount > instruction_params_num ( words [ 0 ] ) + 1 ) error ( ln , line , " " ) ; if ( wordcount < instruction_params_num ( words [ 0 ] ) + 1 ) error ( ln , line , " " ) ; ft_strarrdel ( & words ) ; }
This function counts how many parameters there are.
This function counts how many parameters there are .