你遇到过的源代码中最好的注释是什么?


当前回答

我喜欢GNU双utils中的一些注释。这个来自BFD som.c:

/* You'll never believe all this is necessary to handle relocations
   for function calls.  Having to compute and pack the argument
   relocation bits is the real nightmare.

   If you're interested in how this works, just forget it.  You really
   do not want to know about this braindamage.  */

这个也是:

/* Don't ask about these magic sequences.  I took them straight
   from gas-1.36 which took them from the a.out man page.  */

...

/* Keep track of exactly where we are within a particular
   space.  This is necessary as the braindamaged HPUX
   loader will create holes between subspaces *and*
   subspace alignments are *NOT* preserved.  What a crock.  */

另一个:

/* We will NOT put a fucking timestamp in the header here. Every
   time you put it back, I will come in and take it out again. ... */

从气体:

/* Yes this is ugly (storing the broken_word pointer
   in the symbol slot).  Still, this whole chunk of
   code is ugly, and I don't feel like doing anything
   about it.  Think of it as stubbornness in action.  */

其他回答

int main(void)
/* Program starts here */

整个函数非常棒(来自Linux的sunhme.c驱动程序,用于被Sun戏称为“快乐套餐”的网卡)。因为在那之前的卡片是“巨无霸”。明白了吗?明白了吗?)

static void happy_meal_tcvr_write(struct happy_meal *hp,
                              void __iomem *tregs, int reg,
                              unsigned short value)
{
    int tries = TCVR_WRITE_TRIES;

    ASD(("happy_meal_tcvr_write: reg=0x%02x value=%04x\n", reg, value));

    /* Welcome to Sun Microsystems, can I take your order please? */
    if (!(hp->happy_flags & HFLAG_FENABLE)) {
            happy_meal_bb_write(hp, tregs, reg, value);
            return;
    }

    /* Would you like fries with that? */
    hme_write32(hp, tregs + TCVR_FRAME,
                (FRAME_WRITE | (hp->paddr << 23) |
                 ((reg & 0xff) << 18) | (value & 0xffff)));
    while (!(hme_read32(hp, tregs + TCVR_FRAME) & 0x10000) && --tries)
            udelay(20);

    /* Anything else? */
    if (!tries)
            printk(KERN_ERR "happy meal: Aieee, transceiver MIF write bolixed\n");

    /* Fifty-two cents is your change, have a nice day. */

}

/*现在,让所有这些看 半得体的弱智步 哥哥 浏览器家族中的一员,互联网 该死的探险家*/

http://fxr.watson.org/fxr/source/pci/if_rl.c 是好的来源。

// BEGIN HACK
...
// END HACK: I feel dirty.