/* If we're ending a destination (that is, the destination is changing), call ecEndGroupAction. Always restore relevant info from the top of the SAVE list.  */
int ecPopRtfState(RTF_Context *ctx)
/* If we're ending a destination (that is, the destination is changing), call ecEndGroupAction. Always restore relevant info from the top of the SAVE list.  */
int ecPopRtfState(RTF_Context *ctx)
{
    SAVE *psaveOld;
    int ec;
    if (!ctx->psave)
        return ecStackUnderflow;
    if (ctx->rds != ctx->psave->rds)
    {
        if ((ec = ecEndGroupAction(ctx, ctx->rds)) != ecOK)
            return ec;
    }
    ctx->chp = ctx->psave->chp;
    ctx->pap = ctx->psave->pap;
    ctx->sep = ctx->psave->sep;
    ctx->dop = ctx->psave->dop;
    ctx->rds = ctx->psave->rds;
    ctx->ris = ctx->psave->ris;
    psaveOld = ctx->psave;
    ctx->psave = ctx->psave->pNext;
    ctx->cGroup--;
    free(psaveOld);
    return ecOK;
}