#!/bin/sh

trap "rm -f /tmp/$$ /tmp/$$a" 0 1 2 3 15
entab </dev/null >/dev/null
if [ "$?" -ne 0 ]
then	echo "Go to the src/tools/entab directory and do a 'make' and 'make install'." >&2
	echo "This will put the 'entab' command in your path." >&2
	echo "Then run $0 again."
	exit 1
fi
indent -st -npro </dev/null >/dev/null 2>&1
if [ "$?" -ne 0 ]
then	echo "You do not appear to have 'indent' installed on your system." >&2
	exit 1
fi
indent -version -npro </dev/null >/dev/null 2>&1
if [ "$?" -eq 0 ]
then	echo "You appear to have GNU indent rather than BSD indent." >&2
	echo "See the pgindent/README file for a description of its problems." >&2
	EXTRA_OPTS="-ncdb -bli0 -npcs -cli4"
else	echo "Hope you installed /src/tools/pgindent/indent.bsd.patch." >&2
	EXTRA_OPTS="-bbb -cli1"
fi

for FILE
do
	cat $FILE |
	sed 's;/\*  *---;/*---X_X;g' |
# workaround for indent bug with 'else' handling
	sed 's;\([} 	]\)else[ 	]*\(/\*.*\)$;\1else\
\2;g' | 
	detab -t4 -qc |
# protect backslashes in DATA()
	sed 's;^DATA(.*$;/*&*/;' >/tmp/$$a

# We get the list of typedef's from /src/tools/find_typedef
	indent -bad -bap -bc -bl -d0 -cdb -nce -nfc1 -di12 -i4 -l75 \
		-lp -nip -npro $EXTRA_OPTS \
