Package: dc
Version: 1.06.94-3
Severity: wishlist
Tags: patch
The dc package in Debian etch and earlier had a patch that added support
for a .dcrc file, which was run on startup. This was a really great
feature (I use it, for example, to run '3k' when starting up, so that dc
will return more precision than just integers). It would be nice if it
could be returned to the newer release.
I've taken the patch from the old version of dc, applied it to the
latest release and attached it to this report.
Many thanks,
Paul
-- System Information:
Debian Release: lenny/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.23-1-686 (SMP w/1 CPU core)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash
Versions of packages dc depends on:
ii libc6 2.7-9 GNU C Library: Shared libraries
dc recommends no packages.
-- no debconf information
diff -urN bc-1.06.94.old/dc/dc.c bc-1.06.94/dc/dc.c
--- bc-1.06.94.old/dc/dc.c 2006-06-05 07:05:48.000000000 +1000
+++ bc-1.06.94/dc/dc.c 2008-03-23 07:58:28.000000000 +1100
@@ -30,6 +30,9 @@
#include "config.h"
#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <pwd.h>
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
@@ -89,6 +92,29 @@
bug_report_info();
}
+static void
+try_rcfile(void)
+{
+ char *homedir;
+ struct passwd *pw;
+ char *rcfile;
+ FILE *input;
+
+ homedir=getenv("HOME");
+ if (!homedir)
+ {
+ pw=getpwuid(getuid());
+ homedir=pw->pw_dir;
+ }
+ rcfile=malloc(strlen(homedir)+8);
+ sprintf(rcfile, "%s/.dcrc", homedir);
+ if (!(input=fopen(rcfile, "r")))
+ return;
+ if (dc_evalfile(input))
+ exit(EXIT_FAILURE);
+ fclose(input);
+}
+
/* returns a pointer to one past the last occurance of c in s,
* or s if c does not occur in s.
*/
@@ -297,6 +323,8 @@
}
}
+ try_rcfile();
+
for (; optind < argc; ++optind) {
try_file(argv[optind]);
did_eval = 1;
diff -urN bc-1.06.94.old/doc/dc.1 bc-1.06.94/doc/dc.1
--- bc-1.06.94.old/doc/dc.1 2006-04-29 19:05:36.000000000 +1000
+++ bc-1.06.94/doc/dc.1 2008-03-23 08:00:16.000000000 +1100
@@ -501,6 +501,14 @@
because the 2 was stored in an instance of 0:a that
was later popped.
.SH
+FILES
+.TP 15
+~/.dcrc
+The commands in this file will be executed when
+.I dc
+is first run.
+.PP
+.SH
BUGS
.PP
Email bug reports to