X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Ftransformations.c;h=209d13f82bf816653cba78240060924cb206c2fe;hb=d2b769f76cbbadede9bd68da7caecabd69235bfa;hp=2a73cade41bbcf6e4c55622c5d00b9d8b18505b6;hpb=14aac9fe7a7efbb6c9bded2ed5969a643cb76645;p=pspp diff --git a/src/data/transformations.c b/src/data/transformations.c index 2a73cade41..209d13f82b 100644 --- a/src/data/transformations.c +++ b/src/data/transformations.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2006, 2009, 2011, 2013 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,14 +16,14 @@ #include -#include +#include "data/transformations.h" #include #include -#include +#include "libpspp/str.h" -#include "xalloc.h" +#include "gl/xalloc.h" /* A single transformation. */ struct transformation @@ -59,26 +59,25 @@ trns_chain_create (void) return chain; } -/* Finalizes all the transformations in CHAIN. - A chain is only finalized once; afterward, calling this - function is a no-op. - Finalizers may add transformations to CHAIN, but after - finalization the chain's contents are fixed, so that no more - transformations may be added afterward. */ +/* Finalizes all the un-finalized transformations in CHAIN. + Any given transformation is only finalized once. */ void trns_chain_finalize (struct trns_chain *chain) { - if (!chain->finalized) + while (!chain->finalized) { size_t i; + chain->finalized = true; for (i = 0; i < chain->trns_cnt; i++) { struct transformation *trns = &chain->trns[i]; - if (trns->finalize != NULL) - trns->finalize (trns->aux); + trns_finalize_func *finalize = trns->finalize; + + trns->finalize = NULL; + if (finalize != NULL) + finalize (trns->aux); } - chain->finalized = true; } } @@ -127,7 +126,7 @@ trns_chain_append (struct trns_chain *chain, trns_finalize_func *finalize, { struct transformation *trns; - assert (!chain->finalized); + chain->finalized = false; if (chain->trns_cnt == chain->trns_cap) chain->trns = x2nrealloc (chain->trns, &chain->trns_cap, @@ -167,6 +166,7 @@ trns_chain_splice (struct trns_chain *dst, struct trns_chain *src) } dst->trns_cnt += src->trns_cnt; + src->trns_cnt = 0; trns_chain_destroy (src); }