50
50
if (NR >= 2)
51
51
print line1;
52
52
if (NR >= 2 &&
53
- line2 ~ " ^{[ ]*$" &&
54
- line1 !~ " ^struct" &&
55
- line1 !~ " ^enum" &&
56
- line1 !~ " ^typedef" &&
57
- line1 !~ " ^extern[ ][ ]*\"C\"" &&
58
- line1 !~ "=" &&
59
- line1 ~ "\)" )
53
+ line2 ~ / ^{[ ]*$/ &&
54
+ line1 !~ / ^struct/ &&
55
+ line1 !~ / ^enum/ &&
56
+ line1 !~ / ^typedef/ &&
57
+ line1 !~ / ^extern[ ][ ]*"C"/ &&
58
+ line1 !~ /=/ &&
59
+ line1 ~ /)/ )
60
60
print "int pgindent_func_no_var_fix;";
61
61
line1 = line2;
62
62
}
70
70
line2 = $0;
71
71
if (skips > 0)
72
72
skips--;
73
- if (line1 ~ " ^#ifdef[ ]*__cplusplus" &&
74
- line2 ~ " ^extern[ ]*\"C\ "[ ]*$" )
73
+ if (line1 ~ / ^#ifdef[ ]*__cplusplus/ &&
74
+ line2 ~ / ^extern[ ]*"C "[ ]*$/ )
75
75
{
76
76
print line1;
77
77
print line2;
81
81
line2 = "";
82
82
skips = 2;
83
83
}
84
- else if (line1 ~ " ^#ifdef[ ]*__cplusplus" &&
85
- line2 ~ " ^}[ ]*$" )
84
+ else if (line1 ~ / ^#ifdef[ ]*__cplusplus/ &&
85
+ line2 ~ / ^}[ ]*$/ )
86
86
{
87
87
print line1;
88
88
print "/* Close extern \"C\" */";
1732
1732
# work around misindenting of function with no variables defined
1733
1733
awk '
1734
1734
{
1735
- if ($0 ~ " ^[ ]*int[ ]*pgindent_func_no_var_fix;" )
1735
+ if ($0 ~ / ^[ ]*int[ ]*pgindent_func_no_var_fix;/ )
1736
1736
{
1737
1737
if (getline && $0 != "")
1738
1738
print $0;
1751
1751
# line3 = $0;
1752
1752
# if (skips > 0)
1753
1753
# skips--;
1754
- # if (line1 ~ " *{$" &&
1755
- # line2 ~ " *[^;{}]*;$" &&
1756
- # line3 ~ " *}$" )
1754
+ # if (line1 ~ / *{$/ &&
1755
+ # line2 ~ / *[^;{}]*;$/ &&
1756
+ # line3 ~ / *}$/ )
1757
1757
# {
1758
1758
# print line2;
1759
1759
# line2 = "";
1778
1778
line3 = $0;
1779
1779
if (skips > 0)
1780
1780
skips--;
1781
- if (line1 ~ " *{$" &&
1782
- line2 ~ "^$" &&
1783
- line3 ~ " */\\*$" )
1781
+ if (line1 ~ / *{$/ &&
1782
+ line2 ~ /^$/ &&
1783
+ line3 ~ / *\/\*$/ )
1784
1784
{
1785
1785
print line1;
1786
1786
print line3;
1819
1819
line2 = $0;
1820
1820
if (skips > 0)
1821
1821
skips--;
1822
- if (line1 ~ "^$" &&
1823
- line2 ~ " ^#endif" )
1822
+ if (line1 ~ /^$/ &&
1823
+ line2 ~ / ^#endif/ )
1824
1824
{
1825
1825
print line2;
1826
1826
line2 = "";
1844
1844
line1 = line2;
1845
1845
}
1846
1846
END {
1847
- if (NR >= 1 && line2 ~ " ^#endif" )
1847
+ if (NR >= 1 && line2 ~ / ^#endif/ )
1848
1848
printf "\n";
1849
1849
print line1;
1850
1850
}' |
@@ -1853,16 +1853,16 @@ do
1853
1853
# like real functions.
1854
1854
awk ' BEGIN {paren_level = 0}
1855
1855
{
1856
- if ($0 ~ /^[a-zA-Z_][a-zA-Z_0-9]*[^\ (]*$/)
1856
+ if ($0 ~ /^[a-zA-Z_][a-zA-Z_0-9]*[^(]*$/)
1857
1857
{
1858
1858
saved_len = 0;
1859
1859
saved_lines[++saved_len] = $0;
1860
1860
if ((getline saved_lines[++saved_len]) == 0)
1861
1861
print saved_lines[1];
1862
1862
else
1863
- if (saved_lines[saved_len] !~ /^[a-zA-Z_][a-zA-Z_0-9]*\ (/ ||
1864
- saved_lines[saved_len] ~ /^[a-zA-Z_][a-zA-Z_0-9]*\ (.*\ )$/ ||
1865
- saved_lines[saved_len] ~ /^[a-zA-Z_][a-zA-Z_0-9]*\ (.*\ );$/)
1863
+ if (saved_lines[saved_len] !~ /^[a-zA-Z_][a-zA-Z_0-9]*(/ ||
1864
+ saved_lines[saved_len] ~ /^[a-zA-Z_][a-zA-Z_0-9]*(.*)$/ ||
1865
+ saved_lines[saved_len] ~ /^[a-zA-Z_][a-zA-Z_0-9]*(.*);$/)
1866
1866
{
1867
1867
print saved_lines[1];
1868
1868
print saved_lines[2];
1879
1879
}
1880
1880
for (i=1; i <= saved_len; i++)
1881
1881
{
1882
- if (i == 1 && saved_lines[saved_len] ~ /\ );$/)
1882
+ if (i == 1 && saved_lines[saved_len] ~ /);$/)
1883
1883
{
1884
1884
printf "%s", saved_lines[i];
1885
1885
if (substr(saved_lines[i], length(saved_lines[i]),1) != "*")
0 commit comments