Index: uspace/lib/posix/fnmatch.c
===================================================================
--- uspace/lib/posix/fnmatch.c	(revision 903bd436b362156834cc6fdeae86e67477d75afc)
+++ uspace/lib/posix/fnmatch.c	(revision 4c8f5e7cf5a36a3df239abbc7d94dc09f00044b0)
@@ -33,5 +33,12 @@
  */
 
-// TODO: clean this up a bit
+/* This file contains an implementation of the fnmatch() pattern matching
+ * function. There is more code than necessary to account for the possibility
+ * of adding POSIX-like locale support to the system in the future. Functions
+ * that are only necessary for locale support currently simply use single
+ * characters for "collation elements". 
+ * When (or if) locales are properly implemented, extending this implementation
+ * will be fairly straightforward.
+ */
 
 #include "stdbool.h"
@@ -46,6 +53,5 @@
 #include "fnmatch.h"
 
-// TODO: documentation
-
+/* Returned by _match... functions. */
 #define INVALID_PATTERN -1
 
@@ -53,6 +59,9 @@
  * but may be extended for better locale support.
  */
-typedef int _coll_elm_t;
-
+typedef int coll_elm_t;
+
+/** Return value indicating that the element in question
+ * is not valid in the current locale. (That is, if locales are supported.)
+ */
 #define COLL_ELM_INVALID -1
 
@@ -60,7 +69,7 @@
  *
  * @param str
