nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] AM/PM

2012-11-10 12:50:27
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
  IF_V_EQ).

- 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! :-)

--Ken

_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>