-TA_Const \
-TA_Expr \
-TA_Indices \
-TAbsoluteTime \
-TAcl \
-TAclId \
-TAclIdType \
-TAclItem \
-TAclMode \
-TAddAttrStmt \
-TAgg \
-TAggFuncInfo \
-TAggInfo \
-TAggState \
-TAggref \
-TAllocBlock \
-TAllocBlockData \
-TAllocChunk \
-TAllocChunkData \
-TAllocMode \
-TAllocPointer \
-TAllocSet \
-TAllocSetData \
-TAlterUserStmt \
-TAnyInvalidation \
-TAppend \
-TAppendState \
-TArray \
-TArrayRef \
-TArrayType \
-TAtom \
-TAttr \
-TAttrDefault \
-TAttrNumber \
-TAttributeSize \
-TAuthRequest \
-TAuthRequestPacket \
-TBOX \
-TBTItem \
-TBTItemData \
-TBTMetaPageData \
-TBTPageOpaque \
-TBTPageOpaqueData \
-TBTPageState \
-TBTPriQueue \
-TBTPriQueueElem \
-TBTScanList \
-TBTScanListData \
-TBTScanOpaque \
-TBTScanOpaqueData \
-TBTSortKey \
-TBTSpool \
-TBTStack \
-TBTStackData \
-TBTTapeBlock \
-TBUCKET_INDEX \
-TBackend \
-TBackendId \
-TBackendTag \
-TBitArray \
-TBitIndex \
-TBlock \
-TBlockId \
-TBlockIdData \
-TBlockNumber \
-TBoolPtr \
-TBucket \
-TBufFile \
-TBufFlags \
-TBuffer \
-TBufferBlock \
-TBufferDesc \
-TBufferHdr \
-TBufferLock \
-TBufferTag \
-TCATEGORY \
-TCHUNK_INFO \
-TCIRCLE \
-TCPFunction \
-TCPPFunction \
-TCancelRequestPacket \
-TCandidateList \
-TCaseExpr \
-TCaseWhen \
-TCash \
-TCatCTup \
-TCatCache \
-TCatalogInvalidationData \
-TChangeACLStmt \
-TChromosome \
-TCity \
-TClientData \
-TClosePortalStmt \
-TClusterStmt \
-TCmdType \
-TColormap \
-TColumnDef \
-TCommandDest \
-TCommandId \
-TCommonScanState \
-TCommonState \
-TConnStatusType \
-TConst \
-TConstrCheck \
-TConstrType \
-TConstraint \
-TCopyStmt \
-TCost \
-TCreatePLangStmt \
-TCreateSeqStmt \
-TCreateStmt \
-TCreateTrigStmt \
-TCreateUserStmt \
-TCreatedbStmt \
-TCursor \
-TDIR \
-TDR_printtup \
-TDateADT \
-TDateTime \
-TDatum \
-TDatumPtr \
-TDefElem \
-TDefineStmt \
-TDeleteStmt \
-TDepth \
-TDestReceiver \
-TDestroyStmt \
-TDestroydbStmt \
-TDisplay \
-TDl_info \
-TDlelem \
-TDllist \
-TDrawable \
-TDropPLangStmt \
-TDropTrigStmt \
-TDropUserStmt \
-TDynamicFileList \
-TELEMENT \
-TEState \
-TEdge \
-TErrorMessagePacket \
-TExcContext \
-TExcData \
-TExcDetail \
-TExcFrame \
-TExcId \
-TExcMessage \
-TExcProc \
-TException \
-TExecStatus \
-TExecStatusType \
-TExitStatus \
-TExplainState \
-TExplainStmt \
-TExpr \
-TExprContext \
-TExtendStmt \
-TFILE \
-TFUNMAP \
-TFetchStmt \
-TFile \
-TFileName \
-TFixedItem \
-TFixedItemData \
-TFixedStack \
-TFixedStackData \
-TFjoin \
-TFmgrCall \
-TFmgrInfo \
-TFmgrValues \
-TFont \
-TFormData_pg_aggregate \
-TFormData_pg_am \
-TFormData_pg_amop \
-TFormData_pg_amproc \
-TFormData_pg_attrdef \
-TFormData_pg_attribute \
-TFormData_pg_class \
-TFormData_pg_database \
-TFormData_pg_group \
-TFormData_pg_index \
-TFormData_pg_inherits \
-TFormData_pg_ipl \
-TFormData_pg_language \
-TFormData_pg_listener \
-TFormData_pg_log \
-TFormData_pg_opclass \
-TFormData_pg_operator \
-TFormData_pg_proc \
-TFormData_pg_relcheck \
-TFormData_pg_rewrite \
-TFormData_pg_sequence \
-TFormData_pg_shadow \
-TFormData_pg_statistic \
-TFormData_pg_trigger \
-TFormData_pg_type \
-TFormData_pg_variable \
-TFormData_pg_version \
-TForm_pg_aggregate \
-TForm_pg_am \
-TForm_pg_amop \
-TForm_pg_amproc \
-TForm_pg_attrdef \
-TForm_pg_attribute \
-TForm_pg_class \
-TForm_pg_database \
-TForm_pg_group \
-TForm_pg_index \
-TForm_pg_inherits \
-TForm_pg_ipl \
-TForm_pg_language \
-TForm_pg_log \
-TForm_pg_opclass \
-TForm_pg_operator \
-TForm_pg_proc \
-TForm_pg_relcheck \
-TForm_pg_rewrite \
-TForm_pg_sequence \
-TForm_pg_shadow \
-TForm_pg_statistic \
-TForm_pg_trigger \
-TForm_pg_type \
-TForm_pg_variable \
-TForm_pg_version \
-TFunc \
-TFuncCall \
-TFuncIndexInfo \
-TFuncIndexInfoPtr \
-TFuncInfo \
-TFunction \
-TFunctionCache \
-TFunctionCachePtr \
-TGC \
-TGContext \
-TGISTENTRY \
-TGISTPageOpaque \
-TGISTPageOpaqueData \
-TGISTSTACK \
-TGISTSTATE \
-TGISTScanList \
-TGISTScanListData \
-TGISTScanOpaque \
-TGISTScanOpaqueData \
-TGIST_SPLITVEC \
-TGene \
-TGlobalMemory \
-TGlobalMemoryData \
-TGroup \
-TGroupBuffer \
-TGroupClause \
-TGroupState \
-THASHACTION \
-THASHCTL \
-THHDR \
-THISTORY_STATE \
-THIST_ENTRY \
-THTAB \
-THash \
-THashInfo \
-THashItem \
-THashItemData \
-THashJoin \
-THashJoinState \
-THashJoinTable \
-THashJoinTuple \
-THashJoinTupleData \
-THashMetaPage \
-THashMetaPageData \
-THashPageOpaque \
-THashPageOpaqueData \
-THashPath \
-THashScanList \
-THashScanListData \
-THashScanOpaque \
-THashScanOpaqueData \
-THashState \
-THashTableData \
-THashtFunc \
-THeapAccessStatistics \
-THeapAccessStatisticsData \
-THeapMemoryBlock \
-THeapMemoryBlockData \
-THeapScanDesc \
-THeapScanDescData \
-THeapTuple \
-THeapTupleData \
-THeapTupleHeader \
-THeapTupleHeaderData \
-TINTRANGE \
-TIPCKey \
-TIdList \
-TIdent \
-TIdxInfoRetval \
-TIndDesc \
-TIndInfo \
-TIndex \
-TIndexAttributeBitMap \
-TIndexAttributeBitMapData \
-TIndexElem \
-TIndexInfo \
-TIndexList \
-TIndexPath \
-TIndexScan \
-TIndexScanDesc \
-TIndexScanDescData \
-TIndexScanDescPtr \
-TIndexScanState \
-TIndexStmt \
-TIndexStrategy \
-TIndexStrategyData \
-TIndexTuple \
-TIndexTupleData \
-TInhInfo \
-TInhPaths \
-TInsertIndexResult \
-TInsertIndexResultData \
-TInsertStmt \
-TIntArray \
-TInt_yy_size_t \
-TInt_yy_state_type \
-TInvalidationEntry \
-TInvalidationEntryData \
-TInvalidationMessage \
-TInvalidationMessageData \
-TInvalidationUserData \
-TIpcMemoryId \
-TIpcMemoryKey \
-TIpcSemaphoreId \
-TIpcSemaphoreKey \
-TItem \
-TItemId \
-TItemIdData \
-TItemIdFlags \
-TItemLength \
-TItemOffset \
-TItemPointer \
-TItemPointerData \
-TIter \
-TJoin \
-TJoinExpr \
-TJoinInfo \
-TJoinKey \
-TJoinMethod \
-TJoinPath \
-TJoinState \
-TJunkFilter \
-TKEYMAP_ENTRY \
-TKEYMAP_ENTRY_ARRAY \
-TKeyCode \
-TKeySym \
-TKeymap \
-TLINE \
-TLOCK \
-TLOCKMETHOD \
-TLOCKMETHODCTL \
-TLOCKMETHODTABLE \
-TLOCKMODE \
-TLOCKTAG \
-TLSEG \
-TLargeObjectDesc \
-TLeftistContext \
-TLeftistContextData \
-TLibCCopyLength \
-TList \
-TListenStmt \
-TLoadStmt \
-TLocalInvalid \
-TLocationIndex \
-TLockInfo \
-TLockInfoData \
-TLockRelId \
-TLockStmt \
-TLogRelationContents \
-TLogRelationContentsData \
-TLookupEnt \
-TMASK \
-TMarkData \
-TMask \
-TMaterial \
-TMaterialState \
-TMdfdVec \
-TMemoryContext \
-TMemoryContextData \
-TMemoryContextMethods \
-TMergeInfo \
-TMergeJoin \
-TMergeJoinState \
-TMergeOrder \
-TMergePath \
-TMsgType \
-TName \
-TNameData \
-TNestLoop \
-TNestLoopState \
-TNestPath \
-TNode \
-TNodeTag \
-TNoname \
-TNotifyEvent \
-TNotifyStmt \
-TNumeric \
-TNumericData \
-TNumericDigit \
-TNumericDigitBuf \
-TNumericVar \
-TOffset \
-TOffsetNumber \
-TOid \
-TOpType \
-TOpaque \
-TOpaqueData \
-TOper \
-TOperator \
-TOprInfo \
-TOrderKey \
-TOrderType \
-TOrderedElem \
-TOrderedElemData \
-TOrderedSet \
-TOrderedSetData \
-TOverflowPageAddress \
-TPATH \
-TPGAsyncStatusType \
-TPG_LOCK_LEVEL \
-TPGconn \
-TPGlobjfuncs \
-TPGnotify \
-TPGresAttDesc \
-TPGresAttValue \
-TPGresult \
-TPGresult_data \
-TPOLYGON \
-TPQArgBlock \
-TPQconninfoOption \
-TPQnoticeProcessor \
-TPQprintOpt \
-TPROC \
-TPROC_HDR \
-TPROC_QUEUE \
-TPacket \
-TPacketDoneProc \
-TPacketLen \
-TPacketState \
-TPage \
-TPageHeader \
-TPageHeaderData \
-TPageManagerMode \
-TPageOffset \
-TParam \
-TParamExecData \
-TParamListInfo \
-TParamListInfoData \
-TParamNo \
-TParamString \
-TParseState \
-TPasswordPacket \
-TPasswordPacketV0 \
-TPath \
-TPathOrder \
-TPg_ConnectionId \
-TPg_TclNotifies \
-TPixmap \
-TPlan \
-TPoint \
-TPointer \
-TPool \
-TPort \
-TPortal \
-TPortalBlock \
-TPortalBlockData \
-TPortalBuffer \
-TPortalD \
-TPortalEntry \
-TPortalHashEnt \
-TPortalHeapMemory \
-TPortalMemoryContext \
-TPortalVariableMemory \
-TPredInfo \
-TPrinttupAttrInfo \
-TPrivateMem \
-TProcState \
-TProcedureStmt \
-TProcessingMode \
-TProjectionInfo \
-TProtocolVersion \
-TPsortstate \
-TPsqlSettings \
-TQryHier \
-TQuery \
-TQueryDesc \
-TREAD_ROUTINE \
-TRTSTACK \
-TRTSTATE \
-TRTScanList \
-TRTScanListData \
-TRTreePageOpaque \
-TRTreePageOpaqueData \
-TRTreeScanOpaque \
-TRTreeScanOpaqueData \
-TRangeTblEntry \
-TRangeVar \
-TRecipeStmt \
-TRegProcedure \
-TRelExpr \
-TRelIdCacheEnt \
-TRelNameCacheEnt \
-TRelOptInfo \
-TRelation \
-TRelationBuildDescInfo \
-TRelationData \
-TRelationInfo \
-TRelationInvalidationData \
-TRelationList \
-TRelationPtr \
-TRelativeTime \
-TRelids \
-TRemoveAggrStmt \
-TRemoveFuncStmt \
-TRemoveOperStmt \
-TRemoveStmt \
-TRenameStmt \
-TResTarget \
-TResdom \
-TRestrictInfo \
-TResult \
-TResultState \
-TRetrieveIndexResult \
-TRetrieveIndexResultData \
-TRewriteInfo \
-TRewriteRule \
-TRowMark \
-TRuleLock \
-TRuleStmt \
-TSEGMENT \
-TSEG_OFFSET \
-TSEMA \
-TSHMEM_OFFSET \
-TSHM_QUEUE \
-TSISeg \
-TSISegEntry \
-TSISegOffsets \
-TSLock \
-TSPINLOCK \
-TSPITupleTable \
-TSPLITVEC \
-TScan \
-TScanDirection \
-TScanFunc \
-TScanKey \
-TScanKeyData \
-TScanKeyword \
-TScreen \
-TScreenFormat \
-TSelectStmt \
-TSeqScan \
-TSeqTable \
-TSeqTableData \
-TSharedInvalid \
-TSharedInvalidData \
-TShmemIndexEnt \
-TSigHandler \
-TSize \
-TSnapshot \
-TSnapshotData \
-TSockAddr \
-TSort \
-TSortClause \
-TSortGroupBy \
-TSortState \
-TSplitNumber \
-TStartupPacket \
-TStrategyEvaluation \
-TStrategyEvaluationData \
-TStrategyExpression \
-TStrategyExpressionData \
-TStrategyMap \
-TStrategyMapData \
-TStrategyNumber \
-TStrategyOperator \
-TStrategyOperatorData \
-TStrategyTerm \
-TStrategyTermData \
-TStrategyTransformMap \
-TStrategyTransformMapData \
-TStream \
-TStreamPtr \
-TStringInfo \
-TStringInfoData \
-TSubLink \
-TSubLinkType \
-TSubPlan \
-TSuperQE \
-TSystemPortAddress \
-TTXTRANGE \
-TTableID \
-TTableInfo \
-TTargetEntry \
-TTcl_AppInitProc \
-TTcl_AsyncHandler \
-TTcl_AsyncProc \
-TTcl_CallFrame \
-TTcl_Channel \
-TTcl_ChannelProc \
-TTcl_ChannelType \
-TTcl_CloseProc \
-TTcl_CmdDeleteProc \
-TTcl_CmdInfo \
-TTcl_CmdProc \
-TTcl_CmdTraceProc \
-TTcl_Command \
-TTcl_DString \
-TTcl_DriverBlockModeProc \
-TTcl_DriverCloseProc \
-TTcl_DriverGetHandleProc \
-TTcl_DriverGetOptionProc \
-TTcl_DriverInputProc \
-TTcl_DriverOutputProc \
-TTcl_DriverSeekProc \
-TTcl_DriverSetOptionProc \
-TTcl_DriverWatchProc \
-TTcl_DupInternalRepProc \
-TTcl_EolTranslation \
-TTcl_Event \
-TTcl_EventCheckProc \
-TTcl_EventDeleteProc \
-TTcl_EventProc \
-TTcl_EventSetupProc \
-TTcl_ExitProc \
-TTcl_FileFreeProc \
-TTcl_FileProc \
-TTcl_FreeInternalRepProc \
-TTcl_FreeProc \
-TTcl_HashEntry \
-TTcl_HashSearch \
-TTcl_HashTable \
-TTcl_IdleProc \
-TTcl_Interp \
-TTcl_InterpDeleteProc \
-TTcl_MathProc \
-TTcl_Namespace \
-TTcl_NamespaceDeleteProc \
-TTcl_Obj \
-TTcl_ObjCmdProc \
-TTcl_ObjType \
-TTcl_PackageInitProc \
-TTcl_PathType \
-TTcl_Pid \
-TTcl_QueuePosition \
-TTcl_RegExp \
-TTcl_SetFromAnyProc \
-TTcl_TcpAcceptProc \
-TTcl_Time \
-TTcl_TimerProc \
-TTcl_TimerToken \
-TTcl_Trace \
-TTcl_UpdateStringProc \
-TTcl_Value \
-TTcl_ValueType \
-TTcl_Var \
-TTcl_VarTraceProc \
-TTempRelList \
-TTempTable \
-TTime \
-TTimeADT \
-TTimeInterval \
-TTimeIntervalData \
-TTimeSpan \
-TTk_3DBorder \
-TTk_Anchor \
-TTk_ArgvInfo \
-TTk_BindingTable \
-TTk_Canvas \
-TTk_CanvasTextInfo \
-TTk_ConfigSpec \
-TTk_Cursor \
-TTk_CustomOption \
-TTk_ErrorHandler \
-TTk_ErrorProc \
-TTk_EventProc \
-TTk_FakeWin \
-TTk_Font \
-TTk_FontMetrics \
-TTk_GenericProc \
-TTk_GeomLostSlaveProc \
-TTk_GeomMgr \
-TTk_GeomRequestProc \
-TTk_GetSelProc \
-TTk_Image \
-TTk_ImageChangedProc \
-TTk_ImageCreateProc \
-TTk_ImageDeleteProc \
-TTk_ImageDisplayProc \
-TTk_ImageFileMatchProc \
-TTk_ImageFileReadProc \
-TTk_ImageFileWriteProc \
-TTk_ImageFreeProc \
-TTk_ImageGetProc \
-TTk_ImageMaster \
-TTk_ImageStringMatchProc \
-TTk_ImageStringReadProc \
-TTk_ImageStringWriteProc \
-TTk_ImageType \
-TTk_Item \
-TTk_ItemAreaProc \
-TTk_ItemConfigureProc \
-TTk_ItemCoordProc \
-TTk_ItemCreateProc \
-TTk_ItemCursorProc \
-TTk_ItemDCharsProc \
-TTk_ItemDeleteProc \
-TTk_ItemDisplayProc \
-TTk_ItemIndexProc \
-TTk_ItemInsertProc \
-TTk_ItemPointProc \
-TTk_ItemPostscriptProc \
-TTk_ItemScaleProc \
-TTk_ItemSelectionProc \
-TTk_ItemTranslateProc \
-TTk_ItemType \
-TTk_Justify \
-TTk_LostSelProc \
-TTk_OptionParseProc \
-TTk_OptionPrintProc \
-TTk_PhotoHandle \
-TTk_PhotoImageBlock \
-TTk_PhotoImageFormat \
-TTk_RestrictAction \
-TTk_RestrictProc \
-TTk_SelectionProc \
-TTk_TextLayout \
-TTk_Uid \
-TTk_Window \
-TTransactionId \
-TTransactionState \
-TTransactionStateData \
-TTransactionStmt \
-TTrigger \
-TTriggerData \
-TTriggerDesc \
-TTriggerEvent \
-TTupleBlock \
-TTupleConstr \
-TTupleDesc \
-TTupleTable \
-TTupleTableData \
-TTupleTableSlot \
-TType \
-TTypeBlock \
-TTypeInfo \
-TTypeName \
-TUNDO_LIST \
-TUnique \
-TUniqueState \
-TUnlistenStmt \
-TUpdateStmt \
-TUserAuth \
-TVAttList \
-TVAttListData \
-TVFunction \
-TVPageDescr \
-TVPageDescrData \
-TVPageList \
-TVPageListData \
-TVRelList \
-TVRelListData \
-TVRelStats \
-TVTupleLink \
-TVTupleLinkData \
-TVTupleMove \
-TVTupleMoveData \
-TVacAttrStats \
-TVacuumStmt \
-TValue \
-TVar \
-TVariableCache \
-TVariableCacheData \
-TVariableRelationContents \
-TVariableRelationContentsData \
-TVariableResetStmt \
-TVariableSetStmt \
-TVariableShowStmt \
-TVersionStmt \
-TVfd \
-TViewStmt \
-TVisual \
-TVisualID \
-TWindow \
-TXActivateDeactivateEvent \
-TXActivateEvent \
-TXAnyEvent \
-TXArc \
-TXButtonEvent \
-TXButtonPressedEvent \
-TXButtonReleasedEvent \
-TXChar2b \
-TXCharStruct \
-TXCirculateEvent \
-TXCirculateRequestEvent \
-TXClientMessageEvent \
-TXColor \
-TXColormapEvent \
-TXConfigureEvent \
-TXConfigureRequestEvent \
-TXConnectionWatchProc \
-TXCreateWindowEvent \
-TXCrossingEvent \
-TXDeactivateEvent \
-TXDestroyWindowEvent \
-TXEDataObject \
-TXEnterWindowEvent \
-TXErrorEvent \
-TXErrorHandler \
-TXEvent \
-TXExposeEvent \
-TXExtCodes \
-TXExtData \
-TXFocusChangeEvent \
-TXFocusInEvent \
-TXFocusOutEvent \
-TXFontProp \
-TXFontSet \
-TXFontSetExtents \
-TXFontStruct \
-TXGCValues \
-TXGraphicsExposeEvent \
-TXGravityEvent \
-TXHostAddress \
-TXIC \
-TXICCallback \
-TXICProc \
-TXID \
-TXIDLookupEnt \
-TXIDProc \
-TXIDTAG \
-TXIM \
-TXIMCallback \
-TXIMCaretDirection \
-TXIMCaretStyle \
-TXIMFeedback \
-TXIMHotKeyState \
-TXIMHotKeyTrigger \
-TXIMHotKeyTriggers \
-TXIMPreeditCaretCallbackStruct \
-TXIMPreeditDrawCallbackStruct \
-TXIMPreeditState \
-TXIMPreeditStateNotifyCallbackStruct \
-TXIMProc \
-TXIMResetState \
-TXIMStatusDataType \
-TXIMStatusDrawCallbackStruct \
-TXIMStringConversionCallbackStruct \
-TXIMStringConversionFeedback \
-TXIMStringConversionOperation \
-TXIMStringConversionPosition \
-TXIMStringConversionText \
-TXIMStringConversionType \
-TXIMStyle \
-TXIMStyles \
-TXIMText \
-TXIMValuesList \
-TXIOErrorHandler \
-TXImage \
-TXKeyEvent \
-TXKeyPressedEvent \
-TXKeyReleasedEvent \
-TXKeyboardControl \
-TXKeyboardState \
-TXKeymapEvent \
-TXLeaveWindowEvent \
-TXMapEvent \
-TXMapRequestEvent \
-TXMappingEvent \
-TXModifierKeymap \
-TXMotionEvent \
-TXNoExposeEvent \
-TXOC \
-TXOM \
-TXOMCharSetList \
-TXOMFontInfo \
-TXOMOrientation \
-TXOrientation \
-TXPixmapFormatValues \
-TXPoint \
-TXPointer \
-TXPointerMovedEvent \
-TXPropertyEvent \
-TXRectangle \
-TXReparentEvent \
-TXResizeRequestEvent \
-TXSegment \
-TXSelectionClearEvent \
-TXSelectionEvent \
-TXSelectionRequestEvent \
-TXSetWindowAttributes \
-TXTextItem \
-TXTextItem16 \
-TXTimeCoord \
-TXUnmapEvent \
-TXVaNestedList \
-TXVirtualEvent \
-TXVisibilityEvent \
-TXWindowAttributes \
-TXWindowChanges \
-TXidStatus \
-TXmbTextItem \
-TXwcTextItem \
-TYYSTYPE \
-TYY_BUFFER_STATE \
-TYY_CHAR \
-T_LIB_VERSION_TYPE \
-T_LockId_ \
-T_RuneEntry \
-T_RuneLocale \
-T_RuneRange \
-T_SPI_connection \
-T_SPI_plan \
-T_XPrivDisplay \
-Taclitem \
-Tassoc_list \
-Tbits16 \
-Tbits32 \
-Tbits8 \
-Tbool \
-Tbool16 \
-Tbool32 \
-Tbool8 \
-Tbytea \
-Tcaddr_t \
-Tcat_t \
-Tcc_t \
-Tchar \
-Tclock_t \
-Tclockid_t \
-Tcset \
-Tdaddr_t \
-Tdatetkn \
-Tdev_t \
-Tdhalloc_ptr \
-Tdiv_t \
-Tdouble \
-TevalPlanQual \
-TexecRowMark \
-Texecution_state \
-Tf_smgr \
-Tfd_mask \
-Tfd_set \
-Tfixpt_t \
-Tfloat \
-Tfloat32 \
-Tfloat32data \
-Tfloat4 \
-Tfloat64 \
-Tfloat64data \
-Tfloat8 \
-Tfpos_t \
-Tfunc_ptr \
-Tgid_t \
-Thashnode \
-Tin_addr_t \
-Tin_port_t \
-Tinet \
-Tinet_struct \
-Tino_t \
-Tint \
-Tint16 \
-Tint16_t \
-Tint16m_t \
-Tint2 \
-Tint28 \
-Tint32 \
-Tint32_t \
-Tint32m_t \
-Tint4 \
-Tint64 \
-Tint64_t \
-Tint64m_t \
-Tint8 \
-Tint8_t \
-Tint8m_t \
-Tjmp_buf \
-Tkey_t \
-Tldiv_t \
-Tmacaddr \
-Tmanufacturer \
-Tmode_t \
-Tnlink_t \
-Toff_t \
-Toid8 \
-Tpg_pwd \
-Tpid_t \
-Tpqbool \
-Tpqsigfunc \
-Tptrdiff_t \
-Tqaddr_t \
-Tquad_t \
-Tregex_t \
-Tregister_t \
-Tregmatch_t \
-Tregoff_t \
-Tregproc \
-Trune_t \
-Tsa_family_t \
-Tsegsz_t \
-Tsequence_magic \
-Tsig_atomic_t \
-Tsig_func \
-Tsig_t \
-Tsighandler_cxt \
-Tsigjmp_buf \
-Tsigset_t \
-Tsize_t \
-Tslock_t \
-Tsmgrid \
-Tsocklen_t \
-Tsop \
-Tsopno \
-Tspeed_t \
-Tssize_t \
-Tswblk_t \
-Ttcflag_t \
-Ttcp_seq \
-Ttext \
-Ttime_t \
-Tu_char \
-Tu_int \
-Tu_int16_t \
-Tu_int16m_t \
-Tu_int32_t \
-Tu_int32m_t \
-Tu_int64_t \
-Tu_int64m_t \
-Tu_int8_t \
-Tu_int8m_t \
-Tu_long \
-Tu_quad_t \
-Tu_short \
-Tuch \
-Tuid_t \
-Tuint \
-Tuint16 \
-Tuint32 \
-Tuint8 \
-Tushort \
-Tva_list \
-Tvm_offset_t \
-Tvm_size_t \
-Tvoid \
-Twchar_t \
-Tword16 \
-Tword32 \
-Tword8 \
-Tyy_size_t \
-Tyy_state_type \
/tmp/$$a >/tmp/$$ 2>&1
	if [ "$?" -ne 0 -o -s /tmp/$$ ]
	then	echo "$FILE"
		cat /tmp/$$
	fi
	cat /tmp/$$a |
	sed 's;^/\*\(DATA(.*\)\*/$;\1;' |
	sed 's;/\*---X_X;/* ---;g' |
