From b9fe019c5bf5834ebee845b47654f6d6967cda28 Mon Sep 17 00:00:00 2001 From: Siep Kroonenberg Date: Fri, 10 Oct 2008 10:21:54 +0000 Subject: dviout.vbs: better version test; svn propset svn:eol-style CRLF git-svn-id: svn://tug.org/texlive/trunk@10911 c570f23f-e606-0410-a88d-b1316a301751 --- Master/bin/win32/dviout.vbs | 261 ++++++++++++++++++++++---------------------- 1 file changed, 132 insertions(+), 129 deletions(-) (limited to 'Master') diff --git a/Master/bin/win32/dviout.vbs b/Master/bin/win32/dviout.vbs index 3c271499cd5..0d76d711211 100644 --- a/Master/bin/win32/dviout.vbs +++ b/Master/bin/win32/dviout.vbs @@ -1,130 +1,133 @@ -' Call dviout with an optional dvi-file parameter -' and font search configuration parameters. - -option explicit -On Error Resume Next - -dim oWsh, oEnv, oFS, oArgs, oExec, sTmp, bFirst -Dim sTL, oTL, sGS, sCmd, oTmp, i, s - -set oWsh = wscript.createobject( "wscript.Shell" ) -Set oArgs = wscript.Arguments -Set oEnv = oWsh.Environment( "PROCESS" ) -Set oFS = CreateObject("Scripting.FileSystemObject") - -If wscript.version < 5.6 Then - MsgBox "Need VBScript 5.6 or later. Aborting...", vbOKOnly+vbCritical, "Error" - Wscript.Quit -Else - sTmp = "" - ' ask kpathsea - Set oExec = oWsh.Exec("kpsewhich -var-value=SELFAUTOPARENT") - sTmp = oExec.StdOut.ReadLine - Err.clear() - If sTmp <> "" then - sTL = replace(sTmp, "/", "\") - End If -End If -If sTL = "" Then - MsgBox "TeX Live not found; aborting...", vbOKOnly+vbCritical, "Error" - wscript.quit -End If -If InStr(sTL, " ") <> 0 Then - Set oTL = oFS.GetFolder(sTL) - sTL = oTL.ShortPath -End If - -'strip trailing "\" -If Right(sTL,1) = "\" Then - sTL = Left(sTL,Len(sTL)-1) -End If - -' Ghostscript environment settings -sGS = sTL & "\tlpkg\tlgs" -oEnv("PATH") = sGS & "\bin;" & oEnv("PATH") -oEnv("GS_LIB") = sGS & "\fonts;" & sGS & "\lib;" & sGS & "\Resource" - -sCmd = sTL & "\tlpkg\dviout\dviout.exe -TEXROOT=" - -'add font trees to command-Line - -'first make sure %TEXMFVAR%\fonts exists -sTmp = "" -' ask kpathsea -Set oExec = oWsh.Exec("kpsewhich -var-value=TEXMFVAR") -sTmp = oExec.StdOut.ReadLine -If Not oFS.FolderExists(sTmp) Then - s = oFS.GetParentFolderName(sTmp) - If Not oFS.FolderExists(s) Then - Err.clear() - oFS.CreateFolder(s) - If Not oFS.FolderExists(s) Then - MsgBox "No place to put bitmaps; aborting...", _ - vbOKOnly+vbCritical, "Error" - wscript.quit - End If - End If - oFS.CreateFolder(sTmp) - If Not oFS.FolderExists(sTmp) Then - MsgBox "No place to put bitmaps; aborting...", _ - vbOKOnly+vbCritical, "Error" - wscript.quit - End If -End If -If Not oFS.FolderExists(sTmp & "\fonts") Then - Err.clear() - oFS.CreateFolder(sTmp & "\fonts") - If Not oFS.FolderExists(sTmp & "\fonts") Then - MsgBox "No place to put bitmaps; aborting...", _ - vbOKOnly+vbCritical, "Error" - wscript.quit - End If -End If - - -Set oExec = oWsh.Exec("kpsewhich -show-path=tfm") -sTmp = oExec.StdOut.ReadLine -bFirst = True -For Each s in Split(sTmp, ";", -1, 1) - s = Trim(s) - If s<>"." Then - If InStr(s, "!!")=1 Then - s = Mid(s, 3) - End If - i = InStr(s, "/fonts/tfm") - If i<>0 then - s = Mid(s, 1, i+5) - Else - s="" - End If - s = Trim(s) - If s<>"" then - s = replace(s, "/", "\") - If oFS.FolderExists(s) Then - If InStr(s," ")<>0 Then - Set oTmp = oFS.GetFolder(s) - s = oTmp.ShortPath - End If - If Not bFirst Then - sCmd=sCmd & ";" - Else - bfirst=False - End If - sCmd = sCmd & s - End If - End If - End If -Next -sCmd = sCmd & " -TEXPK=""^r\pk\\^s.^dpk;^r\tfm\\^s^tfm;" & _ - "^r\vf\\^s.vf;^r\ovf\\^s.ovf;^r\tfm\\^s.tfm""" - -' assume argument either short or already quoted -If (oArgs.length > 0) Then - For i = 0 To (oArgs.length - 1) Step 1 - sCmd = sCmd & " " & oArgs(i) - Next -End If - -' 2nd arg 1: normal window -oWsh.run sCmd, 1 +' Call dviout with an optional dvi-file parameter +' and font search configuration parameters. + +option explicit +On Error Resume Next + +dim oWsh, oEnv, oFS, oArgs, oExec, sTmp, bFirst +Dim sTL, oTL, sGS, sCmd, oTmp, i, s + +set oWsh = wscript.createobject( "wscript.Shell" ) +Set oArgs = wscript.Arguments +Set oEnv = oWsh.Environment( "PROCESS" ) +Set oFS = CreateObject("Scripting.FileSystemObject") + +s = Left (wscript.version, 3) +s = replace (s, ".", "") +i = CInt(s) +If i < 56 Then + MsgBox "Need VBScript 5.6 or later. Aborting...", vbOKOnly+vbCritical, "Error" + Wscript.Quit +Else + sTmp = "" + ' ask kpathsea + Set oExec = oWsh.Exec("kpsewhich -var-value=SELFAUTOPARENT") + sTmp = oExec.StdOut.ReadLine + Err.clear() + If sTmp <> "" then + sTL = replace(sTmp, "/", "\") + End If +End If +If sTL = "" Then + MsgBox "TeX Live not found; aborting...", vbOKOnly+vbCritical, "Error" + wscript.quit +End If +If InStr(sTL, " ") <> 0 Then + Set oTL = oFS.GetFolder(sTL) + sTL = oTL.ShortPath +End If + +'strip trailing "\" +If Right(sTL,1) = "\" Then + sTL = Left(sTL,Len(sTL)-1) +End If + +' Ghostscript environment settings +sGS = sTL & "\tlpkg\tlgs" +oEnv("PATH") = sGS & "\bin;" & oEnv("PATH") +oEnv("GS_LIB") = sGS & "\fonts;" & sGS & "\lib;" & sGS & "\Resource" + +sCmd = sTL & "\tlpkg\dviout\dviout.exe -TEXROOT=" + +'add font trees to command-Line + +'first make sure %TEXMFVAR%\fonts exists +sTmp = "" +' ask kpathsea +Set oExec = oWsh.Exec("kpsewhich -var-value=TEXMFVAR") +sTmp = oExec.StdOut.ReadLine +If Not oFS.FolderExists(sTmp) Then + s = oFS.GetParentFolderName(sTmp) + If Not oFS.FolderExists(s) Then + Err.clear() + oFS.CreateFolder(s) + If Not oFS.FolderExists(s) Then + MsgBox "No place to put bitmaps; aborting...", _ + vbOKOnly+vbCritical, "Error" + wscript.quit + End If + End If + oFS.CreateFolder(sTmp) + If Not oFS.FolderExists(sTmp) Then + MsgBox "No place to put bitmaps; aborting...", _ + vbOKOnly+vbCritical, "Error" + wscript.quit + End If +End If +If Not oFS.FolderExists(sTmp & "\fonts") Then + Err.clear() + oFS.CreateFolder(sTmp & "\fonts") + If Not oFS.FolderExists(sTmp & "\fonts") Then + MsgBox "No place to put bitmaps; aborting...", _ + vbOKOnly+vbCritical, "Error" + wscript.quit + End If +End If + + +Set oExec = oWsh.Exec("kpsewhich -show-path=tfm") +sTmp = oExec.StdOut.ReadLine +bFirst = True +For Each s in Split(sTmp, ";", -1, 1) + s = Trim(s) + If s<>"." Then + If InStr(s, "!!")=1 Then + s = Mid(s, 3) + End If + i = InStr(s, "/fonts/tfm") + If i<>0 then + s = Mid(s, 1, i+5) + Else + s="" + End If + s = Trim(s) + If s<>"" then + s = replace(s, "/", "\") + If oFS.FolderExists(s) Then + If InStr(s," ")<>0 Then + Set oTmp = oFS.GetFolder(s) + s = oTmp.ShortPath + End If + If Not bFirst Then + sCmd=sCmd & ";" + Else + bfirst=False + End If + sCmd = sCmd & s + End If + End If + End If +Next +sCmd = sCmd & " -TEXPK=""^r\pk\\^s.^dpk;^r\tfm\\^s^tfm;" & _ + "^r\vf\\^s.vf;^r\ovf\\^s.ovf;^r\tfm\\^s.tfm""" + +' assume argument either short or already quoted +If (oArgs.length > 0) Then + For i = 0 To (oArgs.length - 1) Step 1 + sCmd = sCmd & " " & oArgs(i) + Next +End If + +' 2nd arg 1: normal window +oWsh.run sCmd, 1 'wscript.echo sCmd \ No newline at end of file -- cgit v1.2.3