Skip to content

Commit 3fb3678

Browse files
committed
Create pgjindent for java.
1 parent 17c03b3 commit 3fb3678

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

src/tools/pgindent/README

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,9 @@ We get the list of typedef's included in pgindent by running:
3030
Make sure to do the pgsql/bin directory, and the src/interfaces/odbc
3131
directory. Merge the output of these and remove duplicates.
3232

33+
---------------------------------------------------------------------------
34+
35+
For java, we use astyle, http://astyle.sourceforge.net/, with the
36+
following options:
37+
38+
find . -name '*.java' -type f -print | xargs -n100 pgjindent

src/tools/pgindent/pgindent

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fi
2424

2525
for FILE
2626
do
27-
cat $FILE |
27+
cat "$FILE" |
2828
# convert // comments to /* */
2929
sed 's;^\([ ]*\)//\(.*\)$;\1/* \2 */;g' |
3030
# mark some comments for special treatment later
@@ -1319,7 +1319,7 @@ int pgindent_func_no_var_fix;\
13191319
# add space after comments that start on tab stops
13201320
sed 's,;\(/\*.*\*/\)$,; \1,' |
13211321
# work around #else indenting next line if #ifdef defines variables at top
1322-
# work around case misindenting function has no variables defined
1322+
# work around misindenting of function with no variables defined
13231323
awk '
13241324
{
13251325
if ($0 ~ "^[ ]*int[ ]*pgindent_func_no_var_fix;")
@@ -1329,6 +1329,7 @@ int pgindent_func_no_var_fix;\
13291329
}
13301330
else print $0;
13311331
}' |
1332+
# remove tabs and retab with four spaces
13321333
detab -t8 -qc |
13331334
entab -t4 -qc |
13341335
# move trailing * in function return type
@@ -1459,7 +1460,7 @@ int pgindent_func_no_var_fix;\
14591460
}
14601461
else print $0;
14611462
}' |
1462-
cat >/tmp/$$ && cat /tmp/$$ >$FILE
1463+
cat >/tmp/$$ && cat /tmp/$$ >"$FILE"
14631464
done
14641465

14651466
# The 'for' loop makes these backup files useless so delete them

src/tools/pgindent/pgjindent

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
3+
trap "rm -f /tmp/$$ /tmp/$$a" 0 1 2 3 15
4+
entab </dev/null >/dev/null
5+
if [ "$?" -ne 0 ]
6+
then echo "Go to the src/tools/entab directory and do a 'make' and 'make install'." >&2
7+
echo "This will put the 'entab' command in your path." >&2
8+
echo "Then run $0 again."
9+
exit 1
10+
fi
11+
astyle --version </dev/null >/dev/null 2>&1
12+
if [ "$?" -eq 0 ]
13+
then echo "You do not appear to have 'astyle' installed on your system." >&2
14+
exit 1
15+
fi
16+
17+
for FILE
18+
do
19+
astyle --style=java -b -p -j < "$FILE" >/tmp/$$ 2>/tmp/$$a
20+
if [ "$?" -ne 0 -o -s /tmp/$$a ]
21+
then echo "$FILE"
22+
cat /tmp/$$a
23+
fi
24+
cat /tmp/$$ |
25+
entab -t4 -qc |
26+
cat >/tmp/$$a && cat /tmp/$$a >"$FILE"
27+
done

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy