Remove sbr/pwd.c file, moving the pwd() function into sbr/utils.c.
authorJosh Bressers <josh@bress.net>
Tue, 3 Jan 2006 01:08:33 +0000 (01:08 +0000)
committerJosh Bressers <josh@bress.net>
Tue, 3 Jan 2006 01:08:33 +0000 (01:08 +0000)
ChangeLog
h/utils.h
sbr/Makefile.in
sbr/pwd.c [deleted file]
sbr/utils.c

index 757d2eb..1c2fc9d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2006-01-02  Josh Bressers <josh@bress.net>
+
+       * Remove sbr/pwd.c file, moving the pwd() function into sbr/utils.c.
+
 2006-01-01  Josh Bressers <josh@bress.net>
 
        * patch #3967: Create a mh_xrealloc function to prevent mistakes when
 2006-01-01  Josh Bressers <josh@bress.net>
 
        * patch #3967: Create a mh_xrealloc function to prevent mistakes when
index 8648b3f..60e26e5 100644 (file)
--- a/h/utils.h
+++ b/h/utils.h
@@ -7,3 +7,4 @@
 
 void *mh_xmalloc(size_t);
 void *mh_xrealloc(void *, size_t);
 
 void *mh_xmalloc(size_t);
 void *mh_xrealloc(void *, size_t);
+char *pwd(void);
index 17d82e8..5f73e0f 100644 (file)
@@ -68,7 +68,7 @@ SRCS = add.c addrsbr.c ambigsw.c atooi.c brkstring.c                  \
        makedir.c mts.c norm_charmap.c                                  \
        path.c peekc.c pidwait.c pidstatus.c                            \
        print_help.c print_sw.c print_version.c push.c                  \
        makedir.c mts.c norm_charmap.c                                  \
        path.c peekc.c pidwait.c pidstatus.c                            \
        print_help.c print_sw.c print_version.c push.c                  \
-       putenv.c pwd.c refile.c remdir.c r1bindex.c                     \
+       putenv.c refile.c       remdir.c r1bindex.c                     \
        readconfig.c ruserpass.c seq_add.c seq_bits.c                   \
        seq_del.c seq_getnum.c seq_list.c seq_nameok.c                  \
        seq_print.c seq_read.c seq_save.c seq_setcur.c                  \
        readconfig.c ruserpass.c seq_add.c seq_bits.c                   \
        seq_del.c seq_getnum.c seq_list.c seq_nameok.c                  \
        seq_print.c seq_read.c seq_save.c seq_setcur.c                  \
diff --git a/sbr/pwd.c b/sbr/pwd.c
deleted file mode 100644 (file)
index 6a8b77f..0000000
--- a/sbr/pwd.c
+++ /dev/null
@@ -1,119 +0,0 @@
-
-/*
- * pwd.c -- return the current working directory
- *
- * $Id$
- *
- * This code is Copyright (c) 2002, by the authors of nmh.  See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
-
-#include <h/mh.h>
-
-static char curwd[PATH_MAX];
-
-
-char *
-pwd(void)
-{
-    register char *cp;
-
-    if (!getcwd (curwd, PATH_MAX)) {
-       admonish (NULL, "unable to determine working directory");
-       if (!mypath || !*mypath
-               || (strcpy (curwd, mypath), chdir (curwd)) == -1) {
-           strcpy (curwd, "/");
-           chdir (curwd);
-       }
-       return curwd;
-    }
-
-    if ((cp = curwd + strlen (curwd) - 1) > curwd && *cp == '/')
-       *cp = '\0';
-
-    return curwd;
-}
-
-
-#if 0
-
-/*
- * Currently commented out.  Everyone seems
- * to have a native version these days.
- */
-
-/*
- * getwd() - get the current working directory
- */
-
-int
-getwd(char *cwd)
-{
-    int found;
-    char tmp1[BUFSIZ], tmp2[BUFSIZ];
-    struct stat st1, st2, root;
-    register struct direct *dp;
-    register DIR *dd;
-
-    strcpy (cwd, "/");
-    stat ("/", &root);
-
-    for (;;) {
-       if ((dd = opendir ("..")) == NULL)
-           return -1;
-       if (stat (".", &st2) == -1 || stat ("..", &st1) == -1)
-           goto out;
-       if (st2.st_ino == root.st_ino && st2.st_dev == root.st_dev) {
-           closedir (dd);
-           return chdir (cwd);
-       }
-
-       if (st2.st_ino == st1.st_ino && st2.st_dev == st1.st_dev) {
-           closedir (dd);
-           chdir ("/");
-           if ((dd = opendir (".")) == NULL)
-               return -1;
-           if (stat (".", &st1) < 0)
-               goto out;
-           if (st2.st_dev != st1.st_dev)
-               while (dp = readdir (dd)) {
-                   if (stat (dp->d_name, &st1) == -1)
-                       goto out;
-                   if (st2.st_dev == st1.st_dev) {
-                       snprintf (tmp1, sizeof(tmp1), "%s%s", dp->d_name, cwd);
-                       strcpy (cwd + 1, tmp1);
-                       closedir (dd);
-                       return (chdir (cwd));
-                   }
-               }
-           else {
-               closedir (dd);
-               return (chdir (cwd));
-           }
-       }
-
-       found = 0;
-       while (dp = readdir (dd)) {
-           snprintf (tmp2, sizeof(tmp2), "../%s", dp->d_name);
-           if (stat (tmp2, &st1) != -1
-                   && st1.st_ino == st2.st_ino
-                   && st1.st_dev == st2.st_dev) {
-               closedir (dd);
-               found++;
-               chdir ("..");
-               snprintf (tmp1, sizeof(tmp1), "%s%s", dp->d_name, cwd);
-               strcpy (cwd + 1, tmp1);
-               break;
-           }
-       }
-       if (!found)
-           goto out;
-    }
-
-out: ;
-    closedir (dd);
-    return -1;
-}
-
-#endif
index 7dfe900..c25e02d 100644 (file)
@@ -9,7 +9,7 @@
  * complete copyright information.
  */
 
  * complete copyright information.
  */
 
-#include <h/nmh.h>
+#include <h/mh.h>
 #include <h/utils.h>
 #include <stdlib.h>
 
 #include <h/utils.h>
 #include <stdlib.h>
 
@@ -42,3 +42,24 @@ mh_xrealloc(void *ptr, size_t size)
 
     return memory;
 }
 
     return memory;
 }
+char *
+pwd(void)
+{
+    register char *cp;
+    static char curwd[PATH_MAX];
+
+    if (!getcwd (curwd, PATH_MAX)) {
+        admonish (NULL, "unable to determine working directory");
+        if (!mypath || !*mypath
+                || (strcpy (curwd, mypath), chdir (curwd)) == -1) {
+            strcpy (curwd, "/");
+            chdir (curwd);
+        }
+        return curwd;
+    }
+
+    if ((cp = curwd + strlen (curwd) - 1) > curwd && *cp == '/')
+        *cp = '\0';
+
+    return curwd;
+}