Here's just a quick start, will need some time to think about useful enhancements etc.
Code: Select all
Procedure Init()
DataSection
;Data.s Title / Keyword,Search-Criteria,Parameter,Replacement,Parameter,Information,Link / Version,Type
Data.s "Button Up Message","Some Windows-Messages got lost","..."
Data.s "#WM_LBUTTONUP","Case","","",""
Data.i 511,3
Data.s "Sort Constants","No Info","..."
Data.s "PB_Sort_Ascending","SortStructuredArray|SortStructuredList|SortList|SortArray","","PB_Ascending",""
Data.i 511,2
Data.s "Sort Constants","No Info","..."
Data.s "#PB_Sort_Descending","SortStructuredArray|SortStructuredList|SortList|SortArray","","#PB_Descending",""
Data.i 511,2
Data.s "Sort Constants","No Info","..."
Data.s "#PB_Sort_NoCase","SortStructuredArray|SortStructuredList|SortList|SortArray","","#PB_NoCase",""
Data.i 511,2
Data.s "Function Name changed","No Info","..."
Data.s "SoundFrequency(","","","SetSoundFrequency(",""
Data.i 511,2
Data.s "Function Name changed","No Info","..."
Data.s "ResizeEntity(","","1,2,3,4)","ScaleEntity(","1,2,3,4,#PB_Absolute)"
Data.i 511,2
Data.s "Parameter change","No Info","..."
Data.s "FlipBuffers(","","1)","FlipBuffers(",")"
Data.i 440,2
Data.s "Obsolete command","No Info","..."
Data.s "CreateGadgetList(","","","; CreateGadgetList(",""
Data.i 430,2
Data.s ""
EndDataSection
Structure ErrorType
Title.s
Version.i
Type.i
Key.s
KeySearch.s
KeyParam.s
New.s
NewParam.s
Info.s
Link.s
EndStructure
Global Zeile.s
Global NewList Error.ErrorType()
Repeat
Read.s Zeile
If Zeile
AddElement(Error())
With Error()
\Title=Zeile
Read.s \Info
Read.s \Link
Read.s \Key
Read.s \KeySearch
Read.s \KeyParam
Read.s \New
Read.s \NewParam
Read.i \Version
Read.i \Type
EndWith
Else
Break
EndIf
ForEver
Enumeration
;
#CCTypeUnknown;
#CCTypeInfo; No Change needed
#CCTypeNormal; Problem can be solved
#CCTypeAlarm; Problem unsolved
;
#CCInfo
#CCAutoFix
;
#CCFileIn
#CCFileOut
;
EndEnumeration
EndProcedure
Procedure Max(a,b)
If a>b
ProcedureReturn a
Else
ProcedureReturn b
EndIf
EndProcedure
Procedure XCheck(s.s,t.s)
Protected n
Protected flag
n=CountString(t,"|")
If n
While n
flag+FindString(s,StringField(t,n,"|"))
n-1
Wend
ProcedureReturn flag
Else
ProcedureReturn FindString(s,t)
EndIf
EndProcedure
Procedure KCheck(s.s)
Protected pos
ResetList(Error())
While NextElement(Error())
With Error()
pos=FindString(s,LCase(\Key))
If pos
If \KeySearch="" Or XCheck(s,LCase(\KeySearch))
ProcedureReturn pos
EndIf
EndIf
EndWith
Wend
EndProcedure
Procedure CCheck(file.s,version=#Null,mode=#CCInfo)
Protected KeyNr
If FileSize(file)>0
If ReadFile(#CCFileIn,file)
If version=#Null
FileSeek(#CCFileIn,Max(Lof(#CCFileIn)-3000,0))
While Eof(#CCFileIn)=#Null
Zeile=ReadString(#CCFileIn)
If Left(Zeile,25)="; IDE Options = PureBasic"
version=Val(ReplaceString(Trim(Mid(Zeile,26,6)),".",""))
Break
EndIf
Wend
FileSeek(#CCFileIn,0)
EndIf
Debug "Version: "+Str(version)
While Eof(#CCFileIn)=#Null
With Error()
Zeile=ReadString(#CCFileIn)
KeyNr=KCheck(LCase(Zeile))
If KeyNr>0
Debug ""
Debug "ERROR "+\Title+" ("+\Info+")"
Debug Trim(Zeile,#TAB$)
If mode=#CCAutoFix
Select \Type
Case #CCTypeInfo
Debug Mid(Zeile,KeyNr,Len(\Key))+" warning "
Case #CCTypeNormal
Debug Mid(Zeile,KeyNr,Len(\Key))+" >> "+\New
Case #CCTypeAlarm
Debug Mid(Zeile,KeyNr,Len(\Key))+" can't be resolved "
EndSelect
EndIf
EndIf
EndWith
Wend
CloseFile(#CCFileIn)
EndIf
EndIf
EndProcedure
Procedure Main()
Init()
CCheck("SourceCode.pb",#Null,#CCAutoFix)
EndProcedure
Main()
