Skip to content

Commit

Permalink
Remove option to return values from break loop in many places
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisJefferson authored and fingolfin committed Nov 7, 2018
1 parent 82d0fb1 commit 4265b7c
Show file tree
Hide file tree
Showing 19 changed files with 124 additions and 124 deletions.
44 changes: 22 additions & 22 deletions src/blister.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
#include "set.h"


#define RequireBlistMayReplace(funcname, op, argname) \
RequireArgumentConditionMayReplace(funcname, op, argname, IsBlistConv(op), \
#define RequireBlist(funcname, op, argname) \
RequireArgumentCondition(funcname, op, argname, IsBlistConv(op), \
"must be a boolean list")

/****************************************************************************
Expand Down Expand Up @@ -1043,7 +1043,7 @@ Obj FuncSIZE_BLIST (
Obj self,
Obj blist )
{
RequireBlistMayReplace("SizeBlist", blist, "blist");
RequireBlist("SizeBlist", blist, "blist");
return INTOBJ_INT(SizeBlist(blist));
}

Expand Down Expand Up @@ -1074,8 +1074,8 @@ Obj FuncBLIST_LIST (
Obj sub )
{
/* get and check the arguments */
RequireSmallListMayReplace("BlistList", list);
RequireSmallListMayReplace("BlistList", sub);
RequireSmallList("BlistList", list);
RequireSmallList("BlistList", sub);

Int lenList = LEN_LIST( list );
Obj blist = NewBag( T_BLIST, SIZE_PLEN_BLIST( lenList ) );
Expand Down Expand Up @@ -1114,9 +1114,9 @@ Obj FuncLIST_BLIST (
UInt i; /* loop variable */

/* get and check the first argument */
RequireSmallListMayReplace("ListBlist", list);
RequireSmallList("ListBlist", list);
/* get and check the second argument */
RequireBlistMayReplace("ListBlist", blist, "blist");
RequireBlist("ListBlist", blist, "blist");
while ( LEN_LIST( list ) != LEN_BLIST( blist ) ) {
blist = ErrorReturnObj(
"ListBlist: <blist> must have the same length as <list> (%d)",
Expand Down Expand Up @@ -1166,8 +1166,8 @@ Obj FuncPositionNthTrueBlist (
const UInt * ptr;

/* Check the arguments. */
RequireBlistMayReplace("ListBlist", blist, "blist");
RequirePositiveSmallIntMayReplace("Position", Nth, "nth");
RequireBlist("ListBlist", blist, "blist");
RequirePositiveSmallInt("Position", Nth, "nth");

nrb = NUMBER_BLOCKS_BLIST(blist);
if ( ! nrb ) return Fail;
Expand Down Expand Up @@ -1216,8 +1216,8 @@ Obj FuncIS_SUB_BLIST (
UInt i; /* loop variable */

/* get and check the arguments */
RequireBlistMayReplace("IsSubsetBlist", list1, "blist1");
RequireBlistMayReplace("IsSubsetBlist", list2, "blist2");
RequireBlist("IsSubsetBlist", list1, "blist1");
RequireBlist("IsSubsetBlist", list2, "blist2");
while ( LEN_BLIST(list1) != LEN_BLIST(list2) ) {
list2 = ErrorReturnObj(
"IsSubsetBlist: <blist2> must have the same length as <blist1> (%d)",
Expand Down Expand Up @@ -1262,8 +1262,8 @@ Obj FuncUNITE_BLIST (
UInt i; /* loop variable */

/* get and check the arguments */
RequireBlistMayReplace("UniteBlist", list1, "blist1");
RequireBlistMayReplace("UniteBlist", list2, "blist2");
RequireBlist("UniteBlist", list1, "blist1");
RequireBlist("UniteBlist", list2, "blist2");
while ( LEN_BLIST(list1) != LEN_BLIST(list2) ) {
list2 = ErrorReturnObj(
"UniteBlist: <blist2> must have the same length as <blist1> (%d)",
Expand Down Expand Up @@ -1310,19 +1310,19 @@ Obj FuncUNITE_BLIST_LIST (
long s, t; /* elements of a range */

/* get and check the arguments */
RequireSmallListMayReplace("UniteBlistList", list);
RequireSmallList("UniteBlistList", list);

lenList = LEN_LIST( list );

RequireBlistMayReplace("UniteBlistList", blist, "blist");
RequireBlist("UniteBlistList", blist, "blist");
while ( LEN_BLIST(blist) != lenList ) {
blist = ErrorReturnObj(
"UniteBlistList: <blist> must have the same length as <list> (%d)",
lenList, 0L,
"you can replace <blist> via 'return <blist>;'" );
}

RequireSmallListMayReplace("UniteBlistList", sub);
RequireSmallList("UniteBlistList", sub);

lenSub = LEN_LIST( sub );

Expand Down Expand Up @@ -1529,8 +1529,8 @@ Obj FuncINTER_BLIST (
UInt i; /* loop variable */

/* get and check the arguments */
RequireBlistMayReplace("IntersectBlist", list1, "blist1");
RequireBlistMayReplace("IntersectBlist", list2, "blist2");
RequireBlist("IntersectBlist", list1, "blist1");
RequireBlist("IntersectBlist", list2, "blist2");
while ( LEN_BLIST(list1) != LEN_BLIST(list2) ) {
list2 = ErrorReturnObj(
"IntersectBlist: <blist2> must have the same length as <blist1> (%d)",
Expand Down Expand Up @@ -1572,8 +1572,8 @@ Obj FuncSUBTR_BLIST (
UInt i; /* loop variable */

/* get and check the arguments */
RequireBlistMayReplace("SubtractBlist", list1, "blist1");
RequireBlistMayReplace("SubtractBlist", list2, "blist2");
RequireBlist("SubtractBlist", list1, "blist1");
RequireBlist("SubtractBlist", list2, "blist2");
while ( LEN_BLIST(list1) != LEN_BLIST(list2) ) {
list2 = ErrorReturnObj(
"SubtractBlist: <blist2> must have the same length as <blist1> (%d)",
Expand Down Expand Up @@ -1617,8 +1617,8 @@ Obj FuncMEET_BLIST (
UInt i; /* loop variable */

/* get and check the arguments */
RequireBlistMayReplace("MeetBlist", list1, "blist1");
RequireBlistMayReplace("MeetBlist", list2, "blist2");
RequireBlist("MeetBlist", list1, "blist1");
RequireBlist("MeetBlist", list2, "blist2");
while ( LEN_BLIST(list1) != LEN_BLIST(list2) ) {
list2 = ErrorReturnObj(
"MeetBlist: <blist2> must have the same length as <blist1> (%d)",
Expand Down
2 changes: 1 addition & 1 deletion src/calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ Obj FuncSET_NAME_FUNC(
Obj func,
Obj name )
{
RequireStringRepMayReplace("SET_NAME_FUNC", name);
RequireStringRep("SET_NAME_FUNC", name);

if (TNUM_OBJ(func) == T_FUNCTION ) {
SET_NAME_FUNC(func, ImmutableString(name));
Expand Down
2 changes: 1 addition & 1 deletion src/cyclotom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1544,7 +1544,7 @@ Obj FuncE (
}

/* get and check the argument */
RequirePositiveSmallIntMayReplace("E", n, "n");
RequirePositiveSmallInt("E", n, "n");

/* for $e_1$ return 1 and for $e_2$ return -1 */
if ( n == INTOBJ_INT(1) )
Expand Down
4 changes: 2 additions & 2 deletions src/exprs.c
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ Obj EvalPermExpr (

/* get and check current entry for the cycle */
val = EVAL_EXPR(READ_EXPR(cycle, j - 1));
RequirePositiveSmallIntMayReplace("Permutation", val, "expr");
RequirePositiveSmallInt("Permutation", val, "expr");
c = INT_INTOBJ(val);
if (c > MAX_DEG_PERM4)
ErrorMayQuit( "Permutation literal exceeds maximum permutation degree",
Expand Down Expand Up @@ -1086,7 +1086,7 @@ Obj EvalRangeExpr (

/* evaluate the low value */
val = EVAL_EXPR(READ_EXPR(expr, 0));
RequireSmallIntMayReplace("Range", val, "first");
RequireSmallInt("Range", val, "first");
low = INT_INTOBJ( val );

/* evaluate the second value (if present) */
Expand Down
6 changes: 3 additions & 3 deletions src/gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ Obj FuncGASMAN (
/* evaluate and check the command */
Obj cmd = ELM_PLIST( args, i );
again:
RequireStringRepMayReplace("GASMAN", cmd);
RequireStringRep("GASMAN", cmd);

// perform full garbage collection
if ( strcmp( CONST_CSTR_STRING(cmd), "collect" ) == 0 ) {
Expand Down Expand Up @@ -1190,7 +1190,7 @@ Obj FuncFUNC_BODY_SIZE(Obj self, Obj f)

Obj FuncSleep( Obj self, Obj secs )
{
RequireSmallIntMayReplace("Sleep", secs, "secs");
RequireSmallInt("Sleep", secs, "secs");

Int s = INT_INTOBJ(secs);
if (s > 0)
Expand All @@ -1215,7 +1215,7 @@ Obj FuncSleep( Obj self, Obj secs )

Obj FuncMicroSleep( Obj self, Obj msecs )
{
RequireSmallIntMayReplace("MicroSleep", msecs, "usecs");
RequireSmallInt("MicroSleep", msecs, "usecs");

Int s = INT_INTOBJ(msecs);

Expand Down
22 changes: 11 additions & 11 deletions src/gvars.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ Obj FuncMakeReadOnlyGVar (
Obj name )
{
// check the argument
RequireStringRepMayReplace("MakeReadOnlyGVar", name);
RequireStringRep("MakeReadOnlyGVar", name);

/* get the variable and make it read only */
MakeReadOnlyGVar(GVarName(CONST_CSTR_STRING(name)));
Expand All @@ -764,7 +764,7 @@ Obj FuncMakeReadOnlyGVar (
Obj FuncMakeConstantGVar(Obj self, Obj name)
{
// check the argument
RequireStringRepMayReplace("MakeConstantGVar", name);
RequireStringRep("MakeConstantGVar", name);

/* get the variable and make it read only */
MakeConstantGVar(GVarName(CONST_CSTR_STRING(name)));
Expand Down Expand Up @@ -804,7 +804,7 @@ Obj FuncMakeReadWriteGVar (
Obj name )
{
// check the argument
RequireStringRepMayReplace("MakeReadWriteGVar", name);
RequireStringRep("MakeReadWriteGVar", name);

/* get the variable and make it read write */
MakeReadWriteGVar(GVarName(CONST_CSTR_STRING(name)));
Expand Down Expand Up @@ -834,7 +834,7 @@ static Obj FuncIsReadOnlyGVar (
Obj name )
{
// check the argument
RequireStringRepMayReplace("IsReadOnlyGVar", name);
RequireStringRep("IsReadOnlyGVar", name);

/* get the answer */
return IsReadOnlyGVar(GVarName(CONST_CSTR_STRING(name))) ? True : False;
Expand All @@ -858,7 +858,7 @@ Int IsConstantGVar(UInt gvar)
static Obj FuncIsConstantGVar(Obj self, Obj name)
{
// check the argument
RequireStringRepMayReplace("IsConstantGVar", name);
RequireStringRep("IsConstantGVar", name);

/* get the answer */
return IsConstantGVar(GVarName(CONST_CSTR_STRING(name))) ? True : False;
Expand Down Expand Up @@ -901,7 +901,7 @@ Obj FuncAUTO (

/* get and check the function */
func = ELM_LIST( args, 1 );
RequireFunctionMayReplace("AUTO", func);
RequireFunction("AUTO", func);

/* get the argument */
arg = ELM_LIST( args, 2 );
Expand All @@ -915,7 +915,7 @@ Obj FuncAUTO (
/* make the global variables automatic */
for ( i = 3; i <= LEN_LIST(args); i++ ) {
name = ELM_LIST( args, i );
RequireStringRepMayReplace("AUTO", name);
RequireStringRep("AUTO", name);
gvar = GVarName( CONST_CSTR_STRING(name) );
SET_ELM_GVAR_LIST( ValGVars, gvar, 0 );
SET_ELM_GVAR_LIST( ExprGVars, gvar, list );
Expand Down Expand Up @@ -1058,7 +1058,7 @@ Obj FuncASS_GVAR (
Obj val )
{
// check the argument
RequireStringRepMayReplace("READ", gvar);
RequireStringRep("READ", gvar);

AssGVar( GVarName( CONST_CSTR_STRING(gvar) ), val );
return 0L;
Expand All @@ -1074,7 +1074,7 @@ Obj FuncISB_GVAR (
Obj gvar )
{
// check the argument
RequireStringRepMayReplace("ISB_GVAR", gvar);
RequireStringRep("ISB_GVAR", gvar);

UInt gv = GVarName( CONST_CSTR_STRING(gvar) );
if (VAL_GVAR_INTERN(gv))
Expand Down Expand Up @@ -1103,7 +1103,7 @@ Obj FuncVAL_GVAR (
{
Obj val;
// check the argument
RequireStringRepMayReplace("VAL_GVAR", gvar);
RequireStringRep("VAL_GVAR", gvar);

/* get the value */
val = ValAutoGVar( GVarName( CONST_CSTR_STRING(gvar) ) );
Expand All @@ -1125,7 +1125,7 @@ Obj FuncUNB_GVAR (
Obj gvar )
{
// check the argument
RequireStringRepMayReplace("UNB_GVAR", gvar);
RequireStringRep("UNB_GVAR", gvar);

/* */
AssGVar( GVarName( CONST_CSTR_STRING(gvar) ), (Obj)0 );
Expand Down
2 changes: 1 addition & 1 deletion src/integer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2647,7 +2647,7 @@ Obj FuncRandomIntegerMT(Obj self, Obj mtstr, Obj nrbits)
Int i, n, q, r, qoff, len;
UInt4 *mt;
UInt4 *pt;
RequireStringRepMayReplace("RandomIntegerMT", mtstr);
RequireStringRep("RandomIntegerMT", mtstr);
while ((! IsStringConv(mtstr)) || GET_LEN_STRING(mtstr) < 2500) {
mtstr = ErrorReturnObj(
"RandomIntegerMT: <mtstr> must be a string with at least 2500 characters",
Expand Down
8 changes: 4 additions & 4 deletions src/intfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Obj FuncInitRandomMT( Obj self, Obj initstr)
UInt4 *mt, key_length, byte_key_length, i, j, k, N = 624;

/* check the seed, given as string */
RequireStringRepMayReplace("InitRandomMT", initstr);
RequireStringRep("InitRandomMT", initstr);

/* store array of 624 UInt4 and one UInt4 as counter "mti" and an
endianness marker */
Expand Down Expand Up @@ -448,12 +448,12 @@ Obj FuncHASHKEY_BAG(Obj self, Obj obj, Obj opSeed, Obj opOffset, Obj opMaxLen)
}

/* check the arguments */
RequireSmallIntMayReplace("HASHKEY_BAG", opSeed, "seed");
RequireSmallInt("HASHKEY_BAG", opSeed, "seed");

do {
offs = -1;

RequireSmallIntMayReplace("HASHKEY_BAG", opOffset, "offset");
RequireSmallInt("HASHKEY_BAG", opOffset, "offset");
offs = INT_INTOBJ(opOffset);
if ( offs < 0 || offs > SIZE_OBJ(obj)) {
opOffset = ErrorReturnObj(
Expand All @@ -464,7 +464,7 @@ Obj FuncHASHKEY_BAG(Obj self, Obj obj, Obj opSeed, Obj opOffset, Obj opMaxLen)
}
} while (offs < 0);

RequireSmallIntMayReplace("HASHKEY_BAG", opMaxLen, "maxlen");
RequireSmallInt("HASHKEY_BAG", opMaxLen, "maxlen");

n=SIZE_OBJ(obj)-offs;

Expand Down
12 changes: 6 additions & 6 deletions src/listfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ Obj FuncAPPEND_LIST_INTR (

/* check the type of the first argument */
if ( TNUM_OBJ( list1 ) != T_PLIST ) {
RequireSmallListMayReplace("AppendList", list1);
RequireSmallList("AppendList", list1);
if ( ! IS_PLIST( list1 ) ) {
PLAIN_LIST( list1 );
}
Expand All @@ -303,7 +303,7 @@ Obj FuncAPPEND_LIST_INTR (

/* check the type of the second argument */
if ( ! IS_PLIST( list2 ) ) {
RequireSmallListMayReplace("AppendList", list2);
RequireSmallList("AppendList", list2);
len2 = LEN_LIST( list2 );
}
else {
Expand Down Expand Up @@ -423,7 +423,7 @@ Obj FuncPOSITION_SORTED_LIST (
UInt h; /* position, result */

/* check the first argument */
RequireSmallListMayReplace("POSITION_SORTED_LIST", list);
RequireSmallList("POSITION_SORTED_LIST", list);
/* dispatch */
if ( IS_DENSE_PLIST(list) ) {
h = PositionSortedDensePlist( list, obj );
Expand Down Expand Up @@ -508,10 +508,10 @@ Obj FuncPOSITION_SORTED_LIST_COMP (
UInt h; /* position, result */

/* check the first argument */
RequireSmallListMayReplace("POSITION_SORTED_LIST_COMP", list);
RequireSmallList("POSITION_SORTED_LIST_COMP", list);

/* check the third argument */
RequireFunctionMayReplace("POSITION_SORTED_LIST_COMP", func);
RequireFunction("POSITION_SORTED_LIST_COMP", func);

/* dispatch */
if ( IS_DENSE_PLIST(list) ) {
Expand Down Expand Up @@ -1152,7 +1152,7 @@ Obj FuncOnTuples (
UInt i; /* loop variable */

/* check the type of the first argument */
RequireSmallListMayReplace("OnTuples", tuple);
RequireSmallList("OnTuples", tuple);

/* special case for the empty list */
if (LEN_LIST(tuple) == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/macfloat.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ Obj FuncMACFLOAT_INT( Obj self, Obj i )

Obj FuncMACFLOAT_STRING( Obj self, Obj s )
{
RequireStringRepMayReplace("MACFLOAT_STRING", s);
RequireStringRep("MACFLOAT_STRING", s);

char * endptr;
UChar *sp = CHARS_STRING(s);
Expand Down
Loading

0 comments on commit 4265b7c

Please sign in to comment.