Re: [PATCH] gen_snippet_d.pl: Add rules to ignore editor's backup files

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

 



On Wed, Dec 26, 2018 at 11:31:03PM +0900, Akira Yokosawa wrote:
> >From 6c0e6e632bbf234de340bcf51acf2007d8e3ac8b Mon Sep 17 00:00:00 2001
> From: Akira Yokosawa <akiyks@xxxxxxxxx>
> Date: Wed, 26 Dec 2018 23:11:26 +0900
> Subject: [PATCH] gen_snippet_d.pl: Add rules to ignore editor's backup files
> 
> Excerpt from Paul's report:
>     $ make
>     sh ./utilities/gen_snippet_d.sh
>     sh utilities/autodate.sh >autodate.tex
>     CodeSamples/datastruct/hash/hash_resize.c --> CodeSamples/datastruct/hash/hash_resize@xxxxxxxx
>     [...]
>     CodeSamples/datastruct/hash/.hash_resize.c.swp --> CodeSamples/datastruct/hash/CodeSamples/datastruct/hash.fcv
>     utilities/fcvextract.pl CodeSamples/datastruct/hash/.hash_resize.c.swp hash > CodeSamples/datastruct/hash/CodeSamples/datastruct/hash.fcv
>     /bin/bash: CodeSamples/datastruct/hash/CodeSamples/datastruct/hash.fcv: No such file or directory
>     make: *** [CodeSamples/datastruct/hash/CodeSamples/datastruct/hash.fcv] Error 1
> 
> .hash_resize.c.swp is a swap file of vim, which causes an invalid
> dependency rule to be emitted.
> 
> To prevent such errors, ignore .swp files as well as emacs' backup
> files ending in "~" and "#" from the search results in
> gen_snippet_d.pl.
> 
> Reported-by: Paul E. McKenney <paulmck@xxxxxxxxxxxxx>
> Signed-off-by: Akira Yokosawa <akiyks@xxxxxxxxx>
> ---
> Paul,
> 
> This should ignore .swp files in the dependency file.
> Can you test "make" while opening hash_resize.c in vim?
> 
>         Thanks, Akira
> 
> PS:
> 
> I'll comment on the update of Quick Quiz 10.13 later this week.

Works great, thank you!!!

It does not handle the case where you are concurrently editing the same
file with two different instances of "vim", but that could be considered
a feature rather than a bug.  ;-)  So no need to modify further.

Queued, will push with the QQ 10.13 update.

And have a great week, especially if this is holiday time for you!

							Thanx, Paul

> --
>  utilities/gen_snippet_d.pl | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/utilities/gen_snippet_d.pl b/utilities/gen_snippet_d.pl
> index 8ba31b5..e07e58d 100755
> --- a/utilities/gen_snippet_d.pl
> +++ b/utilities/gen_snippet_d.pl
> @@ -17,11 +17,19 @@ my @fcvsources_ltms;
>  my $snippet_key;
>  my $snippet_key_ltms;
>  my $source;
> +my @ignore_re;
> +my $re;
>  
>  $snippet_key = '\begin{snippet}' ;
>  $snippet_key_ltms = '\begin[snippet]' ;
> +@ignore_re = ('\.swp$', '~$', '\#$') ;  # to ignore backup of vim and emacs
>  @fcvsources = `grep -l -r -F '$snippet_key' CodeSamples` ;
> +@fcvsources = grep { not /\.ltms$/ } @fcvsources ;
>  @fcvsources_ltms = `grep -l -r -F '$snippet_key_ltms' CodeSamples` ;
> +foreach $re (@ignore_re) {
> +    @fcvsources = grep { not /$re/ } @fcvsources ;
> +    @fcvsources_ltms = grep { not /$re/ } @fcvsources_ltms ;
> +}
>  chomp @fcvsources ;
>  chomp @fcvsources_ltms ;
>  
> @@ -32,9 +40,6 @@ foreach $source (@fcvsources) {
>      my @snippet_commands1 ;
>      my $subdir ;
>      my $snippet ;
> -    if ($source =~ /\.ltms$/) {
> -	next;
> -    }
>      @snippet_commands1 = `grep -F '$snippet_key' $source` ;
>      chomp @snippet_commands1 ;
>      $source =~ m!(.*/[^/]+)/[^/]+! ;
> @@ -51,6 +56,7 @@ foreach $source (@fcvsources_ltms) {
>      my @snippet_commands1 ;
>      my $subdir ;
>      my $snippet ;
> +
>      @snippet_commands1 = `grep -F '$snippet_key_ltms' $source` ;
>      chomp @snippet_commands1 ;
>      $source =~ m!(.*/[^/]+)/[^/]+! ;
> @@ -77,9 +83,7 @@ foreach $source (@fcvsources) {
>      my $src_under_sub ;
>      my $subdir ;
>      my $snippet ;
> -    if ($source =~ /\.ltms$/) {
> -	next;
> -    }
> +
>      @snippet_commands2 = `grep -F '$snippet_key' $source` ;
>      chomp @snippet_commands2 ;
>      $src_under_sub = $source ;
> -- 
> 2.7.4
> 
> 




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux