fixing nconc on long argument lists
This commit is contained in:
		
							parent
							
								
									2bf87ede4f
								
							
						
					
					
						commit
						291b5f86e0
					
				| 
						 | 
					@ -30,23 +30,27 @@ static value_t fl_nconc(value_t *args, u_int32_t nargs)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (nargs == 0)
 | 
					    if (nargs == 0)
 | 
				
			||||||
        return NIL;
 | 
					        return NIL;
 | 
				
			||||||
    value_t first=NIL;
 | 
					    value_t lst, first=NIL;
 | 
				
			||||||
    value_t *pcdr = &first;
 | 
					    value_t *pcdr = &first;
 | 
				
			||||||
    cons_t *c;
 | 
					    cons_t *c;
 | 
				
			||||||
    int a;
 | 
					    int a;
 | 
				
			||||||
    for(a=0; a < (int)nargs-1; a++) {
 | 
					    FOR_ARGS(a, 0, lst, args) {
 | 
				
			||||||
        if (iscons(args[a])) {
 | 
					        // skip last
 | 
				
			||||||
            *pcdr = args[a];
 | 
					        if ((nargs > MAX_ARGS && !iscons(args[MAX_ARGS])) ||
 | 
				
			||||||
            c = (cons_t*)ptr(args[a]);
 | 
					            (nargs <= MAX_ARGS && a == nargs-1))
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        if (iscons(lst)) {
 | 
				
			||||||
 | 
					            *pcdr = lst;
 | 
				
			||||||
 | 
					            c = (cons_t*)ptr(lst);
 | 
				
			||||||
            while (iscons(c->cdr))
 | 
					            while (iscons(c->cdr))
 | 
				
			||||||
                c = (cons_t*)ptr(c->cdr);
 | 
					                c = (cons_t*)ptr(c->cdr);
 | 
				
			||||||
            pcdr = &c->cdr;
 | 
					            pcdr = &c->cdr;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else if (args[a] != NIL) {
 | 
					        else if (lst != NIL) {
 | 
				
			||||||
            type_error("nconc", "cons", args[a]);
 | 
					            type_error("nconc", "cons", lst);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    *pcdr = args[a];
 | 
					    *pcdr = lst;
 | 
				
			||||||
    return first;
 | 
					    return first;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue