apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject svn commit: r279565 - /apr/apr/trunk/file_io/unix/dir.c
Date Thu, 08 Sep 2005 13:55:33 GMT
Author: jorton
Date: Thu Sep  8 06:55:29 2005
New Revision: 279565

URL: http://svn.apache.org/viewcvs?rev=279565&view=rev
Log:
* file_io/unix/dir.c (apr_dir_read): Avoid an unnecessary
strlen(dirname) each time a stat call is required by using the
apr_cpystrn return value.

Modified:
    apr/apr/trunk/file_io/unix/dir.c

Modified: apr/apr/trunk/file_io/unix/dir.c
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/file_io/unix/dir.c?rev=279565&r1=279564&r2=279565&view=diff
==============================================================================
--- apr/apr/trunk/file_io/unix/dir.c (original)
+++ apr/apr/trunk/file_io/unix/dir.c Thu Sep  8 06:55:29 2005
@@ -232,12 +232,16 @@
     if (wanted)
     {
         char fspec[APR_PATH_MAX];
-        int off;
-        apr_cpystrn(fspec, thedir->dirname, sizeof(fspec));
-        off = strlen(fspec);
-        if ((fspec[off - 1] != '/') && (off + 1 < sizeof(fspec)))
-            fspec[off++] = '/';
-        apr_cpystrn(fspec + off, thedir->entry->d_name, sizeof(fspec) - off);
+        char *end;
+
+        end = apr_cpystrn(fspec, thedir->dirname, sizeof fspec);
+
+        if (end > fspec && end[-1] != '/' && (end < fspec + APR_PATH_MAX))
+            *end++ = '/';
+
+        apr_cpystrn(end, thedir->entry->d_name, 
+                    sizeof fspec - (end - fspec));
+
         ret = apr_stat(finfo, fspec, APR_FINFO_LINK | wanted, thedir->pool);
         /* We passed a stack name that will disappear */
         finfo->fname = NULL;



Mime
View raw message