Merge branch 'master' of ssh://dio.dreamhost.com/~/repos.nelsonferreira.com/git/sxema...
authorNelson Ferreira <nelson.ferreira@ieee.org>
Sat, 3 Mar 2012 05:33:34 +0000 (00:33 -0500)
committerNelson Ferreira <nelson.ferreira@ieee.org>
Sat, 3 Mar 2012 05:33:34 +0000 (00:33 -0500)
12 files changed:
lib-src/etags.c
lib-src/fakemail.c
lib-src/gnuclient.c
lib-src/gnuserv.c
lib-src/movemail.c
lib-src/ootags.c
lib-src/pop.c
lib-src/yow.c
src/dumper.c
src/fileio.c
src/sxe-utils.h
src/sysdep.h

index 15bad19..3c787fc 100644 (file)
@@ -233,7 +233,12 @@ extern int optind, opterr;
 
 #define bool int
 
-#define xstrncpy(d_,s_,l_) do { char* dst_=d_; dst_[0]='\0'; strncat((dst_),(s_),(l_)-1); } while(0)
+#define xstrncpy(d_,s_,l_)                     \
+       do {                                    \
+               char* dst_=d_;                  \
+               dst_[0]='\0';                   \
+               strncat((dst_),(s_),(l_)-1);    \
+       } while(0)
 
 typedef void Lang_function __P((FILE *));
 
index a2b67b7..9da9121 100644 (file)
@@ -128,6 +128,13 @@ struct linebuffer lb;
 #define MAIL_PROGRAM_NAME "/bin/mail"
 #endif
 
+#define xstrncpy(d_,s_,l_)                     \
+       do {                                    \
+               char* dst_=d_;                  \
+               dst_[0]='\0';                   \
+               strncat((dst_),(s_),(l_)-1);    \
+       } while(0)
+
 static const char *my_name;
 static char *the_date;
 static char *the_user;
@@ -311,23 +318,23 @@ static line_list make_file_preface(void)
        /* the_user */
        the_user_len = strlen(temp);
        the_user = alloc_string(the_user_len + 1);
-       strncpy(the_user, the_user_len, temp);
+       xstrncpy(the_user, the_user_len, temp);
        /* alloc the_string */
        the_string_len = 3 + prefix_length + the_user_len + date_length;
        the_string = alloc_string(the_string_len);
        temp_len = the_string_len;
        temp = the_string;
-       strncpy(temp, temp_len, FROM_PREFIX);
+       xstrncpy(temp, temp_len, FROM_PREFIX);
 
        temp = &temp[prefix_length];
        *temp++ = ' ';
        temp_len -= prefix_length + 1;
-       strncpy(temp, temp_len, the_user);
+       xstrncpy(temp, temp_len, the_user);
 
        temp = &temp[the_user_len];
        *temp++ = ' ';
        temp_len -= the_user_len + 1;
-       strncpy(temp, temp_len, the_date);
+       xstrncpy(temp, temp_len, the_date);
 
        result = new_list();
        result->string = the_string;
@@ -563,7 +570,7 @@ static header read_header(void)
                }
                *next_line = new_list();
                (*next_line)->string = alloc_string((size_t) length);
-               strncpy(((*next_line)->string), length, line);
+               xstrncpy(((*next_line)->string), length, line);
                next_line = &((*next_line)->continuation);
                *next_line = NIL;
 
@@ -610,7 +617,7 @@ int main(int argc, char *argv[])
        the_header = read_header();
        command_line_len = name_length + args_size(the_header);
        command_line = alloc_string(command_line_len);
-       strncpy(command_line, command_line_len, mail_program_name);
+       xstrncpy(command_line, command_line_len, mail_program_name);
        parse_header(the_header, &command_line[name_length]);
 
        the_pipe = popen(command_line, "w");
index 5328b97..04dba9e 100644 (file)
@@ -59,6 +59,13 @@ char gnuserv_version[] = "gnuclient version " GNUSERV_VERSION;
 
 #include <signal.h>
 