# workaround indent bug
	sed 's;^static[ 	][ 	]*;static ;g' |
	sed 's;^}[ 	][ 	]*/\*;}   /*;' |
	sed 's;^#endif[ 	][ 	]*/\*;#endif   /*;' |
	detab -t8 -qc |
	entab -t4 -qc |
# move trailing * in function return type
	sed 's;^\([A-Za-z_][^	]*\)[ 	][ 	]*\*$;\1 *;' |
# remove un-needed braces around single statements
	awk '
	{	
			line3 = $0;  
			if (skips > 0)
				skips--;
			if (line1 ~ "		*{$" &&
			    line2 ~ "		*[^;{}]*;$" &&
			    line3 ~ "		*}$")
			{
				print line2;
				line1 = "";
				line2 = "";
				line3 = "";
				skips = 3;
			}
			else
	 			if (skips == 0 && NR >= 3)
					print line1;
			line1 = line2;
			line2 = line3;
			line3 = "";
		}
		END {
			if (skips <= 1)
				print line1;
			if (skips <= 2)
				print line2;
	}' |
#  Move prototype names to the same line as return type.  Useful for ctags. 
#  Indent should do this, but it does not.  It formats prototypes just
#  like real functions.
	awk '	BEGIN	{paren_level = 0}  
	{
		if ($0 ~ /^[a-zA-Z_][a-zA-Z_0-9]*[^\(]*$/)
		{
			saved_len = 0;
			saved_lines[++saved_len] = $0;
			if ((getline saved_lines[++saved_len]) == 0)
				print saved_lines[1];
			else
			if (saved_lines[saved_len] !~ /^[a-zA-Z_][a-zA-Z_0-9]*\(/ ||
			    saved_lines[saved_len] ~  /^[a-zA-Z_][a-zA-Z_0-9]*\(.*\)$/ ||
			    saved_lines[saved_len] ~  /^[a-zA-Z_][a-zA-Z_0-9]*\(.*\);$/)
			{
				print saved_lines[1];
				print saved_lines[2];
			}
			else
			{
				while (1)
				{
					if ((getline saved_lines[++saved_len]) == 0)
						break;
					if (saved_lines[saved_len] ~ /^[^ 	]/ ||
					    saved_lines[saved_len] !~ /,$/)
						break;
				}
				for (i=1; i <= saved_len; i++)
				{
					if (i == 1 && saved_lines[saved_len] ~ /\);$/)
					{
						printf "%s", saved_lines[i];
						if (substr(saved_lines[i], length(saved_lines[i]),1) != "*")
							printf " ";
					}
					else	print saved_lines[i];
				}
			}
		}
		else	print $0;
	}' |
	cat >/tmp/$$ && cat /tmp/$$ >$FILE
done

# The 'for' loop makes these backup files useless so delete them
rm -f *a.BAK
