Commit 03b6ccc
committed
[clang-format] Add SpaceBetweenUnderscoreParens option for GNU gettext macro
This adds a new configuration option SpaceBetweenUnderscoreParens to control
spacing between underscore and opening parenthesis. This is specifically
designed for the gettext internationalization macro '_()' commonly used in
GNU projects like GDB.
The option:
- Defaults to true for LLVM style (preserving existing behavior)
- Defaults to false for GNU style (removes space before '_(')
- Only affects single underscore tokens '_', not other identifiers
- Leaves all other spacing rules unchanged
Examples:
GNU style with SpaceBetweenUnderscoreParens=false:
printf(_("Hello")); // No space before '_('
my_func (arg); // Space before other functions preserved
LLVM style with SpaceBetweenUnderscoreParens=true:
printf(_ ("Hello")); // Standard spacing rules apply
This addresses the common pattern in GNU software where gettext messages
use '_()' without spaces, improving consistency with GNU coding standards.1 parent 70529df commit 03b6ccc
File tree
5 files changed
+62
-0
lines changed- clang
- docs
- include/clang/Format
- lib/Format
- unittests/Format
5 files changed
+62
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6605 | 6605 | | |
6606 | 6606 | | |
6607 | 6607 | | |
| 6608 | + | |
| 6609 | + | |
| 6610 | + | |
| 6611 | + | |
| 6612 | + | |
| 6613 | + | |
| 6614 | + | |
| 6615 | + | |
| 6616 | + | |
| 6617 | + | |
| 6618 | + | |
| 6619 | + | |
6608 | 6620 | | |
6609 | 6621 | | |
6610 | 6622 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4896 | 4896 | | |
4897 | 4897 | | |
4898 | 4898 | | |
| 4899 | + | |
| 4900 | + | |
| 4901 | + | |
| 4902 | + | |
| 4903 | + | |
| 4904 | + | |
| 4905 | + | |
| 4906 | + | |
| 4907 | + | |
| 4908 | + | |
4899 | 4909 | | |
4900 | 4910 | | |
4901 | 4911 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1219 | 1219 | | |
1220 | 1220 | | |
1221 | 1221 | | |
| 1222 | + | |
| 1223 | + | |
1222 | 1224 | | |
1223 | 1225 | | |
1224 | 1226 | | |
| |||
1713 | 1715 | | |
1714 | 1716 | | |
1715 | 1717 | | |
| 1718 | + | |
1716 | 1719 | | |
1717 | 1720 | | |
1718 | 1721 | | |
| |||
2044 | 2047 | | |
2045 | 2048 | | |
2046 | 2049 | | |
| 2050 | + | |
2047 | 2051 | | |
2048 | 2052 | | |
2049 | 2053 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4901 | 4901 | | |
4902 | 4902 | | |
4903 | 4903 | | |
| 4904 | + | |
| 4905 | + | |
| 4906 | + | |
| 4907 | + | |
| 4908 | + | |
4904 | 4909 | | |
4905 | 4910 | | |
4906 | 4911 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17852 | 17852 | | |
17853 | 17853 | | |
17854 | 17854 | | |
| 17855 | + | |
| 17856 | + | |
| 17857 | + | |
| 17858 | + | |
| 17859 | + | |
| 17860 | + | |
| 17861 | + | |
| 17862 | + | |
| 17863 | + | |
| 17864 | + | |
| 17865 | + | |
| 17866 | + | |
| 17867 | + | |
| 17868 | + | |
| 17869 | + | |
| 17870 | + | |
| 17871 | + | |
| 17872 | + | |
| 17873 | + | |
| 17874 | + | |
| 17875 | + | |
| 17876 | + | |
| 17877 | + | |
| 17878 | + | |
| 17879 | + | |
| 17880 | + | |
| 17881 | + | |
| 17882 | + | |
| 17883 | + | |
| 17884 | + | |
| 17885 | + | |
17855 | 17886 | | |
17856 | 17887 | | |
17857 | 17888 | | |
| |||
0 commit comments