Date: Tue, 6 Oct 2020 10:06:13 +0200 From: Hans Petter Selasky <hps@selasky.org> To: Baptiste Daroussin <bapt@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r366471 - head/usr.bin/backlight Message-ID: <f2178811-4b0e-14f6-f5f4-cdaef6736839@selasky.org> In-Reply-To: <202010060805.09685J6l009787@repo.freebsd.org> References: <202010060805.09685J6l009787@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2020-10-06 10:05, Baptiste Daroussin wrote: > Author: bapt > Date: Tue Oct 6 08:05:19 2020 > New Revision: 366471 > URL: https://svnweb.freebsd.org/changeset/base/366471 > > Log: > backlight: accept '%' in the brightness input value > > Improve friendlyness of the command line by accepting the percent brightness > in both format: with or without a trailing '%' > > Reviewed by: manu > Differential Revision: https://reviews.freebsd.org/D26692 > > Modified: > head/usr.bin/backlight/backlight.8 > head/usr.bin/backlight/backlight.c > > Modified: head/usr.bin/backlight/backlight.8 > ============================================================================== > --- head/usr.bin/backlight/backlight.8 Tue Oct 6 06:45:52 2020 (r366470) > +++ head/usr.bin/backlight/backlight.8 Tue Oct 6 08:05:19 2020 (r366471) > @@ -22,7 +22,7 @@ > .\" > .\" $FreeBSD$ > .\" > -.Dd October 02, 2020 > +.Dd October 06, 2020 > .Dt BACKLIGHT 8 > .Os > .Sh NAME > @@ -63,6 +63,7 @@ When querying the brightness level only print the valu > Query information about the backlight (name, type). > .It Ar value > Set the brightness level to this value, must be between 0 and 100. > +A trailing '%' is valid. > .It Ar incr | + > .Op Ar value > Decrement the backlight level. > > Modified: head/usr.bin/backlight/backlight.c > ============================================================================== > --- head/usr.bin/backlight/backlight.c Tue Oct 6 06:45:52 2020 (r366470) > +++ head/usr.bin/backlight/backlight.c Tue Oct 6 08:05:19 2020 (r366471) > @@ -144,6 +144,9 @@ main(int argc, char *argv[]) > action = BACKLIGHT_SET_BRIGHTNESS; > > if (argc == 1) { > + /* ignore a trailing % for user friendlyness */ > + if (argv[0][strlen(argv[0]) - 1] == '%') > + argv[0][strlen(argv[0]) - 1] = '\0'; > percent = strtonum(argv[0], 0, 100, &percent_error); > if (percent_error) > errx(1, "Cannot parse brightness level %s: %s", > Should there be a check here that strlen(xxx) > 0 ? --HPS
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?f2178811-4b0e-14f6-f5f4-cdaef6736839>