diff mbox series

mystring: Add dotdir

Message ID ZlMRwiyOhfrIz2mY@gondor.apana.org.au (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series mystring: Add dotdir | expand

Commit Message

Herbert Xu May 26, 2024, 10:41 a.m. UTC
Merge all occurrences of "." into dotdir.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
 src/cd.c       | 2 +-
 src/expand.c   | 2 +-
 src/mystring.c | 1 +
 src/mystring.h | 1 +
 src/var.c      | 2 +-
 5 files changed, 5 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/src/cd.c b/src/cd.c
index 1ef1dc5..bcd1484 100644
--- a/src/cd.c
+++ b/src/cd.c
@@ -126,7 +126,7 @@  dotdot:
 		}
 	}
 	if (!*dest)
-		dest = ".";
+		dest = dotdir;
 	path = bltinlookup("CDPATH");
 	while (p = path, (len = padvance_magic(&path, dest, 0)) >= 0) {
 		c = *p;
diff --git a/src/expand.c b/src/expand.c
index d8b354c..e7e8ce0 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -1358,7 +1358,7 @@  expmeta(char *name, unsigned name_len, unsigned expdir_len)
 	cp = expdir;
 	expdir_len = enddir - cp;
 	if (!expdir_len)
-		cp = ".";
+		cp = dotdir;
 	if ((dirp = opendir(cp)) == NULL)
 		return;
 	if (*endname == 0) {
diff --git a/src/mystring.c b/src/mystring.c
index 978bbb5..7bf61e3 100644
--- a/src/mystring.c
+++ b/src/mystring.c
@@ -68,6 +68,7 @@  const char cqchars[] = {
 };
 const char illnum[] = "Illegal number: %s";
 const char homestr[] = "HOME";
+const char dotdir[] = ".";
 
 /*
  * equal - #defined in mystring.h
diff --git a/src/mystring.h b/src/mystring.h
index d178990..0857c32 100644
--- a/src/mystring.h
+++ b/src/mystring.h
@@ -57,6 +57,7 @@  extern const char cqchars[];
 #define qchars (cqchars + 1)
 extern const char illnum[];
 extern const char homestr[];
+extern const char dotdir[];
 
 #if 0
 void scopyn(const char *, char *, int);
diff --git a/src/var.c b/src/var.c
index bb5420a..e2102c3 100644
--- a/src/var.c
+++ b/src/var.c
@@ -143,7 +143,7 @@  INIT {
 
 	p = lookupvar("PWD");
 	if (p)
-		if (*p != '/' || stat64(p, &st1) || stat64(".", &st2) ||
+		if (*p != '/' || stat64(p, &st1) || stat64(dotdir, &st2) ||
 		    st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino)
 			p = 0;
 	setpwd(p, 0);