+#define xstrncpy(d_,s_,l_)                     \
+       do {                                    \
+               char* dst_=d_;                  \
+               dst_[0]='\0';                   \
+               strncat((dst_),(s_),(l_)-1);    \
+       } while(0)
+
 #if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && \
     !defined(INTERNET_DOMAIN_SOCKETS)
 int main(int argc, char *argv[])
@@ -400,7 +407,7 @@ int main(int argc, char *argv[])
                                        break;
                                case 'r':
                                        GET_ARGUMENT(remotearg, "-r");
-                                       strncpy(remotepath, remotearg, sizeof(remotepath));
+                                       xstrncpy(remotepath, remotearg, sizeof(remotepath));
                                        remotepath[sizeof(remotepath)-1]='\0';
                                        rflg = 1;
                                        break;
@@ -545,7 +552,7 @@ int main(int argc, char *argv[])
                                         * to this machine */
                                if ((ptr = getenv("GNU_NODE")) != NULL) {
                                        /* user specified a path */
-                                       strncpy(remotepath, ptr, sizeof(remotepath)-1);
+                                       xstrncpy(remotepath, ptr, sizeof(remotepath)-1);
                                        remotepath[sizeof(remotepath)-1]='\0';
                                }
                        }
index 103765c..08649b7 100644 (file)
@@ -59,6 +59,13 @@ char gnuserv_version[] = "gnuserv version" GNUSERV_VERSION;
 #include <string.h>
 #endif                         /* HAVE_STRING_H */
 
+#define xstrncpy(d_,s_,l_)                     \
+       do {                                    \
+               char* dst_=d_;                  \
+               dst_[0]='\0';                   \
+               strncat((dst_),(s_),(l_)-1);    \
+       } while(0)
+
 
 #if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && \
     !defined(INTERNET_DOMAIN_SOCKETS)
@@ -186,7 +193,7 @@ handle_ipc_request(struct msgbuf *msgp)
        }
        /* if */
        msgctl(ipc_qid, IPC_STAT, &msg_st);
-       strncpy(buf, msgp->mtext, len);
+       xstrncpy(buf, msgp->mtext, len);
        /* terminate buf */
        buf[len] = '\0';
 
index f80b95d..9d75782 100644 (file)
@@ -143,6 +143,14 @@ static int pop_search_top(popserver server, int msgno, int lines,
                          struct re_pattern_buffer *regexp);
 #endif
 
+
+#define xstrncpy(d_,s_,l_)                     \
+       do {                                    \
+               char* dst_=d_;                  \
+               dst_[0]='\0';                   \
+               strncat((dst_),(s_),(l_)-1);    \
+       } while(0)
+
 int verbose = 0;
 #ifdef MAIL_USE_POP
 int reverse = 0;
@@ -681,9 +689,9 @@ static char *concat(char *s1, char *s2, char *s3)
        int len1 = strlen(s1), len2 = strlen(s2), len3 = strlen(s3);
        char *result = (char *)xmalloc(len1 + len2 + len3 + 1);
 
-       strncpy(result, s1, len1+1);
-       strncpy(result + len1, s2, len2+1);
-       strncpy(result + len1 + len2, s3, len3+1);
+       xstrncpy(result, s1, len1+1);
+       xstrncpy(result + len1, s2, len2+1);
+       xstrncpy(result + len1 + len2, s3, len3+1);
        *(result + len1 + len2 + len3) = '\0';
 
        return result;
