resurrecting-open-source-projects / scrot

SCReenshOT - command line screen capture utility
Other
512 stars 51 forks source link

getopt_long() cleanup #227

Closed N-R-K closed 1 year ago

N-R-K commented 1 year ago

Noticed these while I was trying to add --delay-select for #221

options: test against correct return value

getopt_long manpage says:

| If all command-line options have been parsed, then getopt() returns -1.

it doesn't say anything about returning EOF. but since EOF is typically defined as -1 it ended up working by accident.

options: remove unused variable

getopt_long accepts NULL as longindex argument, so no need to pass a dummy variable.

guijan commented 1 year ago

https://man.freebsd.org/cgi/man.cgi?getopt(3)

     The getopt() function was once specified to return EOF instead of -1.
     This was changed by IEEE Std 1003.2-1992 ("POSIX.2") to decouple getopt()
     from <stdio.h>.

Probably, getopt_long() inherited the old POSIX getopt() behavior, and maybe scrot was initially developed with a pre-1992 version of POSIX in mind.

N-R-K commented 1 year ago

Thanks, I've changed the commit message.