From faeeb5bd7eafb1f6d12d1d31bde1c2697fe5b0b6 Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Thu, 28 Aug 2008 06:13:05 +0000 Subject: [PATCH] 2008-08-28 Chris Allegretta * configure.ac, rcfile.c: Add support for an alternate rcfilename at configure time. Maybe this should become a command line option some day, but I don't see the need currently. Start of fix for Savannah bug #24128: Add nanorc support to win32 platform. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4314 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 5 +++++ configure.ac | 6 ++++++ src/rcfile.c | 7 +++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b16d2e7e..17ad4863 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-08-28 Chris Allegretta + * configure.ac, rcfile.c: Add support for an alternate rcfilename at configure time. Maybe this + should become a command line option some day, but I don't see the need currently. Start of + fix for Savannah bug #24128: Add nanorc support to win32 platform. + 2008-08-21 Chris Allegretta * text.c: Change error messages where we may possibly get into a bad state and urge the user to save when this happens. Originally by Benno Schulenberg diff --git a/configure.ac b/configure.ac index 4b096848..d9f46678 100644 --- a/configure.ac +++ b/configure.ac @@ -387,6 +387,12 @@ fi AM_CONDITIONAL(USE_COLOR, test x$color_support = xyes) AM_CONDITIONAL(USE_NANORC, test x$nanorc_support = xyes) +AC_ARG_ENABLE(altrcname, +[ --enable-altrcname Specify alternate rcfile name (default: .nanorc)], +[if test x$enableval != no; then + AC_DEFINE_UNQUOTED(RCFILE_NAME, "$enableval", [Specify alternate rcfile name (default: .nanorc)]) rcfilename=$enableval +fi]) + dnl Checks for functions. AC_CHECK_FUNCS(getdelim getline isblank strcasecmp strcasestr strncasecmp strnlen vsnprintf) diff --git a/src/rcfile.c b/src/rcfile.c index 4481b6a4..ee3759f3 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -1044,8 +1044,11 @@ void do_rcfile(void) if (homedir == NULL) rcfile_error(N_("I can't find my home directory! Wah!")); else { - nanorc = charealloc(nanorc, strlen(homedir) + 9); - sprintf(nanorc, "%s/.nanorc", homedir); +#ifndef RCFILE_NAME +#define RCFILE_NAME ".nanorc" +#endif + nanorc = charealloc(nanorc, strlen(homedir) + strlen(RCFILE_NAME) + 2); + sprintf(nanorc, "%s/%s", homedir, RCFILE_NAME); /* Don't open directories, character files, or block files. */ if (stat(nanorc, &rcinfo) != -1) { -- 2.39.5