@@ -847,7 +855,7 @@ pop_retr(popserver server, int msgno, int (*action) (char *, FILE *),
        int ret;
 
        if (pop_retrieve_first(server, msgno, &line)) {
-               strncpy(Errmsg, pop_error, sizeof(Errmsg));
+               xstrncpy(Errmsg, pop_error, sizeof(Errmsg));
                Errmsg[sizeof(Errmsg) - 1] = '\0';
                return (POP_ERROR);
        }
@@ -864,7 +872,7 @@ pop_retr(popserver server, int msgno, int (*action) (char *, FILE *),
        }
 
        if (ret) {
-               strncpy(Errmsg, pop_error, sizeof(Errmsg));
+               xstrncpy(Errmsg, pop_error, sizeof(Errmsg));
                Errmsg[sizeof(Errmsg) - 1] = '\0';
                return (POP_ERROR);
        }
@@ -882,7 +890,7 @@ pop_search_top(popserver server, int msgno, int lines,
        int match = POP_DONE;
 
        if (pop_top_first(server, msgno, lines, &line)) {
-               strncpy(Errmsg, pop_error, sizeof(Errmsg));
+               xstrncpy(Errmsg, pop_error, sizeof(Errmsg));
                Errmsg[sizeof(Errmsg) - 1] = '\0';
                return (POP_ERROR);
        }
@@ -906,7 +914,7 @@ pop_search_top(popserver server, int msgno, int lines,
        }
 
        if (ret) {
-               strncpy(Errmsg, pop_error, sizeof(Errmsg));
+               xstrncpy(Errmsg, pop_error, sizeof(Errmsg));
                Errmsg[sizeof(Errmsg) - 1] = '\0';
                return (POP_ERROR);
        }
index 5f897a6..116bd3f 100644 (file)
@@ -174,6 +174,14 @@ void oo_browser_check_and_clear_structtype(void);
 # define xrnew(op,n,Type) ((Type *) xrealloc ((op), (n) * sizeof (Type)))
 #endif
 
+#define xstrncpy(d_,s_,l_)                     \
+       do {                                    \
+               char* dst_=d_;                  \
+               dst_[0]='\0';                   \
+               strncat((dst_),(s_),(l_)-1);    \
+       } while(0)
+
+
 typedef int bool;
 
 typedef void Lang_function(FILE *);
@@ -2387,7 +2395,7 @@ bool *is_func_or_var;             /* OUT: function or variable found */
                        objdef = omethodtag;
                        methodlen = len;
                        grow_linebuffer(&token_name, methodlen + 1);
-                       strncpy(token_name.buffer, str, len);
+                       xstrncpy(token_name.buffer, str, len);
                        token_name.buffer[methodlen] = '\0';
                        token_name.len = methodlen;
                        return TRUE;
@@ -2829,7 +2837,7 @@ FILE *inf;                        /* input file */
                                                                    (&token_name,
                                                                     toklen +
                                                                     1);
-                                                               strncpy
+                                                               xstrncpy
                                                                    (token_name.
                                                                     buffer,
                                                                     newlb.
@@ -3903,7 +3911,7 @@ FILE *inf;
 
                        /* save all values for later tagging */
                        grow_linebuffer(&tline, lb.len + 1);
-                       strncpy(tline.buffer, lb.buffer, lb.len);
+                       xstrncpy(tline.buffer, lb.buffer, lb.len);
                        save_lineno = lineno;
                        save_lcno = linecharno;
 
@@ -4292,7 +4300,7 @@ FILE *inf;
                        else if (len + 1 > allocated)
                                last = xrnew(last, len + 1, char);
                        allocated = len + 1;
-                       strncpy(last, cp, len);
+                       xstrncpy(last, cp, len);
                        last[len] = '\0';
                }
        }
@@ -4447,7 +4455,7 @@ FILE *inf;
                        else if (len + 1 > allocated)
                                last = xrnew(last, len + 1, char);
                        allocated = len + 1;
-                       strncpy(last, cp, len);
+                       xstrncpy(last, cp, len);
                        last[len] = '\0';
                }
        }
@@ -4746,7 +4754,7 @@ struct re_registers *regs;
                        /* Using "dig2" satisfies my debugger.  Bleah. */
                        dig = *out - '0';
                        diglen = regs->end[dig] - regs->start[dig];
-                       strncpy(t, in + regs->start[dig], diglen);
+                       xstrncpy(t, in + regs->start[dig], diglen);
                        t += diglen;
                } else
                        *t++ = *out;
@@ -4917,7 +4925,7 @@ int len;
        register char *dp;
 
        dp = xnew(len + 1, char);
-       strncpy(dp, cp, len);
+       xstrncpy(dp, cp, len);
        dp[len] = '\0';
        return dp;
 }
