summaryrefslogtreecommitdiffstats
path: root/scripts/indent.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/indent.sh')
-rwxr-xr-xscripts/indent.sh153
1 files changed, 153 insertions, 0 deletions
diff --git a/scripts/indent.sh b/scripts/indent.sh
new file mode 100755
index 0000000..506be6a
--- /dev/null
+++ b/scripts/indent.sh
@@ -0,0 +1,153 @@
+#!/bin/sh
+# $LynxId: indent.sh,v 1.5 2018/07/08 15:22:44 tom Exp $
+# Indent LYNX files (for reference). See "lnx-indent" from
+# https://invisible-island.net/cindent/
+NOOP=no
+OPTS='
+--blank-lines-after-declarations
+--blank-lines-after-procedures
+--braces-on-if-line
+--continue-at-parentheses
+--cuddle-else
+--dont-break-procedure-type
+--indent-level4
+--leave-preprocessor-space
+--line-length80
+--no-space-after-function-call-names
+--parameter-indentation4
+--space-after-cast
+--space-special-semicolon
+--swallow-optional-blank-lines
+-T AddressDefList
+-T BOOL
+-T BOOLEAN
+-T CSOfield_info
+-T DIR
+-T DocAddress
+-T DocInfo
+-T DocObj
+-T EntryInfo
+-T EditFieldData
+-T FILE
+-T GCC_NORETURN
+-T GCC_UNUSED
+-T GLOBALREF
+-T GroupDef
+-T GroupDefList
+-T HTAAFailReasonType
+-T HTAAProt
+-T HTAARealm
+-T HTAAServer
+-T HTAssoc
+-T HTAssocList
+-T HTAtom
+-T HTBTElement
+-T HTBTree
+-T HTChildAnchor
+-T HTChunk
+-T HTConverter
+-T HTFormat
+-T HTLine
+-T HTLinkType
+-T HTList
+-T HTParentAnchor
+-T HTParentAnchor0
+-T HTPresentation
+-T HTStream
+-T HTStyle
+-T HTStyleChange
+-T HTStyleSheet
+-T HText
+-T HyperDoc
+-T InitResponseAPDU
+-T Item
+-T ItemList
+-T LYNX_ADDRINFO
+-T LYNX_HOSTENT
+-T LYUCcharset
+-T LexItem
+-T ProgramPaths
+-T STable_cellinfo
+-T STable_info
+-T STable_rowinfo
+-T STable_states
+-T SearchAPDU
+-T SearchResponseAPDU
+-T TextAnchor
+-T UCode_t
+-T UserDefList
+-T WAISDocumentCodes
+-T WAISDocumentHeader
+-T WAISDocumentHeadlines
+-T WAISDocumentLongHeader
+-T WAISDocumentShortHeader
+-T WAISDocumentText
+-T WAISInitResponse
+-T WAISSearch
+-T _cdecl
+-T any
+-T bit_map
+-T boolean
+-T bstring
+-T data_tag
+-T eServerType
+-T lynx_list_item_type
+-T pdu_type
+-T query_term
+-nbacc
+'
+for name in $*
+do
+ case $name in
+ -n) NOOP=yes
+ OPTS="$OPTS -v"
+ ;;
+ -*)
+ OPTS="$OPTS $name"
+ ;;
+ *.[ch])
+ save="${name}".a$$
+ test="${name}".b$$
+ rm -f "$save" "$test"
+ mv "$name" "$save"
+ sed \
+ -e '/MODULE_ID(/s/)$/);/' \
+ -e 's,)[ ]*\<GCC_PRINTFLIKE,);//GCC_PRINTFLIKE,' \
+ -e 's,[ ]*\<GCC_NORETURN;,;//GCC_NORETURN;,' \
+ -e 's,[ ]*\<GCC_UNUSED;,;//GCC_UNUSED;,' \
+ "$save" >"$test"
+ cp "$test" "$name"
+ chmod u+w "$name"
+ ${INDENT_PROG-indent} -npro $OPTS "$name"
+ sed \
+ -e '/MODULE_ID(/s/);$/)/' \
+ -e 's,;[ ]*//GCC_UNUSED;, GCC_UNUSED;,' \
+ -e 's,;[ ]*//GCC_NORETURN;, GCC_NORETURN;,' \
+ -e 's,);[ ]*//GCC_PRINTFLIKE,) GCC_PRINTFLIKE,' \
+ "$name" >"$test"
+ mv "$test" "$name"
+ rm -f "${name}~"
+ if test $NOOP = yes ; then
+ if ! ( cmp -s "$name" $save )
+ then
+ diff -u $save "$name"
+ fi
+ mv "$save" "$name"
+ rm -f "${name}~"
+ else
+ if ( cmp -s "$name" "$save" )
+ then
+ echo "** unchanged $name"
+ rm -f "${name}" "${name}~"
+ mv "$save" "$name"
+ else
+ echo "** updated $name"
+ rm -f "$save"
+ fi
+ fi
+ ;;
+ *)
+ echo "** ignored: $name"
+ ;;
+ esac
+done