This file is indexed.

/usr/lib/libreoffice/share/extensions/DmathsAddon/OOoGdmath/Fonction.xba is in libreoffice-dmaths 3.4+dfsg1-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
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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Fonction" script:language="StarBasic">&apos;OOoGdmath
&apos;Copyright (C) 2005-2009  Gilles Daurat

&apos;This program is free software; you can redistribute it and/or
&apos;modify it under the terms of the GNU General Public License
&apos;as published by the Free Software Foundation; either version 2
&apos;of the License, or (at your option) any later version.

&apos;This program is distributed in the hope that it will be useful,
&apos;but WITHOUT ANY WARRANTY; without even the implied warranty of
&apos;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
&apos;GNU General Public License for more details.

&apos;You should have received a copy of the GNU General Public License
&apos;along with this program; if not, write to the Free Software
&apos;Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

&apos; Variables pour le trace de fonction

Option Explicit

Dim Operande(0 To 100) As Double
Dim Operateur(0 To 100) As Variant
Dim Coperande(0 To 50) As String
Dim Coperateur(0 To 50) As String

Sub Main
End Sub

Function CalculeFonction(texte$, Defini)
Dim nombre, puissance, i, c

    SupprimeEspace texte$
    RemplaceTexte texte$, &quot;Pi&quot;, Trim(Str(Pi))
    RemplaceTexte texte$, &quot;pi&quot;, Trim(Str(Pi))
    nombre = &quot;&quot;
    ni = 0
    oi = 0
    puissance = 0
    For i = 1 To Len(texte$)
        c = Mid$(texte$, i, 1)
        If (c &gt;= &quot;0&quot; And c &lt;= &quot;9&quot;) Or c = &quot;.&quot; Or c = &quot;,&quot; Or (c = &quot;E&quot; And nombre &lt;&gt; &quot;&quot;) Or (c = &quot;-&quot; And puissance = 1) Then
            If nombre = &quot;*&quot; Then nombre = &quot;&quot;
            If c = &quot;,&quot; Then c = &quot;.&quot;
            nombre = nombre &amp; c
            If c = &quot;E&quot; Then puissance = 1
        Else
            If nombre &lt;&gt; &quot;&quot; And nombre &lt;&gt; &quot;*&quot; Then
                Operande(ni) = val(nombre)
                ni = ni + 1
                nombre = &quot;*&quot;
                puissance = 0
            End If
            If c = &quot;-&quot; And nombre &lt;&gt; &quot;*&quot; Then
                Operateur(oi) = &quot;O&quot;
                oi = oi + 1
                puissance = 0
            Else
                If c = &quot;+&quot; And nombre &lt;&gt; &quot;*&quot; Then
                    Operateur(oi) = &quot;K&quot;
                    oi = oi + 1
                    puissance = 0
                Else
                    If c = &quot;+&quot; Or c = &quot;-&quot; Then
                        &apos; il faut calculer l&apos;operation precedente
                        &apos; et prendre l&apos;oppose si necessaire
                        If oi &gt; 0 Then
                            Do While (InStr(1, &quot;[(=)]&quot;, Operateur(oi - 1)) = 0)
                                CalculeOperation Defini
                                If oi = 0 Then Exit Do
                            Loop
                        End If
                        If oi &gt; 0 Then
                            If Operateur(oi - 1) = &quot;O&quot; Then
                                CalculeOperation Defini
                            End If
                        End If
                        Operateur(oi) = c
                        oi = oi + 1
                        nombre = &quot;&quot;
                    End If
                End If
            End If
            Select Case c
                Case &quot;*&quot;, &quot;/&quot;
                    If oi &gt; 0 Then
                        If Operateur(oi - 1) = &quot;*&quot; Or Operateur(oi - 1) = &quot;/&quot; Then
                            CalculeOperation Defini
                        End If
                    End If
                    Operateur(oi) = c
                    nombre = &quot;&quot;
                    oi = oi + 1
                Case &quot;^&quot;, &quot;¨&quot;
                    If oi &gt; 0 Then
                        If Operateur(oi - 1) = c Then
                            CalculeOperation Defini
                        End If
                    End If
                    nombre = &quot;&quot;
                    Operateur(oi) = c
                    oi = oi + 1
                Case &quot;c&quot;, &quot;C&quot;, &quot;s&quot;, &quot;S&quot;, &quot;T&quot;, &quot;t&quot;, &quot;R&quot;, &quot;r&quot;, &quot;L&quot;, &quot;l&quot;, &quot;E&quot;, &quot;e&quot;
                    Operateur(oi) = c
                    oi = oi + 1
                    If c = &quot;L&quot; Or c = &quot;l&quot; Then i = i - 1
                    i = i + 2
                    nombre = &quot;&quot;
                Case &quot;(&quot;
                    If nombre = &quot;*&quot; Then
                        Operateur(oi) = &quot;*&quot;
                        oi = oi + 1
                    End If
                    nombre = &quot;&quot;
                    Operateur(oi) = c
                    oi = oi + 1
                Case &quot;)&quot;
                    While Operateur(oi - 1) &lt;&gt; &quot;(&quot;
                        CalculeOperation Defini
                    Wend
                    Operateur(oi - 1) = &quot;&quot;
                    oi = oi - 1
&apos;                    If oi &gt; 0 Then
&apos;                        If InStr(1, &quot;cstrle&quot;, Operateur(oi - 1)) &lt;&gt; 0 Then
&apos;                            CalculeOperation Defini
&apos;                        End If
&apos;                    End If
                    nombre = &quot;*&quot;
            End Select
        End If
    Next i
    If nombre &lt;&gt; &quot;&quot; And nombre &lt;&gt; &quot;*&quot; Then
        Operande(ni) = Val(nombre)
        ni = ni + 1
    End If
    While oi &gt; 0
        CalculeOperation Defini
    Wend
    CalculeFonction = Operande(0)
End Function

Sub CalculeOperation(Defini)
Dim ok1, ok2

    If oi &gt; 0 Then
        Select Case Operateur(oi - 1)
            Case &quot;e&quot;, &quot;E&quot;
                If Abs(Operande(ni - 1)) &lt; 700 Then
                    Operande(ni - 1) = Exp(Operande(ni - 1))
                Else
                    Defini = 0
                End If
                Operateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;l&quot;, &quot;L&quot;
                If Operande(ni - 1) &gt; 0 Then
                    Operande(ni - 1) = Log(Operande(ni - 1))
                Else
                    Defini = 0
                End If
                Operateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;r&quot;, &quot;R&quot;
                If Operande(ni - 1) &gt;= 0 Then
                    Operande(ni - 1) = Sqr(Operande(ni - 1))
                Else
                    Defini = 0
                End If
                Operateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;c&quot;, &quot;C&quot;
                Operande(ni - 1) = Cos(Operande(ni - 1))
                Operateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;s&quot;, &quot;S&quot;
                Operande(ni - 1) = Sin(Operande(ni - 1))
                Operateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;t&quot;, &quot;T&quot;
                Operande(ni - 1) = Tan(Operande(ni - 1))
                Operateur(oi) = &quot;&quot;
                oi = oi - 1
            Case &quot;K&quot;
                Operande(ni - 1) = Operande(ni - 1)
                Operateur(oi - 1) = &quot;&quot;
                oi = oi - 1
            Case &quot;O&quot;
                Operande(ni - 1) = -Operande(ni - 1)
                Operateur(oi - 1) = &quot;&quot;
                oi = oi - 1
            Case &quot;¨&quot;
                If Int(Operande(ni - 1)) = Operande(ni - 1) Then
                    If EstPair(Operande(ni - 1)) And Operande(ni - 2) &lt; 0 Then
                        Defini = 0
                    Else
                        Operande(ni - 2) = Sgn(Operande(ni - 2)) * Abs(Operande(ni - 2)) ^ (1 / Operande(ni - 1))
                    End If
                Else
                    If Operande(ni - 1) = 0 Then
                        ok1 = True
                    Else
                        ok1 = EstPair(1 / Operande(ni - 1))
                    End If
                    If Operande(ni - 1) = 1 Then
                        ok2 = True
                    Else
                        ok2 = EstPair((1 / Operande(ni - 1)) - 1)
                    End If
                    If ok1 Then
                        If Operande(ni - 2) &gt; 0 Then
                            Operande(ni - 2) = Operande(ni - 2) ^ (1 / Operande(ni - 1))
                        Else
                            Defini = 0
                        End If
                    Else
                        If ok2 Then
                            Operande(ni - 2) = Sgn(Operande(ni - 2)) * Abs(Operande(ni - 2)) ^ (1 / Operande(ni - 1))
                        Else
                            If Operande(ni - 2) &gt; 0 Then
                                Operande(ni - 2) = Operande(ni - 2) ^ (1 / Operande(ni - 1))
                            Else
                                Defini = 0
                            End If
                        End If
                    End If
                End If
                Operateur(oi) = &quot;&quot;
                oi = oi - 1
                ni = ni - 1
            Case &quot;^&quot;
                If Int(Operande(ni - 1)) = Operande(ni - 1) Then
                    Operande(ni - 2) = Operande(ni - 2) ^ Operande(ni - 1)
                Else
                    If Operande(ni - 1) = 0 Then
                        ok1 = True
                    Else
                        ok1 = EstPair(1 / Operande(ni - 1))
                    End If
                    If Operande(ni - 1) = 1 Then
                        ok2 = True
                    Else
                        ok2 = EstPair((1 / Operande(ni - 1)) - 1)
                    End If
                    If ok1 Then
                        If Operande(ni - 2) &gt; 0 Then
                            Operande(ni - 2) = Operande(ni - 2) ^ Operande(ni - 1)
                        Else
                            Defini = 0
                        End If
                    Else
                        If ok2 Then
                            Operande(ni - 2) = Sgn(Operande(ni - 2)) * Abs(Operande(ni - 2)) ^ Operande(ni - 1)
                        Else
                            If Operande(ni - 2) &gt; 0 Then
                                Operande(ni - 2) = Operande(ni - 2) ^ Operande(ni - 1)
                            Else
                                Defini = 0
                            End If
                        End If
                    End If
                End If
                Operateur(oi) = &quot;&quot;
                oi = oi - 1
                ni = ni - 1
            Case &quot;+&quot;
                Operande(ni - 2) = Operande(ni - 2) + Operande(ni - 1)
                Operateur(oi) = &quot;&quot;
                oi = oi - 1
                ni = ni - 1
            Case &quot;-&quot;
                Operande(ni - 2) = Operande(ni - 2) - Operande(ni - 1)
                Operateur(oi) = &quot;&quot;
                oi = oi - 1
                ni = ni - 1
            Case &quot;*&quot;
                Operande(ni - 2) = Operande(ni - 2) * Operande(ni - 1)
                Operateur(oi) = &quot;&quot;
                oi = oi - 1
                ni = ni - 1
            Case &quot;/&quot;
                If Operande(ni - 1) &lt;&gt; 0 Then
                    Operande(ni - 2) = Operande(ni - 2) / Operande(ni - 1)
                Else
                    Defini = 0
                End If
                Operateur(oi) = &quot;&quot;
                oi = oi - 1
                ni = ni - 1
        End Select
    End If
End Sub

</script:module>