bug-gnu-utils
[Top][All Lists]
Advanced

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

dc not entering input mode when a file is given (did_eval flag)


From: Deborah Spencer
Subject: dc not entering input mode when a file is given (did_eval flag)
Date: Wed, 1 Nov 2000 10:05:01 -0500
User-agent: Mutt/1.2.5i

I have a dc script that I have been using for many years, sort of
hex/decimal converter

$ cat /tmp/hex
[ A A oi ]sd
[ A A oi 16 16 oi ]sh
lhx

I run it using

$ dc /tmp/hex

At which point I am able to enter hex or decimal number and convert
them.

I haven't been able to use this with GNU dc (bc-1.05a) since the
input file mechanism works differerntly.  Once dc reads the file in
and executes the contents, it does not drop in to reading from stdin.

At the end of main (lines 167-170), dc treats reading of files with
the following loop:

    for (; optind < argc; ++optind) {
        try_file(argv[optind]);
        did_eval = 1;
    }

Always setting the did_eval flag to true.

The test for whether or not to use stdin is to check this did_eval
flag:  (lines 171-176)

    if (!did_eval) {
        /* if no -e commands and no command files, then eval stdin */
        if (dc_evalfile(stdin))
            return EXIT_FAILURE;
    }
    return EXIT_SUCCESS;


I believe this behavior is inconsitant with all of the other versions
of dc I have used.

To fix this behavior, I have removed the 'did_eval = 1' on line 168.
dc appears to then work consistent with the other versions of dc.


In the past, to have dc execute a script and exit, the way the current
GNU dc behaves, a 'q' needed to be added to the last line of the dc
script to instruct it to exit.   This behavior works with GNU dc as
well.

Thanks
Deborah Spencer
address@hidden



reply via email to

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