From ff8a68c258d6968379d7568741ff3ea50116e389 Mon Sep 17 00:00:00 2001
From: Chris Allegretta <chrisa@asty.org>
Date: Sat, 16 Feb 2002 20:34:57 +0000
Subject: [PATCH] rcfile.c:do_rcfile() - Parse rcfile in  as well (Dwayne
 Rightler)

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1077 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog |  2 ++
 rcfile.c  | 14 +++++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index e56c1740..1c2cb77a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -26,6 +26,8 @@ CVS code -
   parse_next_regex()
 	- Allow " symbol to be in regex without leading \ by checking
 	  for *ptr+1 is not the end of the regex.
+  do_rcfile()
+	- Parse rcfile in $SYSCONFDIR as well (Dwayne Rightler).
 - nano.c:
   help_init()
 	- Added message re: having multiple blank buffers (DLR).
diff --git a/rcfile.c b/rcfile.c
index 6455fe00..3fa012d8 100644
--- a/rcfile.c
+++ b/rcfile.c
@@ -432,12 +432,24 @@ void do_rcfile(void)
 {
     char *unable = _("Unable to open ~/.nanorc file, %s");
     struct stat fileinfo;
+    int skip=0;
     FILE *rcstream;
 
-
     if (getenv("HOME") == NULL)
 	return;
 
+    nanorc = charalloc(strlen(SYSCONFDIR) + 10);
+    sprintf(nanorc, "%s/nanorc", SYSCONFDIR);
+
+    /* Try to open system nanorc */
+    if (stat(nanorc, &fileinfo) != -1)
+	if ((rcstream = fopen(nanorc, "r")) != NULL) {
+
+	   /* Parse it! */
+	    parse_rcfile(rcstream);
+	    fclose(rcstream);
+	}
+
     nanorc = charalloc(strlen(getenv("HOME")) + 10);
     sprintf(nanorc, "%s/.nanorc", getenv("HOME"));
 
-- 
GitLab