This file is indexed.

/usr/share/maxima/5.32.1/src/mrgmac.lisp is in maxima-src 5.32.1-1.

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
;;; -*-  Mode: Lisp; Package: Maxima; Syntax: Common-Lisp; Base: 10 -*- ;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;     The data in this file contains enhancments.                    ;;;;;
;;;                                                                    ;;;;;
;;;  Copyright (c) 1984,1987 by William Schelter,University of Texas   ;;;;;
;;;     All rights reserved                                            ;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;     (c) Copyright 1980 Massachusetts Institute of Technology         ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(in-package :maxima)

(macsyma-module mrgmac macro)

(defun zl-get (sym tag)
  (cond ((symbolp sym) (get sym tag))
	((consp sym) (getf (cdr sym) tag))))

(defun define-macro (name lambda-exp)
  (cond ((symbolp lambda-exp)
	 (setq lambda-exp (symbol-function lambda-exp))))
  (setf (macro-function name) lambda-exp))

(declare-top (special name bas selector))

(defvar *mobjects* nil)

(defprop mode (c-mode s-mode a-mode) mode)

(defmacro c-mode (&rest l)
  `(list ,@l))

(defmacro s-mode (&rest x)
  (push 's-mode x)
  (cond ((eq 'c (third x)) `(first ,(second x)))
	((eq 'sel (third x)) `(second ,(second x)))
	((eq 'push+sto (third x)) `(third ,(second x)))))

(defmacro a-mode (&rest x)
  (push 'a-mode x)
  (cond ((eq 'c (third x)) `(rplaca (second x) ,(fourth x)))
	((eq 'sel (third x)) `(rplaca (cdr ,(second x)) ,(fourth x)))
	((eq 'push+sto (third x)) `(rplaca (cddr ,(second x)) ,(fourth x)))))

(defmacro defmode (&rest x)
  (push 'defmode x)
  (let ((selector (member 'selector (cddddr x) :test #'eq)))
    (define-mode (second x) (fourth x))
    (mapc 'eval (cddddr x))
    `',(second x)))

(defun define-mode (name desc)
  (let ((c (intern (format nil "C-~A" name)))
	(s (intern (format nil "S-~A" name)))
	(a (intern (format nil "A-~A" name))))
    (define-macro c (defc desc))
    (define-macro s (defs desc))
    (define-macro a (defa desc))
    (putprop name (c-mode c s a) 'mode)))

(defun defc (desc)
  (let ((bas 'x))
    (coerce `(lambda (x &optional env)
	      (declare (ignore env))
	      ,(defc1 desc))
	    'function)))

(defun defc1 (desc)
  (cond ((atom desc) (list 'quote desc))
	((eq 'selector (car desc))
	 (cond ((not (null (cdddr desc))) (list 'quote (fourth desc)))
	       (t (setq bas (list 'cdr bas))
		  (list 'car bas))))
	((eq (quote atom) (car desc))
	 `(list 'c-atom '',(mapcar 'second (cdr desc)) (cons (quote list) (cdr x))))
	((eq 'cons (car desc)) `(list 'cons ,(defc1 (second desc)) ,(defc1 (third desc))))
	((eq (quote list) (car desc))
	 (do ((l (cdr desc) (cdr l)) (nl))
	     ((null l) `(list (quote list) ,@(nreverse nl)))
	   (push (defc1 (car l)) nl)))
	((eq 'struct (car desc)) (defc1 (cons (quote list) (cdr desc))))
	(t (list 'quote desc))))


(defun defs (desc)
  (coerce `(lambda (x &optional env)
	    (declare (ignore env))
	    (cond ,@(nreverse (defs1 desc '(second x) nil))))
	  'function ))

(defun defs1 (desc bas result)
  (cond ((atom desc) result)
	((eq 'selector (car desc))
	 (putprop (second desc)
	      (cons (cons name (third desc)) (zl-get (second desc) 'modes))
	      'modes)
	 (putprop name
	      (cons (cons (second desc) (third desc)) (zl-get name 'sels))
	      'sels)
	 (if selector (define-macro (second desc) 'selector))
	 (cons `((eq ',(second desc) (third x)) ,bas) result))
	((eq (quote atom) (car desc))
	 (do ((l (cdr desc) (cdr l))) ((null l))
	   (putprop (cadar l) (cons (cons name (caddar l))
				(zl-get (cadar l) 'modes)) 'modes)
	   (putprop name (cons (cons (cadar l) (caddar l))
			   (zl-get name 'sels)) 'sels)
	   (if selector (define-macro (cadar l) 'selector)))
	 (cons `((member (third x) ',(mapcar 'second (cdr desc)) :test #'eq)
		 (list 'zl-get ,bas (list 'quote (third x))))
	       result))
	((eq 'cons (car desc))
	 (setq result (defs1 (second desc) `(list 'car ,bas) result))
	 (defs1 (third desc) `(list 'cdr ,bas) result))
	((eq (quote list) (car desc))
	 (do ((l (cdr desc) (cdr l))) ((null l))
	   (setq result (defs1 (car l) `(list 'car ,bas) result)
		 bas `(list 'cdr ,bas)))
	 result)
	((eq 'struct (car desc)) (defs1 (cons (quote list) (cdr desc)) bas result))
	(t result)))

(defun defa (desc)
  (coerce `(lambda (x &optional env)
	    (declare (ignore env))
	    (cond ,@(nreverse (defa1 desc '(second x) nil nil))))
	  'function))

(defun defa1 (desc bas cdr result)
  (cond ((atom desc) result)
	((eq 'selector (car desc))
	 (setq bas (cond ((not cdr) `(list 'car (list 'rplaca ,(third bas) (fourth x))))
			 (t `(list 'cdr (list 'rplacd ,(third bas) (fourth x))))))
	 (cons `((eq ',(second desc) (third x)) ,bas) result))
	((eq  (quote atom) (car desc))
	 (list `(t (list 'cput (second x) (fourth x) (list 'quote (third x))))))
	((eq 'cons (car desc))
	 (setq result (defa1 (second desc) `(list 'car ,bas) nil result))
	 (defa1 (third desc) `(list 'cdr ,bas) t result))
	((eq (quote list) (car desc))
	 (do ((l (cdr desc) (cdr l))) ((null l))
	   (setq result (defa1 (car l) `(list 'car ,bas) nil result)
		 bas `(list 'cdr ,bas)))
	 result)
	((eq 'struct (car desc)) (defa1 (cons (quote list) (cdr desc)) bas cdr result))
	(t result)))


(defun mode (x)
  (cdr (assoc x *mobjects* :test #'equal)))

(defmacro modedeclare (&rest l)
  `(modeclare-internal ',l))

(defun modedeclare-internal (x)
  (mapc #'(lambda (l)
	    (mapc #'(lambda (v) (push (cons v (car l)) *mobjects*))
		  (cdr l)))
	x))

(defmacro sel (&rest x)
  (push 'sel x )
  (let ((s (fsel (mode (second x)) (cddr x))))
    (cond ((null s) (merror "SEL: ~a ~a" (second x) (cddr x)))
	  (t (setq x (second x))
	     (do ()
		 ((null (cdr s)) x)
	       (setq x (cons (second (zl-get (car s) 'mode)) (rplaca s x))
		     s (cddr s))
	       (rplacd (cddr x) nil))))))

(defun fsel (m sels) ;;This has a bug in it.
  (cond ((null sels) (list m))
	((null m)
	 (do ((l (zl-get (car sels) 'modes) (cdr l)))
	     ((null l))
	   (if (setq m (fsel (cdar l) (cdr sels)))
	       (return (cons (caar l) (cons (car sels) m))))))
	((let (dum)
	   (if (setq dum (assoc (car sels) (zl-get m 'sels) :test #'eq))
	       (cons m (cons (car sels) (fsel (cdr dum) (cdr sels)))))))
	(t (do ((l (zl-get m 'sels) (cdr l)) (dum))
	       ((null l))
	     (if (setq dum (fsel (cdar l) sels))
		 (return (cons m (cons (caar l) dum))))))))

(defun selector (x env)
  (declare (ignore env))
  (if (null (cddr x))
      `(sel ,(second x) ,(car x))
      `(push+sto (sel ,(second x) ,(car x)) ,(third x))))

(defmacro push+sto (&rest x)
  (push 'push+sto x )
  `(sto ,@(cdr x)))

(defmacro sto (&rest x)
  (push ' sto x )
  (do ((l (cdr x) (cddr l))
       (s)
       (nl))
      ((null l) `(progn ,@(nreverse nl)))
    (cond ((atom (car l))
	   (push `(setq ,(first l) ,(second l)) nl))
	  ((and (eq 'sel (caar l)) (setq s (fsel (mode (cadar l)) (cddar l))))
	   (setq x (cadar l))
	   (do ((l (cddr s) (cddr l)))
	       ((null (cdr l)))
	     (setq x (cons (second (zl-get (first l) 'mode)) (rplaca l x)))
	     (rplacd (cddr x) nil))
	   (push (list (third (zl-get (first s) 'mode)) x (second s) (second l)) nl))
	  (t (merror "STO: ~a" (car l))))))

(defmacro cons-exp (op &rest args)
  `(simplify (list (list ,op) ,@args)))

;; Local Modes:
;; Mode: LISP
;; Comment Col: 40
;; End: