git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Makefile(s): avoid recipe prefix in conditional statements

From
Jeff King <peff@peff.net>
Date
Apr 9, 2024, 00:17 UTC
Message-ID
<20240409001728.GB1647304@coredump.intra.peff.net>
In-Reply-To
<20240409000414.GA1647304@coredump.intra.peff.net>
On Mon, Apr 08, 2024 at 08:04:14PM -0400, Jeff King wrote:
Show 16 quoted lines
> I do find it curious that in:
> 
> ifdef FOO
> 	SOME_VAR += bar
> endif
> 
> the tab is significant for "ifdef" but not for SOME_VAR (at least that
> is implied by Taylor's patch, which does not touch the bodies within the
> conditionals).
> 
> I may just be showing my ignorance of the parsing issue, though. For
> anybody else digging into the details, I think the correct link is:
> 
>   https://savannah.gnu.org/bugs/index.php?64185
> 
> (the commit has the wrong bug number, 64815).

Answering my own question (at least what I think the answer is): there's basically two levels of parsing going on. The outer layer is respecting conditionals to decide which lines to care about at all, and the inner one is figuring what are assignments, rules, recipes, etc.

So the outer parser cares about things that look like conditionals, but nothing else. The inner one has more context and can more easily realize that "\tSOME_VAR += bar" is not part of a recipe.

I'd guess it's _possible_ to fix the case discussed in the bug by letting the outer parser know more of the inner-parser context (i.e., whatever rules it uses to decide that the assignment line is not a recipe line could similarly be used for a line like "\telse"). But I also wouldn't be at all surprised if it would involve a substantial rewrite. At any rate, I'd certainly defer to you on such matters. I'm mostly just thinking out loud from my peanut-gallery perspective.

-Peff
Previous: Jeff KingNext: Paul Smith
Message 11 of 13 in “Makefiles are broken as of GNU Make commit 07fcee35f058a876447c8a021f9eb1943f902534”
  1. Dario GjorgjevskiApr 8, 2024
  2. Makefile(s): avoid recipe prefix in conditional statementsTaylor Blau, Apr 8, 2024
  3. Junio C HamanoApr 8, 2024
  4. Paul SmithApr 8, 2024
  5. Junio C HamanoApr 8, 2024
  6. Paul SmithApr 9, 2024
  7. Junio C HamanoApr 8, 2024
  8. Paul SmithApr 9, 2024
  9. Junio C HamanoApr 9, 2024
  10. Jeff KingApr 9, 2024
  11. Jeff KingApr 9, 2024
  12. Paul SmithApr 9, 2024
  13. Junio C HamanoApr 8, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.