Re: Indentation mistake

Simon Josefsson via Gnulib discussion list <[email protected]> Fri, 03 May 2024 08:46:30 +0200
Newsgroups gmane.comp.lib.gnulib.bugs,gmane.comp.gnu.inetutils.bugs
Message-ID <[email protected]>
Collin Funk <[email protected]> writes:

> Hi Simon,
>
> On 5/2/24 11:25 AM, Simon Josefsson via Bug reports for the GNU Internet utilities wrote:
>>> Sadly, I cannot do this, at least not easily.  After installing GNU
>>> indent, "make syntax-check" complains about many files:
>>>
>>>     $ indent --version
>>>     GNU indent 2.2.12
>> You need 2.2.13 :-)
>
> I see that you added the 'syntax-check' for indent in Gnulib. One
> minor problem though, it breaks if the user has an ~/.indent.pro. :)
>
> I don't use indent much, so I forgot my repository where I store
> dotfiles installs this:
>
>     $ cat ~/.indent.pro 
>     --gnu-style
>     --no-tabs
>
> Here lets check if the code is indented:
>
>     $ make sc_indent | wc -l
>     maint.mk: code format error, try "make indent"
>     make: *** [maint.mk:1760: sc_indent] Error 1
>     52751
>
> I was confused for a bit until I saw that file.
>
>    $ rm ~/.indent.pro
>    $ make sc_indent | wc -l
>    1
>
> Indent has -npro that you can use to ignore the file which might be
> good.

Nice catch.  It doesn't make sense for maint.mk's indentation to be
influenced by ~/.indent.pro -- the style has to be a per-project
setting.  I pushed the patch below.

/Simon
0001-maint.mk-Don-t-fail-on-.indent.pro-reported-by-Colli.patch (text/x-diff, 1.2 KB)
From 6213c5bd72d15ca5e1ea9c34122899e02fed448c Mon Sep 17 00:00:00 2001
From: Simon Josefsson <[email protected]>
Date: Fri, 3 May 2024 08:44:03 +0200
Subject: [PATCH] maint.mk: Don't fail on ~/.indent.pro, reported by Collin
 Funk.

* top/maint.mk (indent_args): Use --ignore-profile.
---
 ChangeLog    | 5 +++++
 top/maint.mk | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index d967c8cfac..2781a70800 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-05-03  Simon Josefsson  <[email protected]>
+
+	maint.mk: Don't fail on ~/.indent.pro, reported by Collin Funk.
+	* top/maint.mk (indent_args): Use --ignore-profile.
+
 2024-05-02  Collin Funk  <[email protected]>
 
 	gnulib-tool.sh: Fix program name in error message.
diff --git a/top/maint.mk b/top/maint.mk
index c30e71ba6e..af865717c4 100644
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -1746,7 +1746,7 @@ refresh-po:
 
 # Indentation
 
-indent_args ?= -ppi 1
+indent_args ?= --ignore-profile --preprocessor-indentation 1
 C_SOURCES ?= $$($(VC_LIST_EXCEPT) | grep '\.[ch]\(.in\)\?$$')
 INDENT_SOURCES ?= $(C_SOURCES)
 exclude_file_name_regexp--indent ?= $(exclude_file_name_regexp--sc_indent)
-- 
2.34.1
signature.asc (application/pgp-signature, 255 B)
-----BEGIN PGP SIGNATURE-----

iIoEARYIADIWIQSjzJyHC50xCrrUzy9RcisI/kdFogUCZjSIRhQcc2ltb25Aam9z
ZWZzc29uLm9yZwAKCRBRcisI/kdForyWAP9mqhkO24AbbB9ke/ZDdwJfvUWfi1e8
y0mEJN6J1WCB9gD+JGqzNQ8S2ItzgOimoyuxjjtAvJVyBe0vfs30XB4ATgU=
=AomL
-----END PGP SIGNATURE-----