This file is indexed.

/usr/share/gap/pkg/openmath/gap/pipeobj.g is in gap-openmath 11.3.1+ds-2.

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
###########################################################################
##
#W  pipeobj.g           OpenMath Package                     Andrew Solomon
#W                                                         Marco Costantini
##
#Y    Copyright (C) 1999, 2000, 2001, 2006
#Y    School Math and Comp. Sci., University of St.  Andrews, Scotland
#Y    Copyright (C) 2004, 2005, 2006 Marco Costantini
##
##  Pipe exactly one OpenMath object from <input stream> to 
##  <output string>. 
##


###########################################################################
##
#F  ReadCharSkipSpace( <input> )
##
##  Reads and returns next non-space byte from input stream
##  returning the associated character.
##
BindGlobal("ReadCharSkipSpace", function(input)
	local
		b,	# byte
		c;  # character

	b :=  ReadByte(input);
	while b <> fail and (CHAR_INT(b) in [' ','\n','\t','\r']) do
		 b := ReadByte(input);
	od;
	if b <> fail then	
		return CHAR_INT(b);
	fi;

	return fail;
end);
	
###########################################################################
##
#F  ReadChar( <input> )
##
##  Reads and returns next byte as a character.
##
BindGlobal("ReadChar", function(input)
	local
		b,	# byte
		c;  # character

	b :=  ReadByte(input);
	if b <> fail then	
		return CHAR_INT(b);
	fi;

	return fail;
end);

###########################################################################
##
#F  CharIsSpace( <c> )
##
##  True iff c is a space, newline or tabstop.
##
BindGlobal("CharIsSpace", c -> c in  [' ','\n','\t']);

###########################################################################
##
#F  ReadTag( <input>, <firstbyte> )
##
##  Read a tag of the form < tag >
##  return "<tag>" - no spaces
##
BindGlobal("ReadTag", function(input,firstbyte)
	local
		s,	# the string to return	
		c,  # the character read
		d;	# string to discard: contains encode or comment

	s := "";
	# find the first '<'
    if CHAR_INT(firstbyte) in [' ','\n','\t','\r'] then
		c := ReadCharSkipSpace(input);
	else
	    c := CHAR_INT(firstbyte);	
	fi;
		
    if c <> '<' then
	   return fail;
	fi;   

	s[1] := c;
	c := ReadCharSkipSpace(input);

	# code inserted later to ensure encoding node (i.e <? ... ?>) is ignored 
	# ignore also things like <!-- this is a comment -->
	if c = '?' or c = '!'  then

        d := "";
        repeat
            c := ReadChar( input );
            if c = fail  then
                return fail;
            fi;
            Add( d, c );
        until Length( d ) >= 2 and d{[ Length( d ) - 1 .. Length( d ) ]} = "?>"
          or Length( d ) >= 3 and d{[ Length( d ) - 2 .. Length( d ) ]} = "-->";


		# now find the real beginning of the tag
		s := "";
		c := ReadCharSkipSpace(input);
		if c <> '<' then
			return fail;
		fi;

		s[1] := c;
		c := ReadCharSkipSpace(input);
	fi;

    repeat
        if c = fail  then
            return fail;
        fi;
        Add( s, c );
        c := ReadChar( input );
    until c = '>';
    while CharIsSpace( s[Length(s)] ) do
        Unbind( s[Length(s)] );
    od;
    Add( s, c );
    return s;

end);
	

###########################################################################
##
#F  PipeOpenMathObject( <input>, <output>, <firstbyte> )
##
##  Return "true" if we succeed in piping an OMOBJ from
##  input to output, fail otherwise.
##
##  Based on a very complicated finite state automaton
##  which accepts "<OMOBJ>" then any amount of stuff
##  and terminates with "<\OMOBJ>" unless it is inside
##  a comment "<!-- -->".
##
BindGlobal("PipeOpenMathObject", function(input,output,firstbyte)

	local
		s,	# string
		EndOMOBJstates, # list of states all of which behave almost the same way
		state,	# current state
		nextchar, # the next character we expect
		c;	# the last character read

	# first read " <OMOBJ >"
	s  := ReadTag(input,firstbyte);

	if not (IsList( s ) and Length( s ) > 6 and s{[ 1 .. 6 ]} = "<OMOBJ")  then
		return fail;
	fi;
	Append( output, s );


	EndOMOBJstates:= ["InXMLRead</","InXMLRead</O","InXMLRead</OM",
		"InXMLRead</OMO","InXMLRead</OMOB","InXMLRead</OMOBJ"];

	# start state
	state := "InXML";

	c := ReadChar(input);
	while c <> fail do

		## Start state
		if state =  "InXML" then
			if c = '<' then
				state := "InXMLRead<";
			fi;

		## Read a `<`
		elif state = "InXMLRead<" then
			if c = '!' then
				state := "InXMLRead<!";
			elif c = '/' then
				state := "InXMLRead</";
			elif c <> '<' then # if c = '<' then we stay in this state
				state := "InXML";
			fi; 


		## Read some part of InXMLRead</OMOBJ
		## these states are all dealt with together
		elif state in  EndOMOBJstates then
			if state <> EndOMOBJstates[Length(EndOMOBJstates)] then # this isn't the last one
				nextchar := EndOMOBJstates[Length(EndOMOBJstates)][Length(state)+1];
			else
				nextchar := '>';
				# skip to next nonblank
				while c <> fail and CharIsSpace(c) do
					Append(output, [c]);
					c := ReadChar(input);
				od;
				if c = fail then 
					return fail;
				elif c = nextchar then
					Append(output, [c]);
					return true;
				fi;
			fi;

			if c = nextchar then
				state := Concatenation(state, [nextchar]);
			elif c = '<' then
				state := "InXMLRead<";
			else 
				state := "InXML";
			fi;


		## now on to the comments
		elif state = "InXMLRead<!" then
			if c = '-' then
				state := "InXMLRead<!-";
			elif c = '<' then
				state := "InXMLRead<";
			else
				state := "InXML";
			fi;

		elif state = "InXMLRead<!-" then
			if c = '-' then
				state := "InComment";
			elif c = '<' then
				state := "InXMLRead<";
			else
				state := "InXML";
			fi;


		elif state = "InComment" then
			if c = '-' then
				state := "InComment-";
			fi;

		elif state = "InComment-" then
			if c = '-' then
				state := "InComment--";
			else 
				state := "InComment";
			fi;

		elif state = "InComment--" then
			if c = '>' then
				state := "InXML";
			else 
				state := "InComment";
			fi;

		else
			Error("Invalid state:",state);
		fi;


		# finally send the character off to the output and get the next one
	
		Append(output, [c]);
		c := ReadChar(input);
	od;
	return fail;
end);

###########################################################################
#E