index 9945443..931c9b0 100644 (file)
@@ -138,6 +138,13 @@ int pop_debug = 0;
 #define min(a,b) (((a) < (b)) ? (a) : (b))
 #endif
 
+#define xstrncpy(d_,s_,l_)                     \
+       do {                                    \
+               char* dst_=d_;                  \
+               dst_[0]='\0';                   \
+               strncat((dst_),(s_),(l_)-1);    \
+       } while(0)
+
 /*
  * Function: pop_open (char *host, char *username, char *password,
  *                    int flags)
@@ -345,7 +352,7 @@ pop_stat (server, count, size)
 
        if (strncmp (fromserver, "+OK ", 4)) {
                if (0 == strncmp (fromserver, "-ERR", 4)) {
-                       strncpy (pop_error, fromserver, ERROR_MAX);
+                       xstrncpy (pop_error, fromserver, ERROR_MAX);
                } else {
                        strcpy (pop_error,
                                "Unexpected response from POP "
@@ -435,7 +442,7 @@ pop_list (server, message, IDs, sizes)
                }
                if (strncmp (fromserver, "+OK ", 4)) {
                        if (! strncmp (fromserver, "-ERR", 4)) {
-                               strncpy (pop_error, fromserver, ERROR_MAX);
+                               xstrncpy (pop_error, fromserver, ERROR_MAX);
                        } else {
                                strcpy (pop_error,
                                        "Unexpected response from "
@@ -680,7 +687,7 @@ pop_multi_first (server, command, response)
        }
 
        if (0 == strncmp (*response, "-ERR", 4)) {
-               strncpy (pop_error, *response, ERROR_MAX);
+               xstrncpy (pop_error, *response, ERROR_MAX);
                return (-1);
        } else if (0 == strncmp (*response, "+OK", 3)) {
                for (*response += 3; **response == ' ';
@@ -848,7 +855,7 @@ pop_last (server)
                return (-1);
 
        if (! strncmp (fromserver, "-ERR", 4)) {
-               strncpy (pop_error, fromserver, ERROR_MAX);
+               xstrncpy (pop_error, fromserver, ERROR_MAX);
                return (-1);
        } else if (strncmp (fromserver, "+OK ", 4)) {
                strcpy (pop_error, "Unexpected response from server in pop_last");
@@ -1385,7 +1392,7 @@ getok (server)
        if (! strncmp (fromline, "+OK", 3))
                return (0);
        else if (! strncmp (fromline, "-ERR", 4)) {
-               strncpy (pop_error, fromline, ERROR_MAX);
+               xstrncpy (pop_error, fromline, ERROR_MAX);
                pop_error[ERROR_MAX-1] = '\0';
                return (-1);
        } else {
index 3dad330..9d66d72 100644 (file)
 static void yow(FILE * fp);
 static void setup_yow(FILE * fp);
 
+#define xstrncpy(d_,s_,l_)                     \
+       do {                                    \
+               char* dst_=d_;                  \
+               dst_[0]='\0';                   \
+               strncat((dst_),(s_),(l_)-1);    \
+       } while(0)
+
+
 int
 main(int argc, char *argv[])
 {
@@ -41,7 +49,7 @@ main(int argc, char *argv[])
        char file[BUFSIZ];
 
        if (argc > 2 && !strcmp(argv[1], "-f")) {
-               strncpy(file, argv[2], sizeof(file)-1);
+               xstrncpy(file, argv[2], sizeof(file)-1);
                file[sizeof(file)-1]='\0';
        } else {
 #ifdef PATH_DATA
index 1b782a9..af22e0c 100644 (file)
@@ -1375,7 +1375,7 @@ int pdump_load(const char *argv0)
                /* invocation-name includes a directory component -- presumably it
                   is relative to cwd, not $PATH */
                assert(strlen(dir) < sizeof(exe_path));
-               strncpy(exe_path, dir, sizeof(exe_path)-1);
+               xstrncpy(exe_path, dir, sizeof(exe_path));
                exe_path[sizeof(exe_path)-1]='\0';
        } else {
                const char *path = getenv("PATH");
@@ -1407,7 +1407,7 @@ int pdump_load(const char *argv0)
                                remain--;
                        }
                        if (remain > 0) {
-                               strncpy(w, name, remain);
+                               xstrncpy(w, name, remain);
                                w[remain]='\0';
                        }
 
