[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nmh-workers] AM/PM

From: Ken Hornstein
Subject: Re: [Nmh-workers] AM/PM
Date: Sat, 10 Nov 2012 13:50:04 -0500

>Maybe next time I'll actually dig into fmtdump.

The other things you want are "ap" (if you want to test stuff involving
addresses) and "dp" (if you want to test stuff involving dates).

fmtdump is of course useful, but if you're not the kind of person who reads
fmt_scan.c regularly it's not always so helpful.  For example, the string
I gave you decodes into the following instructions:

        PARSEDATE, c_name "date", c_type <DATE>
        LV_HOUR, c_name "date", c_type <DATE>
        LV_MODULO_L value 12
        IF_V_EQ 0 continue else goto L0
        LIT "12"
        GOTO L1
L0:     NUMF, width 2, fill '0'
L1:     DONE

Okay, it's not terrible, but it's not wonderful.

Some other gotchas with format string testing:

- ap and dp use a special "text" component that's the value of the command
  line argument.  So you need to change your test format to use that instead
  of whatever component you're interested in (like "date" in this example).

- The biggest weakness you'll find is that you're limited to two variables:
  "str", the string register, and "num", the integer register (which is
  called "value" in the actual code, which explains instructions like

- The real weirdness comes into the rules about how variables are
  automatically overwritten.  Generally anything that returns text
  overwrites "str", and anything that returns an integer or boolean
  overwrites "value", with two exceptions:

  - If you use formataddr or concataddr a special SAVESTR instruction is
    generated and saves the str register.  This lets you append things to
    formataddr in an expression argument, like this:

    %(formataddr %<{reply-to}%?{to}%|%(void{apparantly-to})%>)

    formataddr and concataddr append the value of the "str" register to
    the string saved by SAVESTR.

  - If a special combined if/test instruction is generated, the value
    register is NOT overwritten.  That happens if the argument to an
    if statement (%<) is one of null, nonnull, zero, nonzero, eq, ne, gt,
    match, and amatch.  I didn't actually know that until today when I
    realized, "Hey, that format statement I gave Steve shouldn't have
    actually worked ... why did it?".

See?  Easy! :-)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]