Re: baby shell: code that compiles (for the most part), but indent doesn't like it

Eric Deplagne <[email protected]> Tue, 11 Jun 2019 11:52:42 +0200
Newsgroups gmane.comp.gnu.indent.bugs
Message-ID <[email protected]>
--===============6087320418302317949==
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="E+d41Xxi+aYmIyHQ"
Content-Disposition: inline


--E+d41Xxi+aYmIyHQ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, 11 Jun 2019 02:33:39 -0700, L A Walsh wrote:
> On 2019/06/11 01:55, Eric Deplagne wrote:
> > On Sun, 09 Jun 2019 14:39:36 -0700, L A Walsh wrote:
> >  =20
> >> 	I hand formatted it, and substituted in the value
> >> of the define: ",close(".  But the problem is since the compiler
> >> handles the above, shouldn't 'indent' be able to as well?
> >>    =20
> >
> >   Clearly, a #define with both "," and "(", NO.
> >  =20
> ?clearly? Clearly it doesn't and maybe you are saying it cannot, but whet=
her
> or not it 'should' would depend on one's goals or what one wants to
> accomplish in the program.

  Clearly (it's here I add "i.m.o."), it should not even try to deal with
  #define messups.

> >   Just remember the preprocessor can do almost any dirty trick
> >   (is cpp formally turing complete or not ?).
> >  =20
> I would have no idea if any given instance of cpp is formally or informal=
ly
> turing complete.  Given the things one can do in macro languages as a
> form of declarative programming, I wouldn't doubt that someone might be a=
ble
> to prove it so, but I'm not sure how that would help w/the problem.

  Macro languages clearly are easily turing complete, I'm pretty sure m4 is,
  I have a little more doubt about cpp, but in any case it's almost.

  If it is actually turing complete, that means it can do just anything
  to our poor code, and indenting with defines taken into account is then
  just plain unfeasible.

> I thought the easiest way might be to have indent put markers around
> defines so that once a substitution was done, indent could do its normal
> processing and could find the markers and undo the substitution, resulting
> in something that should achieve that desired goal.
>=20
> However, I'd admit it was alot of work for what might be edge cases, so it
> really depends on how compete the implementor wants indent to be as compa=
red
> to what a 'c' compiler handles.

  The C compiler actually handles fully preprocessed code, i.e. the output =
of cpp.

  And it doesn't care if it's indented or in any way indentable.

> Whether it is fixed or not, isn't going to affect me much, as I don't
> use such convoluted constructs, as a general rule, in my own code (too mu=
ch
> headache in maintenance later trying to figure out what I was doing!)
>=20
> As far as useful fixes, I'd much prefer to have had the RFE I submitted
> looked at, but I sorta realized it wasn't likely to happen after no
> comment(s) for a few months....*oh well*....supporting old SW is just rea=
lly
> no fun if one has moved on to other things...and if it is no fun, how can
> you get motivated on something one did "on the side".  FWIW, the RFE I
> was talking about -- was the RFE I'll copy in below, but I'm not doing so
> much in C these days, so its probably not that important now either.
>=20
> Still, the above obfuscated code might make a good test case if it ever
> got to the point of being tested... :-)
>=20
> ----
>=20
>=20
>=20
> -------- Original Message --------
> Subject: 	Fwd: RFE: option to 'cuddle' bracketless targets of
> conditional statements
> Date: 	Mon, 23 Jan 2017 21:46:43 -0800
> From: 	L A Walsh <[email protected]>
> To: 	[email protected]
>=20
>=20
>=20
> I didn't see this option in my version of 'indent'
>=20
> (GNU indent 2.2.10), so forgive me if it is already there, but
> would it be possible to add an option to put or keep things like:
>=20
>  if (done) return done;
>=20
>  if (done)
>    return done;
>=20
>  for(i=3D0; i<100; ++i) printf("%d\n", i);
>=20
>  while (! done) done=3Dget_status();
>=20
>=20
> on 1 line?
>=20
> Primarily thinking about bracketless targets that follow a conditional
> that easily fit on 1 line.
>=20
> Thanks!
>=20
>=20

--=20
  Eric Deplagne

--E+d41Xxi+aYmIyHQ
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iD8DBQFc/3nqej7DisjVpq4RApJ5AJ0bm80MhZYNK6TuNVS598sCG6jEgwCfbc3t
oZk2lY1dx9Sm4EfCNAD2ZJQ=
=tcV5
-----END PGP SIGNATURE-----

--E+d41Xxi+aYmIyHQ--


--===============6087320418302317949==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KYnVnLWluZGVu
dCBtYWlsaW5nIGxpc3QKYnVnLWluZGVudEBnbnUub3JnCmh0dHBzOi8vbGlzdHMuZ251Lm9yZy9t
YWlsbWFuL2xpc3RpbmZvL2J1Zy1pbmRlbnQK

--===============6087320418302317949==--