This file is indexed.

/usr/share/gap/lib/kernel.g is in gap-libs 4r6p5-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
#############################################################################
##
#W  kernel.g                    GAP library                  Martin Schönert
##
##
#Y  Copyright (C)  1996,  Lehrstuhl D für Mathematik,  RWTH Aachen,  Germany
#Y  (C) 1998 School Math and Comp. Sci., University of St Andrews, Scotland
#Y  Copyright (C) 2002 The GAP Group
##
##  This file contains function that should be in the kernel of GAP.
##  Actually it now just contains some utilities needed very early in
##  the bootstrap.
##


#############################################################################
##
#F  ADD_LIST_DEFAULT( <list>, <obj> ) . . . . . .  add an element to the list
##
##  <ManSection>
##  <Func Name="ADD_LIST_DEFAULT" Arg='list, obj'/>
##
##  <Description>
##  </Description>
##  </ManSection>
##
ADD_LIST_DEFAULT := function ( list, obj )
    list[ LEN_LIST(list)+1 ] := obj;
end;



#############################################################################
##
#F  AS_LIST_SORTED_LIST( <list> ) . . . . . . . . . . . . . . setify the list
##
##  <ManSection>
##  <Func Name="AS_LIST_SORTED_LIST" Arg='list'/>
##
##  <Description>
##  </Description>
##  </ManSection>
##
AS_LIST_SORTED_LIST := function ( list )
    local   new;
    if not IS_MUTABLE_OBJ( list ) and IS_SSORT_LIST( list ) then
        new := list;
    else
        new := IMMUTABLE_COPY_OBJ( LIST_SORTED_LIST( list ) );
    fi;
    return new;
end;

#############################################################################
##
#F  Ordinal( <n> )  . . . . . . . . . . . . . ordinal of an integer as string
##
##  <#GAPDoc Label="Ordinal">
##  <ManSection>
##  <Func Name="Ordinal" Arg='n'/>
##
##  <Description>
##  returns the ordinal of the integer <A>n</A> as a string.
##  <Example><![CDATA[
##  gap> Ordinal(2);  Ordinal(21);  Ordinal(33);  Ordinal(-33);
##  "2nd"
##  "21st"
##  "33rd"
##  "-33rd"
##  ]]></Example>
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
##
Ordinal := function ( n )
    local   str;

    str := SHALLOW_COPY_OBJ(STRING_INT(n));
    if n < 0 then n := -n; fi;
    if   n mod 10 = 1  and n mod 100 <> 11  then
        APPEND_LIST_INTR( str, "st" );
    elif n mod 10 = 2  and n mod 100 <> 12  then
        APPEND_LIST_INTR( str, "nd" );
    elif n mod 10 = 3  and n mod 100 <> 13  then
        APPEND_LIST_INTR( str, "rd" );
    else
        APPEND_LIST_INTR( str, "th" );
    fi;
    return str;
end;


#############################################################################
##
#F  IS_SUBSTRING( <str>, <sub> )  . . . . . . . . .  check if <sub> is prefix
##
##  <ManSection>
##  <Func Name="IS_SUBSTRING" Arg='str, sub'/>
##
##  <Description>
##  </Description>
##  </ManSection>
##
IS_SUBSTRING := function( str, sub )
  if LEN_LIST(sub) > 0 and POSITION_SUBSTRING(str, sub, 0) = fail then
    return false;
  else
    return true;
  fi;
end;


#############################################################################
##
#F  STRING_LOWER( <str> ) . . . . . . . . . convert to lower, remove specials
##
##  <ManSection>
##  <Func Name="STRING_LOWER" Arg='str'/>
##
##  <Description>
##  <!-- seems obsolete now? (FL) -->
##  </Description>
##  </ManSection>
##
STRING_LOWER_TRANS := 0;

STRING_LOWER := function( str )
  local i, res;
  if STRING_LOWER_TRANS = 0 then
    STRING_LOWER_TRANS := "";
    for i in [0..255] do 
      STRING_LOWER_TRANS[i+1] := CHAR_INT(i);
    od;
    STRING_LOWER_TRANS{1+[65..90]} := STRING_LOWER_TRANS{1+[97..122]};
    STRING_LOWER_TRANS{1+[33,126]} := "  ";
  fi;
  res := SHALLOW_COPY_OBJ(str);
  TranslateString(res, STRING_LOWER_TRANS);
  return res;
end;


#############################################################################
##
#F  POSITION_NOT( <list>, <val> [,<from-minus-one>] ) . . . .  find not <val>
##
##  <ManSection>
##  <Func Name="POSITION_NOT" Arg='list, val [,from-minus-one]'/>
##
##  <Description>
##  </Description>
##  </ManSection>
##
POSITION_NOT := function( arg )
    local i;

    if LENGTH(arg) = 2  then
        for i  in [ 1 .. LENGTH(arg[1]) ]  do
            if arg[1][i] <> arg[2] then
                return i;
            fi;
        od;
        return LENGTH(arg[1]) + 1;

    elif LENGTH(arg) = 3 then
        for i  in [ arg[3]+1 .. LENGTH(arg[1]) ]  do
            if arg[1][i] <> arg[2] then
                return i;
            fi;
        od;
        return LENGTH(arg[1]) + 1;

    else
      Error( "usage: PositionNot( <list>, <val>[, <from>] )" );
    fi;

end;

#############################################################################
##
#F  Runtimes() . . . . . . . . self-explaining version of result of RUNTIMES()
##
##  <ManSection>
##  <Func Name="Runtimes" Arg=''/>
##
##  <Description>
##  </Description>
##  </ManSection>
##
Runtimes := function()
  local res, rt, cmp, a, i;
  res := rec();
  rt := RUNTIMES();
  cmp := ["user_time", "system_time", 
          "user_time_children", "system_time_children"]; 
  if IS_INT(rt) then
    for a in cmp do 
      res.(a) := fail;
    od;
    res.(cmp[1]) := rt;
  else
    for i in [1..4] do
      res.(cmp[i]) := rt[i];
    od;
  fi;
  return res;
end;
#############################################################################
##
#E