Fix undersample option accepting 0 trunk
authorLukas Jiriste <ljiriste@student.42prague.com>
Fri, 3 May 2024 10:57:34 +0000 (12:57 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Fri, 3 May 2024 10:57:34 +0000 (12:57 +0200)
When -u 0 is specified, it leads to an infinite loop.
The window is then unresponsive which is clearly a bug.
Now the -u 0 option emits a help message.

src/parsing.c

index 69789bba904a07816ff635954cb2a73a70445380..61f0782164467707bc8d4aa85ca1acd0a073b820 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: ljiriste <marvin@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/04/26 10:47:46 by ljiriste          #+#    #+#             */
-/*   Updated: 2024/04/26 11:06:32 by ljiriste         ###   ########.fr       */
+/*   Updated: 2024/05/03 12:57:05 by ljiriste         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -73,7 +73,7 @@ static int    parse_arg(char **argv, t_session *s, int *i)
                && ft_isint(argv[*i + 1]) && ft_atoi(argv[*i + 1]) > 0)
                s->img.height = ft_atoi(argv[++*i]);
        else if (!ft_strcmp(argv[*i], "-u")
-               && ft_isint(argv[*i + 1]) && ft_atoi(argv[*i + 1]) >= 0)
+               && ft_isint(argv[*i + 1]) && ft_atoi(argv[*i + 1]) > 0)
                s->img.undersample_max = ft_atoi(argv[++*i]);
        else if (!ft_strcmp(argv[*i], "-d") && ft_isint(argv[*i + 1]))
                s->set.detail = ft_atoi(argv[++*i]);