summaryrefslogtreecommitdiffstats
path: root/src/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/file.c')
-rw-r--r--src/file.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/file.c b/src/file.c
index 7e80177..90b4fdc 100644
--- a/src/file.c
+++ b/src/file.c
@@ -38,7 +38,6 @@ extern int yyparse(void);
/* erase the database (tbl, etc.) */
void erasedb() {
int r, c;
- char * home;
for (c = 0; c <= maxcol; c++) {
fwidth[c] = DEFWIDTH;
@@ -74,19 +73,23 @@ void erasedb() {
optimize = 0;
currow = curcol = 0;
- // Load $HOME/.scimrc if present.
- if ((home = getenv("HOME"))) {
- strcpy(curfile, home);
- strcat(curfile, "/.scimrc");
- if ((c = open(curfile, O_RDONLY)) > -1) {
- close(c);
- (void) readfile(curfile, 0);
- }
- }
+ loadrc();
*curfile = '\0';
}
+void loadrc(void) {
+ char rcpath[PATHLEN];
+ char * home;
+
+ if ((home = getenv("HOME"))) {
+ memset(rcpath, 0, sizeof(rcpath));
+ strncpy(rcpath, home, sizeof(rcpath) - (sizeof("/.scimrc") + 1));
+ strcat(rcpath, "/.scimrc");
+ (void) readfile(rcpath, 0);
+ }
+}
+
// function that checks if a file exists.
// returns 1 if so. returns 0 otherwise.
int file_exists(const char * fname) {