Re: [PATCH] Makefile: ASCII-sort += lists

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Denton,

On Thu, 8 Oct 2020, Denton Liu wrote:

> On Thu, Oct 08, 2020 at 12:06:47PM +0200, Johannes Schindelin wrote:
> > Also, this strikes me as yet another task that is so automatable that we
> > should really avoid bothering humans with it.
>
> Yep, I found these changes via a similar-looking Python script. I like
> the Perl version, though, since it gives a path for inclusion so that we
> can automate this task.

Heh, when it comes to string processing, I always reach for Perl.

> > I gave it a quick whirl, and
> > this Perl script seems to do the job for me:
> >
> > 	$key = '';
> > 	@to_sort = ();
> >
> > 	sub flush_sorted {
> > 		if ($#to_sort >= 0) {
> > 			print join('', sort @to_sort);
> > 			@to_sort = ();
> > 		}
> > 	}
> >
> > 	while (<>) {
> > 		if (/^(\S+) \+=/) {
> > 			if ($key ne $1) {
> > 				flush_sorted;
> > 				$key = $1;
> > 			}
> > 			push @to_sort, $_;
> > 		} else {
> > 			flush_sorted;
> > 			print $_;
> > 		}
> > 	}
> > 	flush_sorted;
> >
> > It is not the most elegant Perl script I ever wrote, but it does the job
> > for me. And we could probably adapt and use it for other instances where
> > we want to keep things sorted (think `commands[]` in `git.c` and the
> > `cmd_*()` declarations in `builtin.h`, for example) and hook it up in
> > `ci/run-static-analysis.sh` for added benefit.
> >
> > My little script also finds this:
> >
> > -- snip --
> > @@ -1231,8 +1231,8 @@ space := $(empty) $(empty)
> >
> >  ifdef SANITIZE
> >  SANITIZERS := $(foreach flag,$(subst $(comma),$(space),$(SANITIZE)),$(flag))
> > -BASIC_CFLAGS += -fsanitize=$(SANITIZE) -fno-sanitize-recover=$(SANITIZE)
> >  BASIC_CFLAGS += -fno-omit-frame-pointer
> > +BASIC_CFLAGS += -fsanitize=$(SANITIZE) -fno-sanitize-recover=$(SANITIZE)
> >  ifneq ($(filter undefined,$(SANITIZERS)),)
> >  BASIC_CFLAGS += -DSHA1DC_FORCE_ALIGNED_ACCESS
> >  endif
> > -- snap --
>
> I opted to exclude this hunk because it didn't seem like a list that
> should be sorted. Perhaps if we include this in the static-analysis
> script, we could define a whitelist of lists that we want to keep
> sorted?

I agree, modulo s/whitelist/allow list/.

Thanks,
Dscho




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux