From 19596f0f429ee2f331454deecf838a3b8e49d5b3 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sat, 4 Aug 2018 18:39:24 +0200 Subject: [PATCH] add search in current directory Patch provided by Uros Platise https://sourceforge.net/p/ngspice/ngspice/merge-requests/4/ --- src/frontend/inpcom.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index 659d11f93..106932352 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -1228,7 +1228,22 @@ inp_pathresolve_at(char *name, char *dir) } } - /* concatenate them */ + /* + * Try in current dir and then in the actual dir the file was read. + * Current dir . is needed to correctly support absolute paths in sourcepath + */ + + strcpy(buf, "."); + + end = strchr(buf, '\0'); + if (end[-1] != DIR_TERM) + *end++ = DIR_TERM; + + strcpy(end, name); + + char *r = inp_pathresolve(buf); + if (r) + return r; strcpy(buf, dir);