- * @return
- */
-static _coll_elm_t _coll_elm_get(const char* str)
+ * @return Matching collating element or COLL_ELM_INVALID.
+ */
+static coll_elm_t _coll_elm_get(const char* str)
 {
 	if (str[0] == '\0' || str[1] != '\0') {
@@ -75,5 +84,5 @@
  * @return
  */
-static _coll_elm_t _coll_elm_char(int c)
+static coll_elm_t _coll_elm_char(int c)
 {
 	return c;
@@ -86,10 +95,18 @@
  * @return 0 if the element doesn't match, or the number of characters matched.
  */
-static int _coll_elm_match(_coll_elm_t elm, const char *str)
+static int _coll_elm_match(coll_elm_t elm, const char *str)
 {
 	return elm == *str;
 }
 
-static int _coll_elm_between(_coll_elm_t first, _coll_elm_t second,
+/** Checks whether a string begins with a collating element in the given range.
+ *  Ordering depends on the locale (if locales are supported).
+ *
+ * @param first First element of the range.
+ * @param second Last element of the range.
+ * @param str String to match.
+ * @return 0 if there is no match, or the number of characters matched.
+ */
+static int _coll_elm_between(coll_elm_t first, coll_elm_t second,
     const char *str)
 {
@@ -105,5 +122,6 @@
  * @param buf_sz Read buffer's size. If the buffer is not large enough for
  *    the entire string, the string is cut with no error indication.
- * @return
+ * @param flags Flags modifying the behavior.
+ * @return True on success, false if the pattern is invalid.
  */
 static bool _get_delimited(
@@ -171,5 +189,5 @@
 };
 
-/**
+/** Compare function for binary search in the _char_classes array. 
  * 
  * @param key
@@ -183,9 +201,9 @@
 }
 
-/**
+/** Returns whether the given character belongs to the specified character class.
  * 
- * @param cname
- * @param c
- * @return
+ * @param cname Name of the character class.
+ * @param c Character.
+ * @return True if the character belongs to the class, false otherwise.
  */
 static bool _is_in_class (const char *cname, int c)
@@ -205,10 +223,15 @@
 }
 
-/**
+/** Tries to parse an initial part of the pattern as a character class pattern,
+ *  and if successful, matches the beginning of the given string against the class.
  * 
- * @param pattern
- * @param str
- * @param flags
- * @return
+ * @param pattern Pointer to the pattern to match. Must begin with a class
+ *    specifier and is repositioned to the first character after the specifier
+ *    if successful.
+ * @param str String to match.
+ * @param flags Flags modifying the behavior (see fnmatch()).
+ * @return INVALID_PATTERN if the pattern doesn't start with a valid class
+ *    specifier, 0 if the beginning of the matched string doesn't belong
+ *    to the class, or positive number of characters matched.
  */
 static int _match_char_class(const char **pattern, const char *str, int flags)
@@ -225,12 +248,18 @@
 /************** END CHARACTER CLASSES ****************/
 
-/**
+/** Reads the next collating element in the pattern, taking into account
+ *  locale (if supported) and flags (see fnmatch()).
  * 
- * @param pattern
- * @param flags
- * @return
- */
-static _coll_elm_t _next_coll_elm(const char **pattern, int flags)
-{
+ * @param pattern Pattern.
+ * @param flags Flags given to fnmatch().
+ * @return Collating element on success,
+ *     or COLL_ELM_INVALID if the pattern is invalid.
+ */
+static coll_elm_t _next_coll_elm(const char **pattern, int flags)
+{
+	assert(pattern != NULL);
+	assert(*pattern != NULL);
+	assert(**pattern != '\0');
+
 	const char *p = *pattern;
 	const bool noescape = (flags & FNM_NOESCAPE) != 0;
@@ -257,19 +286,27 @@
 	if (!noescape && *p == '\\') {
 		p++;
+		if (*p == '\0') {
+			*pattern = p;
+			return COLL_ELM_INVALID;
+		}
 	}
 	if (pathname && *p == '/') {
 		return COLL_ELM_INVALID;
 	}
-
+	
 	*pattern = p + 1;
 	return _coll_elm_char(*p);
 }
 
-/**
+/** Matches the beginning of the given string against a bracket expression
+ *  the pattern begins with.
  * 
- * @param pattern
- * @param str
- * @param flags
- * @return
+ * @param pattern Pointer to the beginning of a bracket expression in a pattern.
+ *     On success, the pointer is moved to the first character after the
+ *     bracket expression.
+ * @param str Unmatched part of the string.
+ * @param flags Flags given to fnmatch().
+ * @return INVALID_PATTERN if the pattern is invalid, 0 if there is no match
+ *     or the number of matched characters on success.
  */
 static int _match_bracket_expr(const char **pattern, const char *str, int flags)
@@ -315,5 +352,5 @@
 	}
 	
-	_coll_elm_t current_elm = COLL_ELM_INVALID;
+	coll_elm_t current_elm = COLL_ELM_INVALID;
 	
 	while (*p != ']') {
@@ -322,5 +359,5 @@
 			/* Range expression. */
 			p++;
-			_coll_elm_t end_elm = _next_coll_elm(&p, flags);
+			coll_elm_t end_elm = _next_coll_elm(&p, flags);
 			if (end_elm == COLL_ELM_INVALID) {
 				return INVALID_PATTERN;
@@ -357,10 +394,14 @@
 }
 
-/**
+/** Matches a portion of the pattern containing no asterisks (*) against
+ *  the given string.
  * 
- * @param pattern
- * @param string
- * @param flags
- * @return
+ * @param pattern Pointer to the unmatched portion of the pattern.
+ *     On success, the pointer is moved to the first asterisk, or to the
+ *     terminating nul character, whichever occurs first.
+ * @param string Pointer to the input string. On success, the pointer is moved
+ *     to the first character that wasn't explicitly matched.
+ * @param flags Flags given to fnmatch().
+ * @return True if the entire subpattern matched. False otherwise.
  */
 static bool _partial_match(const char **pattern, const char **string, int flags)
@@ -456,10 +497,10 @@
 }
 
-/**
+/** Match string against a pattern.
  * 
- * @param pattern
- * @param string
- * @param flags
- * @return
+ * @param pattern Pattern.
+ * @param string String to match.
+ * @param flags Flags given to fnmatch().
+ * @return True if the string matched the pattern, false otherwise.
  */
 static bool _full_match(const char *pattern, const char *string, int flags)
@@ -518,8 +559,9 @@
 }
 
-/**
+/** Transform the entire string to lowercase.
  * 
- * @param s
- * @return
+ * @param s Input string.
+ * @return Newly allocated copy of the input string with all uppercase
+ *     characters folded to their lowercase variants.
  */
 static char *_casefold(const char *s)
Index: uspace/lib/posix/locale.c
===================================================================
--- uspace/lib/posix/locale.c	(revision 903bd436b362156834cc6fdeae86e67477d75afc)
+++ uspace/lib/posix/locale.c	(revision 4c8f5e7cf5a36a3df239abbc7d94dc09f00044b0)
@@ -42,5 +42,9 @@
 #include "string.h"
 
-// TODO: documentation
+/* Just a very basic dummy implementation.
+ * This should allow code using locales to work properly, but doesn't provide
+ * any localization functionality.
+ * Should be extended/rewritten when or if HelenOS supports locales natively.
+ */
 
 struct __posix_locale {
@@ -75,9 +79,9 @@
 };
 
-/**
+/** Set program locale.
  * 
- * @param category
- * @param locale
- * @return
+ * @param category What category to set.
+ * @param locale Locale name.
+ * @return Original locale name on success, NULL on failure.
  */
 char *posix_setlocale(int category, const char *locale)
@@ -91,7 +95,7 @@
 }
 
-/**
+/** Return locale-specific information.
  * 
- * @return
+ * @return Information about the current locale.
  */
 struct posix_lconv *posix_localeconv(void)
@@ -101,8 +105,8 @@
 }
 
-/**
+/** Duplicate locale object.
  * 
- * @param locobj
- * @return
+ * @param locobj Object to duplicate.
+ * @return Duplicated object.
  */
 posix_locale_t posix_duplocale(posix_locale_t locobj)
@@ -121,7 +125,7 @@
 }
 
