Skip to content

Conversation

@Karlson2k
Copy link
Contributor

@Karlson2k Karlson2k commented Jul 15, 2025

"config.h" is a locally generated header. It must be included as #include "config.h".
It is already included correctly in some sources files. This commit unifies the way how "config.h" is included.
Examples of current correct includes:

"config.h" is a locally generated header. It must be included as
'#include "config.h"'.
It is already included correctly in some sources files. This commit
unifies the way how "config.h" is included.

Signed-off-by: Evgeny Grin (Karlson2k) <[email protected]>
@alejandro-colomar
Copy link
Collaborator

Was this a scripted change? Would you mind saying which script you ran exactly? Thanks!

@Karlson2k
Copy link
Contributor Author

I used "search and replace in files" in my default IDE Eclipse CDT.
However, simple commands, like sed -i -e 's@^#include <config\.h>$@#include "config.h"@' */*.{c,h} */*/*.{c,h} */*/*/*.{c,h} */*/*/*/*.{c,h} or find . -type f \( -name '*.c' -o -name '*.h' \) -exec sed -i -e 's@^#include <config\.h>$@#include "config.h"@' {} + can do the same (assuming your sed supports non-portable -i, like GNU sed).

Copy link
Collaborator

@alejandro-colomar alejandro-colomar left a comment

Choose a reason for hiding this comment

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

Thanks!

@alejandro-colomar
Copy link
Collaborator

I used "search and replace in files" in my default IDE Eclipse CDT. However, simple commands, like sed -i -e 's@^#include <config\.h>$@#include "config.h"@' */*.{c,h} */*/*.{c,h} */*/*/*.{c,h} */*/*/*/*.{c,h} or find . -type f \( -name '*.c' -o -name '*.h' \) -exec sed -i -e 's@^#include <config\.h>$@#include "config.h"@' {} + can do the same (assuming your sed supports non-portable -i, like GNU sed).

Yup, I'd have done

$ find . -type f | grep '\.[ch]$' | xargs sed -i 's/^#include <config\.h>$/#include "config.h"/';

It is always good to know how scripted changes have been applied exactly, in case it misses some cases accidentally.

@alejandro-colomar alejandro-colomar merged commit eb71706 into shadow-maint:master Jul 16, 2025
10 checks passed
@Karlson2k Karlson2k deleted the fix-include-config-h branch July 16, 2025 13:11
@Karlson2k
Copy link
Contributor Author

Yup, I'd have done

$ find . -type f | grep '\.[ch]$' | xargs sed -i 's/^#include <config\.h>$/#include "config.h"/';

It is always good to know how scripted changes have been applied exactly, in case it misses some cases accidentally.

Sed command can be further improved to really catch everything:
sed -i -Ee 's/^([ ]*)#([ ]*)include <config\.h>/#\2include "config.h/', where [ ] should be [ space tab ].
😄

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.

2 participants