On Mon, Jan 25, 2021 at 11:17:04AM +0100, Martijn van Duren wrote:
>       if (argc == 1) {
> -             double del = atof(argv[0]);
> -             if (del == 0)
> +             delay = strtodnum(argv[0], 0, UINT32_MAX / 1000000, &errstr);
> +             if (errstr != NULL)
>                       viewstr = argv[0];
> -             else
> -                     delay = del;

You need the else.  delay should only be changed if parsing was successful.

>       } else if (argc == 2) {
>               viewstr = argv[0];
> -             delay = atof(argv[1]);
> -             if (delay <= 0)
> -                     delay = 5;
> +             delay = strtodnum(optarg, 0, UINT32_MAX / 1000000, &errstr);

This should be argv[1] instead of optarg.

> +             if (errstr != NULL)
> +                     errx(1, "-s \"%s\": delay value is %s", optarg, errstr);
>       }

The -s in the error message is wrong.  Here delay was passed as argument.

bluhm

Reply via email to