Cosmetics.
[paraslash.git] / string.c
index 8c97ccf75e22397fe3929e84340a05f00b43003c..7d8c8707d9e60fc1c322f280bff13118f0d5f768 100644 (file)
--- a/string.c
+++ b/string.c
@@ -163,13 +163,13 @@ __must_check __malloc char *para_strcat(char *a, const char *b)
 }
 
 /**
- * paraslash's version of dirname()
+ * Paraslash's version of dirname().
  *
- * \param name pointer to the full path
+ * \param name Pointer to the full path.
  *
- * Compute the directory component of \p name
+ * Compute the directory component of \p name.
  *
- * \return If \p name is \รพ NULL or the empty string, return \p NULL.
+ * \return If \p name is \p NULL or the empty string, return \p NULL.
  * Otherwise, Make a copy of \p name and return its directory component. Caller
  * is responsible to free the result.
  */
@@ -189,29 +189,27 @@ __must_check __malloc char *para_dirname(const char *name)
 }
 
 /**
- * paraslash's version of basename()
+ * Paraslash's version of basename().
  *
- * \param name Pointer to the full path
+ * \param name Pointer to the full path.
  *
- * Compute the filename component of \p name
+ * Compute the filename component of \a name.
  *
- * \return If \p name is \p NULL or the empty string, return \p NULL,
- * Otherwise, make a copy of \p name and return its filename component. Caller
- * is responsible to free the result.
+ * \return \p NULL if (a) \a name is the empty string of \p NULL, or (b) name
+ * ends with a slash.  Otherwise, a pointer within \a name is returned.  Caller
+ * must not free the result.
  */
-__must_check __malloc char *para_basename(const char *name)
+__must_check const char *para_basename(const char *name)
 {
-       char *p;
+       const char *ret;
 
        if (!name || !*name)
                return NULL;
-       p = strrchr(name, '/');
-       if (!p)
-               return para_strdup(name);
-       p++;
-       if (!*p)
-               return NULL;
-       return para_strdup(p);
+       ret = strrchr(name, '/');
+       if (!ret)
+               return name;
+       ret++;
+       return ret;
 }
 
 /**