devilhorns pushed a commit to branch master.

http://git.enlightenment.org/apps/express.git/commit/?id=fe71b6356e8e1b764859aa4afc9dd305be2a4a64

commit fe71b6356e8e1b764859aa4afc9dd305be2a4a64
Author: Vincent Torri <vincent.to...@gmail.com>
Date:   Fri Aug 14 10:24:25 2015 +0200

    express: Use strchr to have O(n) complexity and not O(n^2)
---
 src/bin/utils.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/bin/utils.c b/src/bin/utils.c
index 5bd00ce..24fb308 100644
--- a/src/bin/utils.c
+++ b/src/bin/utils.c
@@ -106,6 +106,7 @@ _util_user_fullname_get(void)
 #else
    char *usr;
    struct passwd *p;
+   char *tmp;
    size_t n;
 
    if (!(usr = getenv("LOGNAME")))
@@ -115,7 +116,11 @@ _util_user_fullname_get(void)
    if ((!p) && (errno == 0)) return NULL;
    if (!p) return NULL;
 
-   n = strcspn(p->pw_gecos, ",");
+   tmp = strchr(p->pw_gecos, ',');
+   if (!tmp)
+     return NULL;
+
+   n = tmp - p->pw_gecos;
    if (n > (sizeof(fullname) - 1)) n = (sizeof(fullname) - 1);
 
    memcpy(fullname, p->pw_gecos, n);

-- 


Reply via email to