Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37729253
en ru br
ALT Linux repos
S:1.07.1-alt1
5.0: 1.06-alt2
4.1: 1.06-alt2
4.0: 1.06-alt2
3.0: 1.06-ipl6mdk

Group :: Sciences/Mathematics
RPM: bc

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: 06_read_dcrc.diff
Download


Description: Read ~/.dcrc at startup of dc
 Patch taken from old version of dc by Paul Dwerryhouse
 Was initially applied by Francois Marier <francois@debian.org> in the NMU
 1.06.94-3.1 to close http://bugs.debian.org/472250 .
 Then it disappeared along the way, until users asked for it again.
 Jan Braun <janbraun@gmx.net> updated it to read .drcr before argument
 processing so that
     $ dc
     $ dc -
     $ dc -f -
 all have the same behaviour
Origin: vendor
Author: upstream
Author: Jan Brawn <janbraun@gmx.net>
Bug-Debian: http://bugs.debian.org/582137
Bug-Ubuntu: https://bugs.launchpad.net/debian/+source/bc/+bug/918836
Forwarded: no
Reviewed-by: Ryan Kavanagh <rak@debian.org>
Last-Update: 2013-06-02
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
Index: bc/dc/dc.c
===================================================================
--- bc.orig/dc/dc.c	2017-07-26 17:33:17.976925633 -0400
+++ bc/dc/dc.c	2017-07-26 17:33:17.976925633 -0400
@@ -43,6 +43,8 @@
 # include <sys/stat.h>
 #endif
 #include <getopt.h>
+#include <pwd.h>
+#include <unistd.h>
 #include "dc.h"
 #include "dc-proto.h"
 
@@ -246,6 +248,29 @@
 	return r;
 }
 
+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);
+}
+
 
 int
 main DC_DECLARG((argc, argv))
@@ -268,6 +293,8 @@
 	dc_register_init();
 	dc_array_init();
 
+	try_rcfile();
+
 	while ((c = getopt_long(argc, argv, "hVe:f:", long_opts, (int *)0)) != EOF) {
 		switch (c) {
 		case 'e':
Index: bc/doc/dc.1
===================================================================
--- bc.orig/doc/dc.1	2017-07-26 17:33:17.976925633 -0400
+++ bc/doc/dc.1	2017-07-26 17:33:17.976925633 -0400
@@ -514,6 +514,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
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin