Deconstructing a Function from Microsoft Word 1.1a

When Microsoft Word released the source code for MS-DOS and Word, Ode to Code have to take a look at the functions. In this post, the author came along with a function ReplacePropsCA from srchfmt.c file.

What the author realized was that every function has an owner and the flow control is all wrong. There are also some hilarious notations.

Here is the code:

/* %%Function:ReplacePropsCa %%Owner:rosiep */

ReplacePropsCa(prpp, pca)
struct RPP *prpp;
struct CA *pca;
{
    struct CA caInval;
    if (prpp->cbgrpprlChp)
        {
        ExpandCaSprm(pca, &caInval, prpp->grpprlChp);
        ApplyGrpprlCa(prpp->grpprlChp, prpp->cbgrpprlChp, pca);
        if (!vfNoInval)
            {
            InvalCp(pca);
            InvalText(pca, fFalse /* fEdit */);
            }
        }
    if (prpp->cbgrpprlPap)
        {
        int fStc;
        struct CHP chp;
        struct PAP pap;
        if (fStc = (*prpp->grpprlPap == sprmPStc))
            {
            CachePara(pca->doc, pca->cpFirst);
            pap = vpapFetch;
            }
        ExpandCaSprm(pca, &caInval, prpp->grpprlPap);
        ApplyGrpprlCa(prpp->grpprlPap, prpp->cbgrpprlPap, pca);
        if (fStc)
            {
            GetMajorityChp(pca, &chp);
            EmitSprmCMajCa(pca, &chp);
            if (!FMatchAbs(pca->doc, &pap, &vpapFetch))
                InvalPageView(pca->doc);
            }
        if (!vfNoInval)
            {
            InvalCp(&caInval);
            InvalText (pca, fFalse /* fEdit */);
            DirtyOutline(pca->doc);
            }
        }
}

Leave a Reply

Your email address will not be published. Required fields are marked *