/usr/share/racket/pkgs/slatex/slatex-wrapper.rkt is in racket-common 6.1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | (module slatex-wrapper scheme/base
(require mzlib/file
scheme/contract
mzlib/process
mzlib/sendevent
scheme/runtime-path
"private/slatex.rkt")
(define-runtime-path here ".")
(provide/contract
[slatex (string? . -> . boolean?)]
[pdf-slatex (string? . -> . boolean?)]
[slatex/no-latex (string? . -> . void?)]
[latex (string? . -> . boolean?)]
[pdf-latex (string? . -> . boolean?)]
[filename->latex-filename (string? . -> . string?)])
(define (add-suffix p s)
(path->string
(bytes->path
(bytes-append
(path->bytes (if (string? p) (string->path p) p)) s))))
(define (filename->latex-filename input-file)
(let* ([norm (normalize-path input-file)])
(cond
[(file-exists? norm) input-file]
[(file-exists? (add-suffix norm #".tex"))
(add-suffix input-file #".tex")]
[else
(error 'filename->latex-filename "~e does not exist" input-file)])))
(define (exec-latex exe file)
(let ([latex-path (find-executable-path exe #f)])
(unless latex-path
(error 'latex "could not find latex binary: ~e" exe))
(system* latex-path file)))
;; latex, pdf-latex : string -> boolean
;; boolean result indicates success
(define-values (latex pdf-latex)
(letrec ([meta-latex
(lambda (pdf?)
(lambda (input-file)
(let ([file (filename->latex-filename input-file)]
[command-name (if pdf?
"pdflatex"
"latex")])
(case (system-type)
[(macos)
(when pdf?
(error 'latex "do not know how to run pdflatex on ~s" (system-type)))
(system "OTEX")
;; boy, wouldn't it be great if the "actv" appleevent worked for OTEX?
;;(send-event "OTEX" "misc" "acvt")
(let* ([build-oztex-locations
(list
(lambda (x)
(build-path x
"Applications"
"OzTeX"
"OzTeX"))
(lambda (x)
(build-path x
"Applications (Mac OS 9)"
"OzTeX"
"OzTeX")))]
[oztex-locations
(apply
append
(map (lambda (f) (map f (filesystem-root-list))) build-oztex-locations))]
[oztex-location (ormap (lambda (x) (if (file-exists? x) x #f)) oztex-locations)])
(when oztex-location
(with-handlers ([void void]) ;; mzscheme cannot handle result
(send-event "MACS" "aevt" "odoc" (vector 'file oztex-location)))))
(send-event "OTEX" "aevt" "odoc" (vector 'file file))
#t]
[(windows) (exec-latex (add-suffix command-name #".exe") file)]
[(unix macosx)
(exec-latex command-name file)]
[else
(error 'latex "do not know how to run ~s on ~s" command-name (system-type))]))))])
(values
(meta-latex #f)
(meta-latex #t))))
(define-values (slatex pdf-slatex)
(letrec ([meta-slatex
(lambda (latex-fun)
(lambda (filename)
(slatex/no-latex filename)
(putenv "TEXINPUTS"
(format "~a:~a"
(path->string here)
(or (getenv "TEXINPUTS") "")))
(latex-fun filename)))])
(values
(meta-slatex latex)
(meta-slatex pdf-latex))))
(define (slatex/no-latex input-file)
(let* ([fixed-file (filename->latex-filename input-file)]
[file (normalize-path fixed-file)])
(let-values ([(base name dir?) (split-path file)])
(parameterize ([current-directory
(if (string? base)
base
(current-directory))])
(slatex::process-main-tex-file (path->string name)))))))
|