[hackers] [slock][PATCH] Improve option parsing routine

2016-10-28 Thread Klemens Nanni
This reduces the amount of strcmp() calls and comparisons in general to a minimum. --- slock.c | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/slock.c b/slock.c index 283b04e..e9b050a 100644 --- a/slock.c +++ b/slock.c @@ -298,15 +298,14 @@ main(int argc, char

[hackers] [slock][PATCH] Remove arg.h, simplify option parsing

2016-10-28 Thread Klemens Nanni
arg.h is really ugly code and way to complex for tools like slock that have such minimal synopsis. Regardless of that, usage() does not have to be a function of it's own if it's called just once. This (hopefully) is the final commit implementing proper command-line pargsing adhering to the POSIX

[hackers] [slock][PATCH] Allow usage of -- as end-of-options specifier

2016-10-28 Thread Klemens Nanni
As pointed out in #suckless, sticking to the POSIX Utility Syntax Guidelines[0] is a good idea. 0: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_02 --- slock.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/slock.c b/slock.c index af5edb2..1d28e3a 100644

Re: [hackers] [slock][PATCH] Replace arg.h with if statements, simplify

2016-10-28 Thread Evan Gates
On Fri, Oct 28, 2016 at 11:27 AM, Klemens Nanni wrote: > > ++argv is put on a seperate line since doing it within the execvp() call > would produce a compiler warning. Yes, because that's invoking undefined behavior. There is no guarantee as to the order of execution of function

[hackers] [slock][PATCH] Replace arg.h with if statements, simplify

2016-10-28 Thread Klemens Nanni
arg.h is pretty ugly code, but that is a matter of taste. Technically speaking the argument parsing can be done much cleaner especially for programs with such simple synopsis. Regardless of that, usage() does not have to be a function of it's own if it's called just once. ++argv is put on a

Re: [hackers] [dwm][PATCH] Do not call die() upon '-v' invocation

2016-10-28 Thread David Phillips
On Fri, Oct 28, 2016 at 03:58:14PM +0200, Martin Kühne wrote: > IMHO, when failing to parse command line arguments, usage() should be > called before exiting with EXIT_FAILURE. > on invocation with -h|--help, it should exit with EXIT_SUCCESS. > > cheers! > mar77i This sounds sane and solves the

Re: [hackers] [dwm] [PATCH] get rid of unnecessary ternary operator

2016-10-28 Thread Evan Gates
On Fri, Oct 28, 2016 at 2:17 AM, Hiltjo Posthuma wrote: > > FWIW: I disagree. The ternary form is slightly longer but more readable. I too disagree. I think the !! is more readable and idiomatic (either way, at least we aren't casting to bool...). But I am curious, does

Re: [hackers] [dwm][PATCH] Do not call die() upon '-v' invocation

2016-10-28 Thread Martin Kühne
IMHO, when failing to parse command line arguments, usage() should be called before exiting with EXIT_FAILURE. on invocation with -h|--help, it should exit with EXIT_SUCCESS. cheers! mar77i

Re: [hackers] [dwm][PATCH] Do not call die() upon '-v' invocation

2016-10-28 Thread quinq
> > If not, that's your fault (or the packager you trust do to it for > > you, actually again your responsability). > > Blaming someone else won't solve the issue. Exactly, hence “your responsability”.

Re: [hackers] [dwm][PATCH] Do not call die() upon '-v' invocation

2016-10-28 Thread Ali H. Fardan
On 2016-10-28 13:21, Quentin Rameau wrote: On 2016-10-28 13:02, Quentin Rameau wrote: > On Fri, Oct 28, 2016 at 12:45:14PM +, Ali H. Fardan wrote: >> actually, imo, I think >> usage() should return success. > Surely not. > The call to usage() is made when wrong options have been passed to >

Re: [hackers] [dwm][PATCH] Do not call die() upon '-v' invocation

2016-10-28 Thread Quentin Rameau
> On 2016-10-28 13:02, Quentin Rameau wrote: > > On Fri, Oct 28, 2016 at 12:45:14PM +, Ali H. Fardan wrote: > >> actually, imo, I think > >> usage() should return success. > > Surely not. > > The call to usage() is made when wrong options have been passed to > > the tool, you wouldn't

Re: [hackers] [dwm][PATCH] Do not call die() upon '-v' invocation

2016-10-28 Thread Ali H. Fardan
On 2016-10-28 13:02, Quentin Rameau wrote: On Fri, Oct 28, 2016 at 12:45:14PM +, Ali H. Fardan wrote: actually, imo, I think usage() should return success. Surely not. The call to usage() is made when wrong options have been passed to the tool, you wouldn't return “no error” code when

Re: [hackers] [dwm][PATCH] Do not call die() upon '-v' invocation

2016-10-28 Thread Ali H. Fardan
I don't think -v should output to stderr either, actually, imo, I think usage() should return success. On 2016-10-28 12:40, Klemens Nanni wrote: Returning -1 upon a valid invocation like 'dwm -v' is just wrong. --- dwm.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git

[hackers] [dwm][PATCH] Do not call die() upon '-v' invocation

2016-10-28 Thread Klemens Nanni
Returning -1 upon a valid invocation like 'dwm -v' is just wrong. --- dwm.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dwm.c b/dwm.c index 421bf27..35828b4 100644 --- a/dwm.c +++ b/dwm.c @@ -2122,8 +2122,10 @@ zoom(const Arg *arg) int main(int argc, char *argv[])

Re: [hackers] [dwm] [PATCH] get rid of unnecessary ternary operator

2016-10-28 Thread Laslo Hunhold
On Fri, 28 Oct 2016 11:17:09 +0200 Hiltjo Posthuma wrote: Hey Hiltjo, > FWIW: I disagree. The ternary form is slightly longer but more > readable. yeah, it's more of a taste thing. I don't mind either way, so let's keep it as is. Cheers Laslo -- Laslo Hunhold

Re: [hackers] [dwm] [PATCH] get rid of unnecessary ternary operator

2016-10-28 Thread Hiltjo Posthuma
On Thu, Oct 27, 2016 at 12:41:25PM +0200, Laslo Hunhold wrote: > On Thu, 27 Oct 2016 10:02:32 +0200 > Anselm R Garbe wrote: > > > To me ! is logical NOT and your suggestion relies on the fact that > > XUrgencyHint is a single bit flag? no? > > I prefer the original code, as it