-/**
+/** Free locale object.
  * 
- * @param locobj
+ * @param locobj Object to free.
  */
 void posix_freelocale(posix_locale_t locobj)
@@ -132,10 +136,10 @@
 }
 
-/**
+/** Create or modify a locale object.
  * 
- * @param category_mask
- * @param locale
- * @param base
- * @return
+ * @param category_mask Mask of categories to be set or modified.
+ * @param locale Locale to be used.
+ * @param base Object to modify. 0 if new object is to be created.
+ * @return The new/modified locale object.
  */
 posix_locale_t posix_newlocale(int category_mask, const char *locale,
@@ -159,13 +163,13 @@
 }
 
-/**
+/** Set locale for the current thread.
  * 
- * @param newloc
- * @return
+ * @param newloc Locale to use.
+ * @return The previously set locale or LC_GLOBAL_LOCALE
  */
 posix_locale_t posix_uselocale(posix_locale_t newloc)
 {
 	// TODO
-	return NULL;
+	return LC_GLOBAL_LOCALE;
 }
 
Index: uspace/lib/posix/locale.h
===================================================================
--- uspace/lib/posix/locale.h	(revision 903bd436b362156834cc6fdeae86e67477d75afc)
+++ uspace/lib/posix/locale.h	(revision 4c8f5e7cf5a36a3df239abbc7d94dc09f00044b0)
@@ -35,6 +35,4 @@
 #ifndef POSIX_LOCALE_H_
 #define POSIX_LOCALE_H_
-
-// TODO: documentation
 
 #ifndef NULL
Index: uspace/lib/posix/stdio.c
===================================================================
--- uspace/lib/posix/stdio.c	(revision 903bd436b362156834cc6fdeae86e67477d75afc)
+++ uspace/lib/posix/stdio.c	(revision 4c8f5e7cf5a36a3df239abbc7d94dc09f00044b0)
@@ -320,30 +320,4 @@
 
 /**
- *
- * @param buf
- * @param size
- * @param mode
- * @return
- */
-FILE *posix_fmemopen(void *restrict buf, size_t size,
-    const char *restrict mode)
-{
-	// TODO
-	not_implemented();
-}
-
-/**
- *
- * @param bufp
- * @param sizep
- * @return
- */
-FILE *posix_open_memstream(char **bufp, size_t *sizep)
-{
-	// TODO
-	not_implemented();
-}
-
-/**
  * Write error messages to standard error.
  *
Index: uspace/lib/posix/stdio.h
===================================================================
--- uspace/lib/posix/stdio.h	(revision 903bd436b362156834cc6fdeae86e67477d75afc)
+++ uspace/lib/posix/stdio.h	(revision 4c8f5e7cf5a36a3df239abbc7d94dc09f00044b0)
@@ -65,7 +65,4 @@
 extern FILE *posix_freopen(const char *restrict filename,
     const char *restrict mode, FILE *restrict stream);
-extern FILE *posix_fmemopen(void *restrict buf, size_t size,
-    const char *restrict mode);
-extern FILE *posix_open_memstream(char **bufp, size_t *sizep);
 
 /* Error Messages */
Index: uspace/lib/posix/stdlib/strtold.c
===================================================================
--- uspace/lib/posix/stdlib/strtold.c	(revision 903bd436b362156834cc6fdeae86e67477d75afc)
+++ uspace/lib/posix/stdlib/strtold.c	(revision 4c8f5e7cf5a36a3df239abbc7d94dc09f00044b0)
@@ -48,5 +48,5 @@
 #include "../limits.h"
 
-// FIXME: #include <float.h>
+#include "../float.h"
 
 #ifndef HUGE_VALL
Index: uspace/lib/posix/unistd.c
===================================================================
--- uspace/lib/posix/unistd.c	(revision 903bd436b362156834cc6fdeae86e67477d75afc)
+++ uspace/lib/posix/unistd.c	(revision 4c8f5e7cf5a36a3df239abbc7d94dc09f00044b0)
@@ -88,4 +88,5 @@
 int posix_isatty(int fd)
 {
+	// TODO
 	/* Always returns false, because there is no easy way to find
 	 * out under HelenOS. */