index 995a573..bae112a 100644 (file)
@@ -601,17 +601,18 @@ get a current directory to run processes in.
        return Ffile_name_directory(filename);
 }
 \f
-static char *file_name_as_directory(char *out, char *in)
+static char *file_name_as_directory(char *out, const char *in, size_t len)
 {
        /* This function cannot GC */
        int size = strlen(in);
 
        if (size == 0) {
+               assert(len >= 3);
                out[0] = '.';
                out[1] = DIRECTORY_SEP;
                out[2] = '\0';
        } else {
-               strcpy(out, in);
+               xstrncpy(out, in, len);
                /* Append a slash if necessary */
                if (!IS_ANY_SEP(out[size - 1])) {
                        out[size] = DIRECTORY_SEP;
@@ -633,8 +634,9 @@ except for (file-name-as-directory \"\") => \"./\".
       (filename))
 {
        /* This function can GC.  GC checked 2000-07-28 ben */
-       char *buf;
-       Lisp_Object handler;
+       size_t len = 0;
+       char *buf = NULL;
+       Lisp_Object handler = Qnil;
 
        CHECK_STRING(filename);
 
@@ -645,9 +647,10 @@ except for (file-name-as-directory \"\") => \"./\".
                return call2_check_string(handler, Qfile_name_as_directory,
                                          filename);
 
-       buf = (char *)alloca(XSTRING_LENGTH(filename) + 10);
+       len = XSTRING_LENGTH(filename) + 10;
+       buf = (char *)alloca(len);
        return build_string(file_name_as_directory
-                           (buf, (char *)XSTRING_DATA(filename)));
+                           (buf, (char*)XSTRING_DATA(filename), len));
 }
 \f
 /*
@@ -657,13 +660,13 @@ except for (file-name-as-directory \"\") => \"./\".
  * Value is nonzero if the string output is different from the input.
  */
 
-static int directory_file_name(const char *src, char *dst)
+static int directory_file_name(const char *src, char *dst, size_t len)
 {
        /* This function cannot GC */
        long slen = strlen(src);
        /* Process as Unix format: just remove any final slash.
           But leave "/" unchanged; do not change it to "".  */
-       strcpy(dst, src);
+       xstrncpy(dst, src, len);
        if (slen > 1 && IS_DIRECTORY_SEP(dst[slen - 1])
            )
                dst[slen - 1] = 0;
@@ -680,7 +683,8 @@ In Unix-syntax, this function just removes the final slash.
       (directory))
 {
        /* This function can GC.  GC checked 2000-07-28 ben */
-       char *buf;
+       size_t len = 0;
+       char *buf = NULL;
        Lisp_Object handler;
 
        CHECK_STRING(directory);
@@ -696,8 +700,9 @@ In Unix-syntax, this function just removes the final slash.
        if (!NILP(handler))
                return call2_check_string(handler, Qdirectory_file_name,
                                          directory);
-       buf = (char *)alloca(XSTRING_LENGTH(directory) + 20);
-       directory_file_name((char *)XSTRING_DATA(directory), buf);
+       len = XSTRING_LENGTH(directory) + 20;
+       buf = (char *)alloca(len);
+       directory_file_name((char *)XSTRING_DATA(directory), buf, len);
        return build_string(buf);
 }
 \f
@@ -1024,12 +1029,12 @@ See also the function `substitute-in-file-name'.
 
        if (newdir) {
                if (nm[0] == 0 || IS_DIRECTORY_SEP(nm[0]))
-                       strcpy((char *)target, (char *)newdir);
+                       xstrncpy((char *)target, (char *)newdir, tlen);
                else
-                       file_name_as_directory((char *)target, (char *)newdir);
+                       file_name_as_directory((char *)target, (char *)newdir, tlen);
        }
 
-       strcat((char *)target, (char *)nm);
+       xstrncat((char *)target, (char *)nm, tlen);
 
        /* ASSERT (IS_DIRECTORY_SEP (target[0])) if not VMS */
 
@@ -1245,6 +1250,7 @@ If `/~' appears, all of FILENAME through that `/' is discarded.
        Bufbyte *target = 0;
        int total = 0;
        int substituted = 0;
+       size_t avail = 0;
        Bufbyte *xnm;
        Lisp_Object handler;
 
@@ -1321,19 +1327,22 @@ If `/~' appears, all of FILENAME through that `/' is discarded.
 
        /* If substitution required, recopy the filename and do it */
        /* Make space in stack frame for the new copy */
-       xnm = (Bufbyte *) alloca(XSTRING_LENGTH(filename) + total + 1);
+       avail = XSTRING_LENGTH(filename) + total + 1;
+       xnm = (Bufbyte *) alloca(avail);
        x = xnm;
 
        /* Copy the rest of the name through, replacing $ constructs with values */
        for (p = nm; *p;)
-               if (*p != '$')
+               if (*p != '$') {
                        *x++ = *p++;
-               else {
+                       avail--;
+               } else {
                        p++;
                        if (p == endp)
                                goto badsubst;
                        else if (*p == '$') {
                                *x++ = *p++;
+                               avail--;
                                continue;
                        } else if (*p == '{') {
                                o = ++p;
@@ -1359,8 +1368,9 @@ If `/~' appears, all of FILENAME through that `/' is discarded.
                        if (!o)
                                goto badvar;
 
-                       strcpy((char *)x, (char *)o);
+                       xstrncpy((char *)x, (char *)o, avail);
                        x += strlen((char *)o);
+                       avail -= strlen((char *)o);
                }
 
        *x = 0;
index 7f6bfe0..8bc985f 100644 (file)
@@ -391,4 +391,119 @@ char *xstrdup(const char *);
 # endif         /* ERROR_CHECK_MALLOC */
 #endif /* BDWGC */
 
+\f
+/* str funs */
+#define xstrlen                strlen
+#define xstrcmp                strcmp
+#define xstrncmp       strncmp
+#define xstrncat       strncat
+
+extern_inline char*
+xstrncpy(char* target, const char*source, size_t len)
+       __attribute__((always_inline));
+extern_inline char*
+xstrncpy(char* target, const char*source, size_t len)
+{
+       *target ='\0';
+       return strncat(target,source,len-1);
+}
+
+#if !defined(FORBID_STRCPY)
+#  define xstrcat              strcat
+#  define xstrcpy              strcpy
+#  if defined(HAVE_STPCPY)
+#     define xstpcpy   stpcpy
+#   else
+extern_inline char*
+xstpcpy(char *target, const char *source)
+       __attribute__((always_inline));
+extern_inline char*
+xstpcpy(char *target, const char *source)
+{
+       char *p = target;
+       size_t len = xstrlen(source);
+
+       strcpy(target, source);
+       p += len;
+       return p;
+}
+#   endif
+#else
+#  if defined(strcpy)
+#    undef strcpy
+#  endif
+#  define strcpy  no_strcpy
+extern_inline char*
+no_strcpy(char*,const char*)
+       __attribute__((always_inline));
+extern_inline char*
+no_strcpy(char * SXE_UNUSED(target),const char * SXE_UNUSED(source))
+{
+       assert(0);
+       return NULL;
+}
+#  if defined(strcat)
+#    undef strcat
+#  endif
+#  define strcat  no_strcat
+extern_inline char*
+no_strcat(char*,const char*)
+       __attribute__((always_inline));
+extern_inline char*
+no_strcat(char * SXE_UNUSED(target), const char* SXE_UNUSED(source))
+{
+       assert(0);
+       return NULL;
+}
+#  if defined(stpcpy)
+#    undef stpcpy
+#  endif
+#  define stpcpy       no_stpcpy
+#  define xstpcpy      no_stpcpy
+extern_inline char*
+no_stpcpy(char*,const char*)
+       __attribute__((always_inline));
+extern_inline char*
+no_stpcpy(char* SXE_UNUSED(target),const char* SXE_UNUSED(source))
+{
+       assert(0);
+       return NULL;
+}
+#endif
+
+
+#if defined HAVE_STPNCPY
+# define xstpncpy      stpncpy
+#else
+extern_inline char*
+xstpncpy(char *target, const char *source, size_t len)
+       __attribute__((always_inline));
+extern_inline char*
+xstpncpy(char *target, const char *source, size_t len)
+{
+       char *p = target;
+       xstrncpy(target, source, len);
+       p += len;
+       return p;
+}
+#endif /* !HAVE_STPNCPY */
+
+#define xmemcmp                memcmp
+#define xmemcpy                memcpy
+
+
+
+extern_inline size_t
+xmin_size_t(size_t a, size_t b)
+       __attribute__((always_inline));
+extern_inline size_t
+xmin_size_t(size_t a, size_t b)
+{
+       if (a < b) {
+               return a;
+       } else {
+               return b;
+       }
+}
+
 #endif
index c506d26..4ee497d 100644 (file)
@@ -177,66 +177,10 @@ extern int h_errno;
 char *xrealpath(const char *path, char restrict resolved_path[]);
 #endif
 
-extern_inline size_t xmin_size_t(size_t a, size_t b);
 extern_inline void x__dirname(char *restrict res, const char *file, size_t len);
 extern_inline size_t x__dirlen(const char *file, size_t len);
 extern_inline char *xdirname(const char *file);
 
-\f
-/* str funs */
-/* thought these were defined already :O */
-#define xstrlen                strlen
-#define xstrcmp                strcmp
-#define xstrcat                strcat
-#define xstrncmp       strncmp
-#define xstrncpy       strncpy
-#define xstrncat       strncat
-#if defined HAVE_STPCPY
-# define xstpcpy       stpcpy
-#else
-extern_inline char*
-xstpcpy(char *target, const char *source)
-       __attribute__((always_inline));
-extern_inline char*
-xstpcpy(char *target, const char *source)
-{
-       char *p = target;
-       size_t len = xstrlen(source);
-
-       strcpy(target, source);
-       p += len;
-       return p;
-}
-#endif /* !HAVE_STPCPY */
-#if defined HAVE_STPNCPY
-# define xstpncpy      stpncpy
-#else
-extern_inline char*
-xstpncpy(char *target, const char *source, size_t len)
-       __attribute__((always_inline));
-extern_inline char*
-xstpncpy(char *target, const char *source, size_t len)
-{
-       char *p = target;
-       strncpy(target, source, len);
-       p += len;
-       return p;
-}
-#endif /* !HAVE_STPNCPY */
-
-#define xmemcmp                memcmp
-#define xmemcpy                memcpy
-
-extern_inline size_t
-xmin_size_t(size_t a, size_t b)
-{
-       if (a < b) {
-               return a;
-       } else {
-               return b;
-       }
-}
-
 \f
 /* big dirname magic, some of it stolen from dirname.c from coreutils 6.9 */
 /* POSIX says:
@@ -257,6 +201,9 @@ xmin_size_t(size_t a, size_t b)
 #define ISSLASH(C)     ((C) == DIRECTORY_SEPARATOR)
 #endif
 
+extern_inline size_t
+x__dirlen(const char *file, size_t len)
+       __attribute__((always_inline));
 extern_inline size_t
 x__dirlen(const char *file, size_t len)
 {
@@ -273,6 +220,9 @@ x__dirlen(const char *file, size_t len)
        return len;
 }
 
+extern_inline void
+x__dirname(char *restrict res, const char *file, size_t len)
+       __attribute__((always_inline));
 #if defined(HAVE_DIRNAME) && defined(DIRNAME_SIDE_EFFECT)
 extern_inline void
 x__dirname(char *restrict res, const char *file, size_t len)
@@ -305,6 +255,9 @@ x__dirname(char *restrict res, const char *file, size_t len)
 }
 #endif
 
+extern_inline char*
+xdirname(const char *file)
+       __attribute__((always_inline));
 extern_inline char*
 xdirname(const char *file)
 {