-
Notifications
You must be signed in to change notification settings - Fork 594
Closed
Labels
Description
Within our organisation we are moving to uncrustify and we have been using INDENT-OFF / INDENT-ON comments to ignore entire C header files that are not under our control in our code base (i.e. third party API headers) rather than maintaining a list of file exceptions in our pre-commit hooks.
When running uncrustify against these files multiple whitespace changes are seen.
There are two problems
- Trailing whitespace is always removed (this happens with an empty config file)
- If
nl_maxis set it is applied within the ignored code block
Tested with Uncrustify-0.65_f 3503c92
Example that demonstrates the issue:
configuration file
nl_max=2
Input
/* *INDENT-OFF* */
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
/* The following line has a trailing space */
printf("Hello World!\n");
return EXIT_SUCCESS;
}
/* *INDENT-ON* */Expected output - unchanged
Observed output
/* *INDENT-OFF* */
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
/* The following line has a trailing space */
printf("Hello World!\n");
return EXIT_SUCCESS;
}
/* *INDENT-ON* */Difference
diff -u example.c example.c.uncrustify
--- example.c 2017-09-07 14:47:27.971867687 +0100
+++ example.c.uncrustify 2017-09-07 14:56:03.506449892 +0100
@@ -2,14 +2,12 @@
#include <stdio.h>
#include <stdlib.h>
-
int main(int argc, char *argv[])
{
/* The following line has a trailing space */
- printf("Hello World!\n");
+ printf("Hello World!\n");
return EXIT_SUCCESS;
}
/* *INDENT-ON* */Reactions are currently unavailable