bug-indent
[Top][All Lists]
Advanced

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

indent - add support for gcc's extension allowing nested procediures?


From: Graham Toal
Subject: indent - add support for gcc's extension allowing nested procediures?
Date: Fri, 4 Mar 2022 13:32:18 -0600

Being at heart an old Algol coder, I tend to use the gcc extension that
allows nested procedures more that most C coders would.  (nested procedures
must be explicitly of type "auto") Also I'm writing a source to source
language translator for an algol-like language to C which relies on this
extension.

Unfortunately nested procedures are not supported by indent, which makes
maintenance of sources using this extension somewhat awkward.

I had a look at Indent today to see if the shortcoming could be fixed -
turns out it can, quite minimally, with hopefully no side effects on
existing behaviour:

Add "auto" as a class along with "static" etc:  (this may not be strictly
necessary but should be done anyway)

gtoal@linux:~/src/compilers101/indent/indent-2.2.9$ diff src/gperf.c
src/gperf.c~
89d88
<       {"auto", rw_decl,},

Allow nested procedures to be indentable:

gtoal@linux:~/src/compilers101/indent/indent-2.2.9$ diff src/lexi.c
src/lexi.c~
525c525
<                  (parser_state_tos->ind_level >= 0) &&
      /* >= 0 to allow nested procedures */
---
>                  (parser_state_tos->ind_level == 0) &&

While I'm here ... the current indent sources do not compile with the
current gcc compiler.  The minimal change below allows it to compile.  If
applying this fix, you might consider cleaning up the other warnings that
gcc generates for indent?

gtoal@linux:~/src/compilers101/indent/indent-2.2.9$ diff src/output.c
src/output.c~
26c26
<        FILE            * output       = NULL;
---
> static FILE            * output       = NULL;

Best regards,

Graham Toal <gtoal@gtoal.com>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]