Skip to content

Commit

Permalink
Fix GAP_IsMatrix
Browse files Browse the repository at this point in the history
... and make `GAP_IsMatrixOrMatrixObj`, `GAP_IsMatrixObj` future proof:
directly calling `DoFilter` is risky and will break as soon as the
"filter" we are passing in is not a true filter, but e.g. an and-filter
(such as `IsMatrix`)
  • Loading branch information
fingolfin committed Jun 5, 2021
1 parent 2f25e4b commit a6c45d3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/libgap-api.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,19 +420,19 @@ static Obj NrColsAttr;
// Returns 1 if <obj> is a GAP matrix or matrix obj, 0 if not.
int GAP_IsMatrixOrMatrixObj(Obj obj)
{
return obj && DoFilter(IsMatrixOrMatrixObjFilt, obj) == True;
return obj && CALL_1ARGS(IsMatrixOrMatrixObjFilt, obj) == True;
}

// Returns 1 if <obj> is a GAP matrix, 0 if not.
int GAP_IsMatrix(Obj obj)
{
return obj && DoFilter(IsMatrixFilt, obj) == True;
return obj && CALL_1ARGS(IsMatrixFilt, obj) == True;
}

// Returns 1 if <obj> is a GAP matrix obj, 0 if not.
int GAP_IsMatrixObj(Obj obj)
{
return obj && DoFilter(IsMatrixObjFilt, obj) == True;
return obj && CALL_1ARGS(IsMatrixObjFilt, obj) == True;
}

// Returns the number of rows of the given GAP matrix obj.
Expand Down

0 comments on commit a6c45d3

Please sign in to comment.