summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSosthène Guédon <sosthene.gued@gmail.com>2019-06-16 12:06:37 +0200
committerSosthène Guédon <sosthene.gued@gmail.com>2019-06-16 12:06:37 +0200
commit08556c96115a5421f05b637bb29affde359ccacf (patch)
tree6f9ee26f9b12a5597ce4b6e8d28c4d555006ebfe
parent3540f7e62df019e537993ebe104835a834808ed3 (diff)
Change config file location
-rwxr-xr-xsrc/Makefile4
-rw-r--r--src/file.c11
2 files changed, 10 insertions, 5 deletions
diff --git a/src/Makefile b/src/Makefile
index 0ac22c7..be60014 100755
--- a/src/Makefile
+++ b/src/Makefile
@@ -13,6 +13,8 @@ MANDIR = $(prefix)/share/man/man1
# This is where the history file go
HISTORY_FOLDER= .cache
+# This is where the config file go
+CONFIG_FOLDER= .config
# Change these to your liking or use `make CC=gcc` etc
#CC = cc
@@ -36,6 +38,8 @@ CFLAGS += -DDFLT_EDITOR=\"vim\"
CFLAGS += -DUSECOLORS
# Command history file, relative to HISTORY_FOLDER directory. Comment out to disable commandline history
CFLAGS += -DHISTORY_FILE=\"sc-iminfo\" -DHISTORY_FOLDER=\"$(HISTORY_FOLDER)\"
+# Configuration file, relative to CONFIG_FOLDER directory
+CFLAGS += -DCONFIG_FILE=\"scimrc\" -DCONFIG_FOLDER=\"$(CONFIG_FOLDER)\"
# Input mode history. Same as previous, but for insert mode commands
CFLAGS += -DINS_HISTORY_FILE=\"sc-iminfo\"
# Comment out to disable undo/redo support
diff --git a/src/file.c b/src/file.c
index 2589cb6..798f05f 100644
--- a/src/file.c
+++ b/src/file.c
@@ -136,9 +136,10 @@ void loadrc(void) {
char * home;
if ((home = getenv("HOME"))) {
- memset(rcpath, 0, sizeof(rcpath));
- strncpy(rcpath, home, sizeof(rcpath) - (sizeof("/.scimrc") + 1));
- strcat(rcpath, "/.scimrc");
+ char config_folder[PATHLEN];
+ sprintf(config_folder, "%s/%s", home,CONFIG_FOLDER);
+ mkdir(config_folder,0777);
+ sprintf(rcpath, "%s/%s/%s", home,CONFIG_FOLDER,CONFIG_FILE);
(void) readfile(rcpath, 0);
}
*curfile = '\0';
@@ -625,7 +626,7 @@ sc_readfile_result readfile(char * fname, int eraseflg) {
#ifdef AUTOBACKUP
// Check if curfile is set and backup exists..
- if (str_in_str(fname, ".scimrc") == -1 && strlen(curfile) &&
+ if (str_in_str(fname, CONFIG_FILE) == -1 && strlen(curfile) &&
backup_exists(curfile) && strcmp(fname, curfile)) {
if (modflg) {
// TODO - force load with '!' ??
@@ -675,7 +676,7 @@ sc_readfile_result readfile(char * fname, int eraseflg) {
// Check if file is a correct format
int len = strlen(fname);
if (! strcmp( & fname[len-3], ".sc") ||
- (len > 6 && ! strcasecmp( & fname[len-7], ".scimrc"))) {
+ (len >= strlen(CONFIG_FILE) && ! strcasecmp( & fname[len-strlen(CONFIG_FILE)], CONFIG_FILE))) {
// pass
// If file is an xlsx file, we import it