summaryrefslogtreecommitdiff
path: root/web/lua2dox/lua2dox_filter.bat
blob: a75d2eb67461e056fa088d730fb209f03f1473d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
@echo off

:init

  rem Avoid clobbering anyone else's variables

  setlocal

  rem Safety precaution against awkward paths

  cd /d "%~dp0"
  
:main

  call :set_lua
  if ERRORLEVEL 1 (
    goto :end
  )
  
  set BASENAME=%~n0
  set DIRNAME=%~dp0
  
  set LUASCRIPT=%DIRNAME%\lua2dox.lua %BASENAME%

  if not [%*] == [] (
    echo %*
  )
  %EXE% %LUASCRIPT% %*

  goto :end
  
:set_lua

  call :exe-search texlua
  
  if not defined EXE (
    call :exe-search lua
  )
  
  if not defined EXE (
    echo No Lua interpreter available
    exit /b 1
  )
  
  goto :EOF
  
:exe-search

  set PATHCOPY=%PATH%

:exe-search-loop

  rem Search for a binary

  if defined EXE goto :EOF

  for /f "delims=; tokens=1,2*" %%I in ("%PATHCOPY%") do (
    if exist "%%I\%1.exe" (
      set EXE=%1
    )
    set PATHCOPY=%%J;%%K
  )
  if not "%PATHCOPY%" == ";" goto :exe-search-loop

  exit /b 1

  goto :EOF

:end