home *** CD-ROM | disk | FTP | other *** search
- ***************************************************************************
- *
- * Programmname : defcheck.prg
- *
- * Datum : 1992.1.16
- *
- * Autor : INRO
- *
- * Version : 1.00
- *
- * Kurze Programmbeschreibung :
- *
- ***************************************************************************
-
- parameters par1,par2,par3,par4
-
- set exact on
-
- ? "IRH Define Checker Version 2.20"
- ? "IRH Corp. 1992. Freeware."
- ?
-
- if pcount() # 3 .and. pcount() # 4
- ? "Use : DEFCHECK <File> <Org.language> <Checklanguage> [/P]"
- ? "[/P] : Print error"
- quit
- endif
-
- printit = .f.
-
- if pcount() = 4
- par4 = alltrim(upper(par4))
- if par4 # "/P"
- ? "Wrong Option"
- ? "Use : DEFCHECK <File> <Org.language> <Checklanguage> [/P]"
- ? "[/P] : Print error"
- quit
- else
- printit = .t.
- endif
- endif
-
- datei = alltrim(par1)
-
- if "*" $ datei .or. "?" $ datei
- ? "No wildcards allowed"
- quit
- endif
-
- if .not. file(datei)
- ? "File not found"
- quit
- endif
-
- olan = alltrim(upper(par2))
- clan = alltrim(upper(par3))
-
- if olan == clan
- ? "Always look on the bright side of life ...."
- quit
- endif
-
- filelen = filesize(datei)
- fianzbyte = 0
-
- fc = fopen(datei,0)
- if ferror() # 0
- ? " Open Error : " + str(ferror())
- quit
- endif
-
- fseek(fc,0,0)
- if ferror() # 0
- ? " Seek Error : " + str(ferror())
- quit
- endif
- fianzbyte = 0
- aktlen = 0
- string = ""
- tlinenum = 0
- olinenum = 0
- clinenum = 0
- olanlifo = 0
- clanlifo = 0
-
- ? "File checking start "
- ?
-
- do while aktlen <= filelen
- ostring = string
- string = alltrim(readline())
- tlinenum = tlinenum + 1
- @ row(),0 say "Working line : " + alltrim(str(tlinenum))
- @ row(),0 say ""
- if olan $ upper(string) .and. substr(upper(string),1,6) == "#IFDEF"
- olanlifo = fianzbyte - (len(string)+1)
- olinenum = tlinenum - 1
- endif
- if clan $ upper(string) .and. substr(upper(string),1,6) == "#IFDEF"
- clanlifo = fianzbyte - (len(string)+1)
- clinenum = tlinenum - 1
- endif
- if substr(string,1,1) # "*" .and. substr(string,1,1) # "#" .and.;
- len(string) > 0
- if printit
- set print on
- endif
- ?? alltrim(upper(datei)) + "(" + alltrim(str(tlinenum)) + ")" +;
- " Warning : Crazy line found "
- ? " LINE : " + string
- ?
- if printit
- set print off
- endif
- endif
- enddo
-
- ?? "File checking end "
- ?
- if substr(upper(ostring),1,6) == "#ENDIF"
- ?? alltrim(upper(datei)) + " Warning : #ENDIF on last position in File !"
- ?
- endif
-
- if olanlifo = 0
- ?? alltrim(upper(datei)) + " Error : Original language not found"
- ?
- quit
- endif
-
- if clanlifo = 0
- ?? alltrim(upper(datei)) + " Error : Check language not found"
- ?
- quit
- endif
-
- fseek(fc,olanlifo,0)
- if ferror() # 0
- ? " Seek Error : " + str(ferror())
- quit
- endif
- fianzbyte = 0
- aktlen = 0
-
- olanfound = .f.
- string = ""
- oendifs = 0
-
- * @ row(),0 say "Seek for original language ..."
- * ?
- *
- * for i = 1 to olanlifo
- * readline()
- * olinenum = olinenum + 1
- * next
-
- do while aktlen <= filelen
- string = alltrim(readline())
- olinenum = olinenum + 1
- @ row(),0 say "Working line : " + alltrim(str(olinenum))
- @ row(),0 say ""
- if substr(string,1,1) == "*"
- loop
- endif
- if olanfound .and. substr(upper(string),1,6) == "#IFDEF"
- oendifs = oendifs + 1
- endif
- if olan $ upper(string) .and. substr(upper(string),1,6) == "#IFDEF"
- @ row(),0 say "Original language found at " + alltrim(str(olinenum))
- ?
- olanfound = .t.
- endif
- if olanfound .and. substr(upper(string),1,6) == "#ENDIF"
- if oendifs <= 0
- @ row(),0 say "Original language end at " + alltrim(str(olinenum))
- ?
- olanfound = .f.
- exit
- else
- oendifs = oendifs - 1
- endif
- endif
- if olanfound .and. substr(upper(string),1,7) == "#DEFINE"
- if type ("odef") = "U"
- odef = array(1,3)
- else
- aadd(odef,{"","",.f.})
- endif
- oarrlen = len(odef)
- odef [oarrlen,1] = token(string," ",2)
- odef [oarrlen,3] = .f.
- if numat("'",string) > 0
- if printit
- set print on
- endif
- ?? alltrim(upper(datei)) + " Lan: " + olan + " (" + alltrim(str(olinenum)) + ")" +;
- " Error : >'< found "
- ? " DEFINE : " + token(string," ",2)
- ? " STRING : " + hstring
- ?
- if printit
- set print off
- endif
- endif
- i = 3
- hstring = ""
- do while .not. empty(token(string," ",i))
- hstring = hstring + " " + token(string," ",i)
- i ++
- enddo
- hstring = alltrim(hstring)
- if numat("'",string) > 0
- if printit
- set print on
- endif
- ?? alltrim(upper(datei)) + " Lan: " + olan + " (" + alltrim(str(olinenum)) + ")" +;
- " Error : >'< found "
- ? " DEFINE : " + token(string," ",2)
- ? " STRING : " + hstring
- ?
- if printit
- set print off
- endif
- endif
- if hstring = alltrim(str(val(hstring)))
- odef [oarrlen,2] = "N"
- elseif numat(chr(34),hstring) > 0
- if numat(chr(34),hstring) # int(numat(chr(34),hstring)/2)*2
- if printit
- set print on
- endif
- ?? alltrim(upper(datei)) + " Lan: " + olan + " (" + alltrim(str(olinenum)) + ")" +;
- " Error : Unterminated string"
- ? " DEFINE : " + token(string," ",2)
- ? " STRING : " + hstring
- ?
- if printit
- set print off
- endif
- endif
- odef [oarrlen,2] = "S"
- else
- odef [oarrlen,2] = "C"
- endif
- endif
- enddo
-
- if type("odef") = "U"
- ?? alltrim(upper(datei)) + " Warning : No DEFINE found"
- ?
- quit
- endif
-
- ?? "Checking " + clan
- ?
-
- fseek(fc,clanlifo,0)
- if ferror() # 0
- ? " Seek Error : " + str(ferror())
- quit
- endif
- fianzbyte = 0
- aktlen = 0
-
- clanfound = .f.
- string = ""
- cendifs = 0
-
- * @ row(),0 say "Seek for check language ..."
- * ?
- *
- * for i = 1 to clanlifo
- * readline()
- * clinenum = clinenum + 1
- * next
-
- do while aktlen <= filelen
- string = alltrim(readline())
- clinenum = clinenum + 1
- @ row(),0 say "Working line : " + alltrim(str(clinenum))
- @ row(),0 say ""
- if substr(string,1,1) == "*"
- loop
- endif
- if clanfound .and. substr(upper(string),1,6) == "#IFDEF"
- cendifs = cendifs + 1
- endif
- if clan $ upper(string) .and. substr(upper(string),1,6) == "#IFDEF"
- @ row(),0 say "Check language found at " + alltrim(str(clinenum))
- ?
- clanfound = .t.
- endif
- if clanfound .and. substr(upper(string),1,6) == "#ENDIF"
- if cendifs <= 0
- @ row(),0 say "Check language end at " + alltrim(str(clinenum))
- ?
- clanfound = .f.
- exit
- else
- cendifs = cendifs -1
- endif
- endif
- if clanfound .and. substr(upper(string),1,7) == "#DEFINE"
- i = 3
- hstring = ""
- do while .not. empty(token(string," ",i))
- hstring = hstring + " " + token(string," ",i)
- i ++
- enddo
- hstring = alltrim(hstring)
- stringpos = 0
- for i = 1 to len(odef)
- if odef[i,1] == alltrim(token(string," ",2)) .and. .not. odef[i,3]
- stringpos = i
- exit
- endif
- next
- if numat("'",string) > 0
- if printit
- set print on
- endif
- ?? alltrim(upper(datei)) + " Lan: "+ clan+ " (" + alltrim(str(clinenum)) + ")" +;
- " Error : >'< found "
- ? " DEFINE : " + token(string," ",2)
- ? " STRING : " + hstring
- ?
- if printit
- set print off
- endif
- endif
- if stringpos = 0
- if printit
- set print on
- endif
- ?? alltrim(upper(datei)) + " Lan: "+ clan+ " (" + alltrim(str(clinenum)) + ")" +;
- " Warning : Define not in original language "
- ? " DEFINE : " + token(string," ",2)
- ? " STRING : " + hstring
- ?
- if printit
- set print off
- endif
- else
- odef [stringpos,3] = .t.
- if odef[stringpos,2] = "N"
- if hstring # alltrim(str(val(hstring)))
- if printit
- set print on
- endif
- ?? alltrim(upper(datei)) + " Lan: "+ clan+ " (" + alltrim(str(clinenum)) + ")" +;
- " Error : Wrong type found "
- ? " DEFINE : " + token(string," ",2)
- ? " STRING : " + hstring
- ?
- if printit
- set print off
- endif
- endif
- elseif odef[stringpos,2] = "S"
- if hstring = alltrim(str(val(hstring)))
- if printit
- set print on
- endif
- ?? alltrim(upper(datei)) + " Lan: "+ clan+ " (" + alltrim(str(clinenum)) + ")" +;
- " Error : Wrong type found "
- ? " DEFINE : " + token(string," ",2)
- ? " STRING : " + hstring
- ?
- if printit
- set print off
- endif
- elseif numat(chr(34),hstring) > 0
- if numat(chr(34),hstring) # int(numat(chr(34),hstring)/2)*2
- if printit
- set print on
- endif
- ?? alltrim(upper(datei)) + " Lan: "+ clan+ " (" + alltrim(str(clinenum)) + ")" +;
- " Error : Unterminated string"
- ? " DEFINE : " + token(string," ",2)
- ? " STRING : " + hstring
- ?
- if printit
- set print off
- endif
- endif
- else
- if printit
- set print on
- endif
- ?? alltrim(upper(datei)) + " Lan: "+ clan+ " (" + alltrim(str(clinenum)) + ")" +;
- " Error : Wrong type found "
- ? " DEFINE : " + token(string," ",2)
- ? " STRING : " + hstring
- ?
- if printit
- set print off
- endif
- endif
- elseif odef[stringpos,2] = "C"
- if hstring = alltrim(str(val(hstring)))
- if printit
- set print on
- endif
- ?? alltrim(upper(datei)) + " Lan: "+ clan+ " (" + alltrim(str(clinenum)) + ")" +;
- " Error : Wrong type found "
- ? " DEFINE : " + token(string," ",2)
- ? " STRING : " + hstring
- ?
- if printit
- set print off
- endif
- elseif numat(chr(34),hstring) > 0
- if printit
- set print on
- endif
- ?? alltrim(upper(datei)) + " Lan: "+ clan+ " (" + alltrim(str(clinenum)) + ")" +;
- " Error : Wrong type found "
- ? " DEFINE : " + token(string," ",2)
- ? " STRING : " + hstring
- ?
- if printit
- set print off
- endif
- endif
- endif
- endif
- endif
- enddo
-
- for i = 1 to len(odef)
- if .not. odef[i,3]
- if printit
- set print on
- endif
- ?? alltrim(upper(datei)) + " Lan: " + clan +;
- " Error : Define in Checking Language missing "
- ? " DEFINE : " + odef[i,1]
- ?
- if printit
- set print off
- endif
- endif
- next
-
- @ row(),0 say "End of checking "
-
- quit
-
- *-------------------------------------------------------------------------
- *
- *
- *
- * Datum : 1992.1.17
- *
- * Parameter :
- *
- * Returnwert :
- *
- * Aufgerufene Funktionen :
- *
- * Kurze Beschreibung :
- *
- *-------------------------------------------------------------------------
-
- function readline
-
- private string ,char1
-
- string = ""
-
- char1 = freadstr(fc,1)
- fianzbyte = fianzbyte + 1
- aktlen = aktlen + 1
-
- do while char1 # chr(13) .and. aktlen <= filelen
- if asc(char1) > 31
- string = string + char1
- endif
- char1 = freadstr(fc,1)
- fianzbyte = fianzbyte + 1
- aktlen = aktlen + 1
- enddo
-
- return string
-