This file is indexed.

/usr/share/sagemath/ext/gap/sage.g is in sagemath-common 7.4-9.

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
#
# SAGE support utilities to read into the GAP session.
#
\$SAGE := rec();

\$SAGE.OldPager := Pager;


\$SAGE.NewPager :=
          function( data )
    local   str,  lines,  line, fn, start;
    str := OutputTextFile(\$SAGE.tempfile,false);
    start := 1;
    if IsRecord(data) then
        lines := data.lines;
        if IsBound(data.start) then
            start := data.start;
        fi;
    else
        lines := data;
    fi;
    if IsString(lines) then
        lines := SplitString(lines,"\n");
    fi;
    for line in lines do
        WriteLine(str, line);
    od;
    CloseStream(str);
    Print("Page from ",start,"\n");
end;

\$SAGE.StartInteract := function()
    MakeReadWriteGlobal("Pager");
    Pager := \$SAGE.OldPager;
    HELP_VIEWER_INFO.screen.show := \$SAGE.OldPager;
    MakeReadOnlyGlobal("Pager");
end;


\$SAGE.StopInteract := function()
    MakeReadWriteGlobal("Pager");
    Pager := \$SAGE.NewPager;
    HELP_VIEWER_INFO.screen.show := \$SAGE.NewPager;
    MakeReadOnlyGlobal("Pager");
end;


\$SAGE.StopInteract();

#\$SAGE.ErrorHandler := function(m,a,m2,mode)
#    PrintTo("*errout*", m);
#    if a <> fail then
#        PrintTo("*errout*",a);
#    fi;
#    SetErrorHandler(\$SAGE.ErrorHandler);
#    return true;
#end;

#SetErrorHandler(\$SAGE.ErrorHandler);

SetAllInfoLevels(0);

\$SAGE.OperationsAdmittingFirstArgument := function(obj)
    local   hits,  myflags,  i,  flagss,  flags;
    hits := [];
    myflags := FlagsType(TypeObj(obj));
    for i in [1,3..Length(OPERATIONS)-1] do
        flagss := OPERATIONS[i+1];
        for flags in flagss do
            if Length(flags) >= 1 and IS_SUBSET_FLAGS(myflags, flags[1]) then
                Add(hits, OPERATIONS[i]);
                break;
            fi;
        od;
    od;
    return hits;
end;


\$SAGE.CleanOperationName := function(name)
    local   lt,  ls;
    lt := Length("Tester(");
    if Length(name) > lt and name{[1..lt]} = "Tester(" then
        return Concatenation("Has",name{[lt+1..Length(name)-1]});
    fi;
    ls := Length("Setter(");
    if Length(name) > ls and name{[1..ls]} = "Setter(" then
        return Concatenation("Set",name{[lt+1..Length(name)-1]});
    fi;
    return name;
end;

\$SAGE.HasAtLeastOneMethodAsFirstArgument := function(op,obj)
    local   t,  f,  n,  meths,  i;
    t := TypeObj(obj);
    f := FlagsType(t);
    for n in [1..6] do
        meths := METHODS_OPERATION(op,n);
        for i in [1,n+5..LENGTH(meths)-n-3] do
            if IS_SUBSET_FLAGS(f,meths[i+1]) then
                return true;
            fi;
        od;
    od;
    return false;
end;


\$SAGE.PlausibleTabCompletionsForSage := function(o)
    local   ops,  opnames;
    ops := Filtered(\$SAGE.OperationsAdmittingFirstArgument(o), op ->
                   \$SAGE.HasAtLeastOneMethodAsFirstArgument(op,o));
    opnames := List(ops, op -> \$SAGE.CleanOperationName(NameFunction(op)));
    return Concatenation(opnames, GLOBAL_FUNCTION_NAMES);
end;

# The log below is for debuging only.
# CAREFUL -- do *not* activate this unless you know
# what you are doing.  E.g., if active and the user doesn't
# have write permission to /tmp (e.g., on OS X),
# then gap will completely fail to work for them.   -- WAS
#
# LogTo("/tmp/gapsage.log");
#