:: Re: [DNG] Odd issue with busybox dc…
Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Brad Campbell
Fecha:  
A: dng
Asunto: Re: [DNG] Odd issue with busybox dc in beowulf
On 29/4/21 8:14 pm, tito via Dng wrote:

> Hi,
> by looking at the latest git code:
>
> static const struct op operators[] ALIGN_PTR = {
> #if ENABLE_FEATURE_DC_LIBM
>     {"^",   power},
> //    {"exp", power},
> //    {"pow", power},
> #endif
>     {"%",   mod},
> //    {"mod", mod},
>     // logic ops are not standard, remove?
>     {"and", and},
>     {"or",  or},
>     {"not", not},
>     {"xor", eor},
>     {"+",   add},
> //    {"add", add},
>     {"-",   sub},
> //    {"sub", sub},
>     {"*",   mul},
> //    {"mul", mul},
>     {"/",   divide},
> //    {"div", divide},
>     {"p", print_no_pop},
>     {"f", print_stack_no_pop},
>     {"o", set_output_base},
> };

>
> it seems to me that mod, add, sub, mul, div are disabled
> and only %, +, -, *, / are supported.
> Cannot say if simply uncommenting them restores
> the previous functionality, could be worth a try.
> Eventually if it works a patch for making them optional
> (CONFIG_DC_LONG_OPS or the like) could be sent
> to the list.
>
> Hope this helps,


It did. Thanks to all that replied.

This bit of code runs in the initramfs and is used to unlock ATA locked drives using keys from the network.
If it fails, the machine can't unlock the drives. This prompted me to take the time to re-write the arithmetic
in a POSIX compatible shell to take dc out of the equation altogether. I can't risk it breaking again down the track.

I still never got to the bottom of it printing the top of the stack as a character rather than a number.

Regards,
Brad