This file is indexed.

/usr/share/racket/pkgs/frtime/lang-utils.rkt is in racket-common 6.7-3.

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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
(module lang-utils "lang-core.rkt"
  (require (only-in racket let define-syntax define apply procedure-arity syntax->datum with-input-from-file for-syntax make-empty-namespace cleanse-path collection-path begin syntax-rules)
           (except-in racket
                       else
                       module
                       begin
                       syntax-rules
                       #%app
                       #%top
                       #%datum
                       #%plain-module-begin
                       #%module-begin
                       #%top-interaction
                       λ
                       let
                       define
                       define-syntax
                       define-for-syntax
                       case
                       apply
                       if
                       lambda
                       case-lambda
                       chaperone-procedure
                       free-identifier=?
                       reverse
                       collection-path
                       collection-file-path
                       list-ref
                       require 
                       raise-arity-error
                       procedure-rename
                       impersonate-procedure
                       procedure-reduce-arity
                       procedure-arity
                       procedure->method
                       prop:procedure
                       regexp-replace*
                       provide
                       letrec
                       match
                       cons car cdr pair? null?
                       caar caadr cdar cadar cadr cddr caddr cdddr cadddr cddddr
                       make-struct-type
                       make-struct-field-accessor
                       make-struct-field-mutator
                       vector
                       vector-ref
                       define-struct
                       list
                       list*
                       list?
                       append
                       and
                       or
                       cond when unless
                       map ormap andmap assoc member open-input-file open-output-file open-input-output-file call-with-output-file call-with-input-file with-output-to-file with-input-from-file)
           (rename-in (only-in mzscheme if) [if mzscheme:if])
           (rename-in (only-in "lang-ext.rkt" lift) [lift lift])
           (only-in frtime/core/frp super-lift behavior? value-now)
           (rename-in "lang-ext.rkt"  [undefined undefined])
           (rename-in "lang-ext.rkt" [undefined? undefined?])
           racket/class
           (for-syntax racket/base))
  (require (only-in racket/list empty))
  
  (define-syntax (lifted-send stx)
    (syntax-case stx ()
      [(_ obj meth arg ...)
       (with-syntax ([(obj-tmp) (generate-temporaries '(obj))]
                     [(arg-tmp ...) (generate-temporaries (syntax->list #'(arg ...)))])
         #'(lift #t 
                 (lambda (obj-tmp arg-tmp ...)
                   (send obj-tmp meth arg-tmp ...))
                 obj arg ...))]))
  
  
  (define (list-ref lst idx)
    (if (lift #t positive? idx)
        (list-ref (cdr lst) (lift #t sub1 idx))
        (car lst)))
  
  (define-syntax cond
    (syntax-rules (else =>)
      [(_ [else result1 result2 ...])
       (begin result1 result2 ...)]
      [(_ [test => result])
       (let ([temp test])
         (if temp (result temp)))]
      [(_ [test => result] clause1 clause2 ...)
       (let ([temp test])
         (if temp
             (result temp)
             (cond clause1 clause2 ...)
             (cond clause1 clause2 ...)))]
      [(_ [test]) test]
      [(_ [test] clause1 clause2 ...)
       (let ((temp test))
         (if temp
             temp
             (cond clause1 clause2 ...)
             (cond clause1 clause2 ...)))]
      [(_ [test result1 result2 ...])
       (if test (begin result1 result2 ...))]
      [(_ [test result1 result2 ...]
          clause1 clause2 ...)
       (if test
           (begin result1 result2 ...)
           (cond clause1 clause2 ...)
           (cond clause1 clause2 ...))]))
  
  (define-syntax and
    (syntax-rules ()
      [(_) #t]
      [(_ exp) exp]
      [(_ exp exps ...) (if exp
                            (and exps ...)
                            #f)]))
  
  (define-syntax or
    (syntax-rules ()
      [(_) #f]
      [(_ exp) exp]
      [(_ exp exps ...) (let ([v exp])
                          (if v
                              v
                              (or exps ...)
                              (or-undef exps ...)))]))
  
  
  (define-syntax or-undef
    (syntax-rules ()
      [(_) undefined]
      [(_ exp) (let ([v exp]) (if v v undefined))]
      [(_ exp exps ...) (let ([v exp])
                          (if v
                              v
                              (or-undef exps ...)
                              (or-undef exps ...)))]))
  
  
  
  (define-syntax when
    (syntax-rules ()
      [(_ test body ...) (if test (begin body ...))]))
  
  (define-syntax unless
    (syntax-rules ()
      [(_ test body ...) (if (not test) (begin body ...))]))
  
  (define ormap
    (case-lambda
      [(pred lst) (list-match
                   lst
                   (lambda (a d) (or (pred a) (ormap pred d)))
                   (lambda () #f))]
      [(pred l1 l2) (list-match
                     l1
                     (lambda (a1 d1)
                       (list-match
                        l2
                        (lambda (a2 d2)
                          (or (pred a1 a2) (ormap pred d1 d2)))
                        (lambda ()
                          (error "expected lists of same length, but got" l1 l2))))
                     (lambda ()
                       (list-match
                        l2
                        (lambda (a d)
                          (error "expected lists of same length, but got" l1 l2))
                        (lambda () #f))))]))
  
  (define (andmap proc lst)
    (list-match
     lst
     (lambda (a d) (and (proc a) (andmap proc d)))
     (lambda () #t)))
  
  (define (caar v)
    (car (car v)))
  
  (define (cdar v)
    (cdr (car v)))
  
  (define (cadr v)
    (car (cdr v)))
  
  (define (cadar v)
    (car (cdar v)))
  
  (define (caadr v)
    (car (cadr v)))
  
  (define (cddr v)
    (cdr (cdr v)))
  
  (define (caddr v)
    (car (cddr v)))
  
  (define (cdddr v)
    (cdr (cddr v)))
  
  (define (cadddr v)
    (car (cdddr v)))
  
  (define (cddddr v)
    (cdr (cdddr v)))
  
  (define (split-list acc lst)
    (if (null? (cdr lst))
        (values acc (car lst))
        (split-list (append acc (list (car lst))) (cdr lst))))
  
  (define (all-but-last lst)
    (if (null? (cdr lst))
        '()
        (cons (car lst) (all-but-last (cdr lst)))))
  
  (define frp:apply
    (lambda (fn . args)
      (let* ([first-args (all-but-last args)]
             [last-args (raise-list-for-apply (first (last-pair args)))])
        (super-lift
         (lambda (last-args)
           (apply apply fn (append first-args (cons last-args empty))))
         last-args))))
  
  (define-syntax frp:case
    (syntax-rules ()
      [(_ exp clause ...)
       (let ([v exp])
         (vcase v clause ...))]))
  
  (define-syntax vcase
    (syntax-rules (else)
      [(_ v [else exp ...])
       (begin exp ...)]
      [(_ v [dl exp ...])
       (if (lift #t memv v (quote dl))
           (begin exp ...))]
      [(_ v [dl exp ...] clause ...)
       (if (lift #t memv v (quote dl))
           (begin exp ...)
           (vcase v clause ...))]))
  
  (define map
    (case-lambda
      [(f l) (list-match
              l
              (lambda (a d) (cons (f a) (map f d)))
              (lambda () null))]
      [(f l1 l2) (list-match
                  l1
                  (lambda (a1 d1)
                    (list-match
                     l2
                     (lambda (a2 d2) (cons (f a1 a2) (map f d1 d2)))
                     (lambda () (error "map expected lists of same length but got" l1 l2))))
                  (lambda ()
                    (list-match
                     l2
                     (lambda (a2 d2) (error "map expected lists of same length but got" l1 l2))
                     (lambda () null))))]
      [(f l . ls) (if (and (pair? l) (andmap pair? ls))
                      (cons (apply f (car l) (map car ls)) (apply map f (cdr l) (map cdr ls)))
                      null)]))
  
  
  (define (frp:length lst)
    (cond
      [(pair? lst) (lift #t add1 (frp:length (cdr lst)))]
      [(null? lst) 0]
      [else (error 'length (format "expects list, given ~a" lst))]))
  
  (define (frp:list->string lst)
    (lift #t list->string (raise-reactivity lst)))
  
  (define (reverse lst)
    (let loop ([lst lst] [acc '()])
      (if (pair? lst)
          (loop (cdr lst) (cons (car lst) acc))
          acc)))
  
  ;; This do-nothing function is only here so that frtime programs can
  ;; mark segments of code that shouldn't be optimized in the frtime-opt
  ;; language.  Ironically, frtime-opt has its *own* definition of this
  ;; function; this one is just for source compatibility.
  (define (dont-optimize x) x)
  
  (provide cond 
           and 
           or 
           or-undef 
           when 
           unless
           map
           ormap 
           andmap
           caar
           caadr
           cdar
           cadar
           cadr
           cddr
           caddr
           cdddr
           cadddr
           cddddr
           build-path
           collection-path
           lifted-send
           dont-optimize
           
           list-ref
           (rename-out [frp:case case])
           (rename-out [frp:apply apply])
           (rename-out [frp:length length])
           (rename-out [frp:list->string list->string])
           (rename-out [eq? mzscheme:eq?])
           reverse
           
           (lifted + - * / = 
                   eq? 
                   equal? eqv? < > <= >= 
                   add1 cos sin tan symbol->string symbol?
                   number->string string->symbol eof-object? exp expt even? odd? string-append eval
                   sub1 sqrt not number? string string? zero? min max modulo
                   string->number void? rational? char? char-upcase char-ci>=? char-ci<=?
                   string>=? char-upper-case? char-alphabetic?
                   string<? string-ci=? string-locale-ci>?
                   string-locale-ci<? string-locale-ci=? atan asin acos exact? magnitude imag-part
                   real-part numerator abs log lcm gcd arithmetic-shift integer-sqrt make-rectangular
                   complex? char>? char<? char=?
                   char-numeric? date-time-zone-offset substring string->list
                   string-ci<? string-ci>=? string<=? string-ci<=? string>? string-locale<? string=?
                   string-length string-ref
                   floor angle round
                   ceiling real? date-hour procedure? procedure-arity
                   rationalize date-year-day date-week-day date? date-dst? date-year date-month date-day
                   date-minute date-second make-date char-downcase char>=? char<=? char->integer integer->char boolean?
                   integer? quotient remainder positive? negative? inexact->exact exact->inexact
                   make-polar denominator truncate bitwise-not bitwise-xor bitwise-and bitwise-ior inexact?
                   char-whitespace? assq assv memq memv list-tail
                   seconds->date
                   expand syntax->datum exn-message continuation-mark-set->list exn-continuation-marks
                   exn:fail? regexp-match
                   vector->list list->vector make-vector)
           
           
           make-exn:fail  current-inspector make-inspector
           make-empty-namespace namespace? namespace-symbol->identifier namespace-variable-value
           namespace-set-variable-value! namespace-undefine-variable! namespace-mapped-symbols
           parameterize current-seconds current-milliseconds current-inexact-milliseconds
           call-with-values make-parameter
           null
           gensym collect-garbage
           error set! printf fprintf current-error-port for-each void
           procedure-arity-includes? raise-type-error raise thread
           current-continuation-marks
           raise-mismatch-error for-syntax define-syntax define-syntaxes syntax-rules syntax-case
           (lifted:nonstrict format)
           print-struct
           define
           let
           let*
           values
           let*-values           
           let-values
           define-values
           begin
           begin0
           quote
           quasiquote
           unquote
           unquote-splicing
           
           syntax
           let/ec
           with-handlers
           unsyntax
           current-security-guard
           make-security-guard
           dynamic-require
           path? complete-path? absolute-path? relative-path? path-string?
           path->complete-path
           string->path path->string
           bytes->path path->bytes
           split-path simplify-path normal-case-path cleanse-path resolve-path
           path-replace-suffix
           current-directory
           exit
           system-type 
           unsyntax-splicing 
           
           delay
           force
           random
           sleep
           read-case-sensitive
           file-exists?
           with-input-from-file
           read)
  
  ; from core
  (provide (all-from-out "lang-core.rkt"))
  
  )