Skip to content

Conversation

@richard-ramos
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings December 10, 2025 16:00
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR attempts to replace manual shell escaping with Nim's quoteShell function for defining a C preprocessor macro. The change affects two files where a C preprocessor definition is passed to the compiler via the passc pragma.

Key Changes:

  • Replaces \\\" manual escaping with quoteShell("\"lsquic_xxhash.h\"") in both prelude.nim and lsquic/lsquic_ffi.nim

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
prelude.nim Modified C preprocessor flag definition to use quoteShell instead of manual escaping
lsquic/lsquic_ffi.nim Modified C preprocessor flag definition to use quoteShell instead of manual escaping

Critical Issue Found: The usage of quoteShell in this PR is incorrect. The function is being passed a string that already contains quote characters ("\"lsquic_xxhash.h\""), which will cause quoteShell to add additional escaping/quoting around these existing quotes. This is not the intended behavior for defining a C preprocessor macro. The original approach with manual escaping (\\\") was correct for this use case, as it ensures the C preprocessor receives the macro definition with proper string literal quotes.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

prelude.nim Outdated
type ptrdiff_t* {.importc: "ptrdiff_t", header: "<stddef.h>".} = int

{.passc: "-DXXH_HEADER_NAME=\\\"lsquic_xxhash.h\\\"".}
{.passc: "-DXXH_HEADER_NAME=" & quoteShell("\"lsquic_xxhash.h\"").}
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usage of quoteShell appears incorrect here. quoteShell("\"lsquic_xxhash.h\"") passes a string containing quote characters to quoteShell, which will add additional escaping/quoting around it for shell safety.

The goal is to define a C preprocessor macro XXH_HEADER_NAME with the value "lsquic_xxhash.h" (as a string literal). The correct approach would be:

{.passc: "-DXXH_HEADER_NAME=" & quoteShell("lsquic_xxhash.h").}

However, this still may not produce the desired C string literal. The original approach with manual escaping (\\\") was actually correct for passing string literals to C preprocessor definitions. If the goal is to use quoteShell for cross-platform safety, the string literal quotes should be added after quoting:

{.passc: "-DXXH_HEADER_NAME=\\\"" & quoteShell("lsquic_xxhash.h") & "\\\"".}

But this would double-escape. The simplest correct fix using quoteShell would be to not include the quotes in the input.

Suggested change
{.passc: "-DXXH_HEADER_NAME=" & quoteShell("\"lsquic_xxhash.h\"").}
{.passc: "-DXXH_HEADER_NAME=\\\"lsquic_xxhash.h\\\"".}

Copilot uses AI. Check for mistakes.


{.passc: "-DXXH_HEADER_NAME=\\\"lsquic_xxhash.h\\\"".}
{.passc: "-DXXH_HEADER_NAME=" & quoteShell("\"lsquic_xxhash.h\"").}
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usage of quoteShell appears incorrect here. quoteShell("\"lsquic_xxhash.h\"") passes a string containing quote characters to quoteShell, which will add additional escaping/quoting around it for shell safety.

The goal is to define a C preprocessor macro XXH_HEADER_NAME with the value "lsquic_xxhash.h" (as a string literal). The correct approach would be:

{.passc: "-DXXH_HEADER_NAME=" & quoteShell("lsquic_xxhash.h").}

However, this still may not produce the desired C string literal. The original approach with manual escaping (\\\") was actually correct for passing string literals to C preprocessor definitions. If the goal is to use quoteShell for cross-platform safety, the string literal quotes should be added after quoting:

{.passc: "-DXXH_HEADER_NAME=\\\"" & quoteShell("lsquic_xxhash.h") & "\\\"".}

But this would double-escape. The simplest correct fix using quoteShell would be to not include the quotes in the input.

Copilot uses AI. Check for mistakes.
Co-authored-by: Esteban C Borsani <[email protected]>
@richard-ramos
Copy link
Member Author

richard-ramos commented Dec 11, 2025

@nitely it seems windows did not like the '<lsquic_xxhash.h>' :(

@nitely
Copy link

nitely commented Dec 11, 2025

@nitely it seems windows did not like the '<lsquic_xxhash.h>' :(

I checked it got passed the include error when compiling Nimbus (it failed later to find some boringSSL/OpenSSL files I think). The single quotes should work in mingw.

@richard-ramos
Copy link
Member Author

🤔 i wonder then why it failed here. ... there's some diff in both environments that i am missing (besides nimbus using nimbus-build-system and nim-lsquic using nimble)

@nitely
Copy link

nitely commented Dec 11, 2025

🤔 i wonder then why it failed here. ... there's some diff in both environments that i am missing (besides nimbus using nimbus-build-system and nim-lsquic using nimble)

The only difference I can see is Nimbus using bash as shell, and this repo uses msys2, and Nimbus runs everything with mingw make.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants