VirtualBox

Changeset 85823 in vbox for trunk/tools/win/vbscript


Ignore:
Timestamp:
Aug 18, 2020 3:57:43 PM (4 years ago)
Author:
vboxsync
Message:

configure.vbs,helpers.vbs: Check the YASN, NASM and OpenWatcom versions. Added StrGetFirstLine, StrGetFirstWord, StrStartsWidth and StrStartsWithI to the helpers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/win/vbscript/helpers.vbs

    r85814 r85823  
    566566
    567567
     568''
     569' Returns the first list of the given string.
     570function StrGetFirstLine(str)
     571   dim off
     572   off = InStr(1, str, Chr(10))
     573   if off <= 0 then off = InStr(1, str, Chr(13))
     574   if off > 0 then
     575      StrGetFirstLine = Mid(str, 1, off)
     576   else
     577      StrGetFirstLine = str
     578   end if
     579end function
     580
     581
     582''
     583' Returns the first word in the given string.
     584'
     585' Only recognizes space, tab, newline and carriage return as word separators.
     586'
     587function StrGetFirstWord(str)
     588   dim strSep, offWord, offEnd, offEnd2, strSeparators
     589   strSeparators = " " & Chr(9) & Chr(10) & Chr(13)
     590
     591   ' Skip leading separators.
     592   for offWord = 1 to Len(str)
     593      if InStr(1, strSeparators, Mid(str, offWord, 1)) < 1 then exit for
     594   next
     595
     596   ' Find the end.
     597   offEnd = Len(str) + 1
     598   for offSep = 1 to Len(strSeparators)
     599      offEnd2 = InStr(offWord, str, Mid(strSeparators, offSep, 1))
     600      if offEnd2 > 0 and offEnd2 < offEnd then offEnd = offEnd2
     601   next
     602
     603   StrGetFirstWord = Mid(str, offWord, offEnd - offWord)
     604end function
     605
     606
     607''
     608' Checks if the string starts with the given prefix (case sensitive).
     609function StrStartsWith(str, strPrefix)
     610   if len(str) >= Len(strPrefix) then
     611      StrStartsWith = (StrComp(Left(str, Len(strPrefix)), strPrefix, vbBinaryCompare) = 0)
     612   else
     613      StrStartsWith = false
     614   end if
     615end function
     616
     617
     618''
     619' Checks if the string starts with the given prefix, case insenstive edition.
     620function StrStartsWithI(str, strPrefix)
     621   if len(str) >= Len(strPrefix) then
     622      StrStartsWithI = (StrComp(Left(str, Len(strPrefix)), strPrefix, vbTextCompare) = 0)
     623   else
     624      StrStartsWithI = false
     625   end if
     626end function
     627
     628
    568629''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    569630'  Helpers: Arrays                                                                                                               '
     
    10511112      if CharIsDigit(Mid(str, i, 1)) <> False then MsgFatal "SelfTest failed: CharIsDigit("&Mid(str, i, 1)&")"
    10521113   next
     1114
    10531115   if StrVersionCompare("1234", "1234") <> 0 then MsgFatal "SelfTest failed: StrVersionCompare #1"
    10541116   if StrVersionCompare("1", "1") <> 0 then MsgFatal "SelfTest failed: StrVersionCompare #2"
     
    10641126   if StrVersionCompare("v1.2.4", "v1.23.4") >= 0 then MsgFatal "SelfTest failed: StrVersionCompare #12"
    10651127   if StrVersionCompare("v10.0.17163", "v10.00.18363") >= 0 then MsgFatal "SelfTest failed: StrVersionCompare #13"
    1066 end sub
    1067 
     1128   if StrVersionCompare("n 2.15.0", "2.12.0") <= 0 then MsgFatal "SelfTest failed: StrVersionCompare #14"
     1129
     1130   if StrGetFirstWord("1") <> "1" then MsgFatal "SelfTest: StrGetFirstWord #1"
     1131   if StrGetFirstWord(" 1 ") <> "1" then MsgFatal "SelfTest: StrGetFirstWord #2"
     1132   if StrGetFirstWord(" 1  2 ") <> "1" then MsgFatal "SelfTest: StrGetFirstWord #3"
     1133   if StrGetFirstWord("1 2") <> "1" then MsgFatal "SelfTest: StrGetFirstWord #4"
     1134   if StrGetFirstWord("1234 5") <> "1234" then MsgFatal "SelfTest: StrGetFirstWord #5"
     1135   if StrGetFirstWord("  ") <> "" then MsgFatal "SelfTest: StrGetFirstWord #6"
     1136end sub
     1137
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette