RPM Community Forums

Mailing List Message of <popt-devel>

RPN calculator with +/- operations

From: Jeff Johnson <n3npq@mac.com>
Date: Sun 13 Jun 2010 - 21:30:01 CEST
Message-id: <A7176258-6C1E-46FD-8808-A950C7AB0FF7@mac.com>

On Jun 7, 2010, at 1:41 PM, Jeff Johnson wrote:

> 
> (aside)
> I almost added a RPN calculator to popt-1.16 this weekend past.
> The implementation would have involved a table entry like
> 
>     int counter = 0;
> 
>   { "autoincrement", '\0', POPT_ARG_INT|POPT_ARGFLAG_RPN,       &counter, 0,
>         N_("Demonstrate autoincrmenting using a RPN calculator"), "1 +"  },
> 

Well I finally implemented autoincrement using a RPN calculator with a table entry
(from popt/test1.c) like

   { "verbose", 'v', POPT_ARG_VAL|POPT_ARGFLAG_CALCULATOR|POPT_ARGFLAG_DOC_HIDDEN, &aCounter, 1,
        "POPT_ARGFLAG_CALCULATOR: increment a counter", "+" },

I almost certainly will change my mind as I proceed wiring up RPN "calculator"
functionality somehow.

There are several things I dislike with what I implemented,
basically lack of generality and too arcanely obscure to be useful (imho).

Specifically the implementation:
	1) "works" only with longs/ints/shorts, not floats/doubles.
	2) has a delta increment that is limited to 32 bits and must be specified as "1"
	(a variant of the need for an additional "incompatible" pointer field)
        3) no clue how to display RPN calculator +/- in --help. Note that the
	implementation already does more than "++" and "--", that would be easy
        to add to --help spewage somehow.
       4) will force the 7th table field to be used for POPT operations, not just information in --help.

todo++ still early yet for POPT 2.0

73 de Jeff
Received on Sun Jun 13 21:30:52 2010
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.