diff options
Diffstat (limited to 'other')
-rwxr-xr-x | other/astyle/format-source | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/other/astyle/format-source b/other/astyle/format-source index c2238841..7fa8b677 100755 --- a/other/astyle/format-source +++ b/other/astyle/format-source | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/bash |
2 | 2 | ||
3 | set -ex | 3 | set -ex |
4 | 4 | ||
@@ -30,8 +30,28 @@ if ! which "$APIDSL"; then | |||
30 | fi | 30 | fi |
31 | fi | 31 | fi |
32 | 32 | ||
33 | TO_JSON='s/\\/\\\\/g;s/\n/\\n/g;s/"/\\"/g;s/^(.*)$/"$1"/' | ||
34 | FROM_JSON='s/\\"/"/g;s/^"(.*)"$/$1/;s/\\\\/\\/g;s/\\n/\n/g' | ||
35 | |||
36 | apidsl_request() { | ||
37 | TMPFILE=$(mktemp /tmp/apidsl.XXXXXX) | ||
38 | curl -o "$TMPFILE" -X POST --data @<( | ||
39 | echo '["Request",'; | ||
40 | cat $2; | ||
41 | echo ']') https://apidsl2.herokuapp.com/$1 | ||
42 | if grep '\[1,"' "$TMPFILE" > /dev/null; then | ||
43 | echo "Error: $(grep -o '".*"' /tmp/apidsl-$$ | perl -0777 -pe "$FROM_JSON")" >&2 | ||
44 | rm "$TMPFILE" | ||
45 | exit 1 | ||
46 | fi | ||
47 | perl -0777 -pe 's/^\[0,(.*)\]$/$1/' "$TMPFILE" | ||
48 | rm "$TMPFILE" | ||
49 | } | ||
50 | |||
33 | apidsl_curl() { | 51 | apidsl_curl() { |
34 | curl -X POST --data-binary @"$1" https://apidsl.herokuapp.com/apidsl | 52 | apidsl_request "c" <( |
53 | apidsl_request "parse" <( | ||
54 | perl -0777 -pe "$TO_JSON" $1)) | perl -0777 -pe "$FROM_JSON" | ||
35 | } | 55 | } |
36 | 56 | ||
37 | # Check if apidsl generated sources are up to date. | 57 | # Check if apidsl generated sources are up to date. |