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
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
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
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
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
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
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
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
> > 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”.
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
>
> 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
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
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
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[])
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
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
16 matches
Mail list logo