Index: uspace/lib/c/generic/str.c
===================================================================
--- uspace/lib/c/generic/str.c	(revision 1b20da07baaa3e3c424f62c927274e676e4295cd)
+++ uspace/lib/c/generic/str.c	(revision f1380b76772fb5d1aa03637b5e57bd9b929fea61)
@@ -85,13 +85,13 @@
 	if (*offset + 1 > size)
 		return 0;
-	
+
 	/* First byte read from string */
 	uint8_t b0 = (uint8_t) str[(*offset)++];
-	
+
 	/* Determine code length */
-	
+
 	unsigned int b0_bits;  /* Data bits in first byte */
 	unsigned int cbytes;   /* Number of continuation bytes */
-	
+
 	if ((b0 & 0x80) == 0) {
 		/* 0xxxxxxx (Plain ASCII) */
@@ -114,23 +114,23 @@
 		return U_SPECIAL;
 	}
-	
+
 	if (*offset + cbytes > size)
 		return U_SPECIAL;
-	
+
 	wchar_t ch = b0 & LO_MASK_8(b0_bits);
-	
+
 	/* Decode continuation bytes */
 	while (cbytes > 0) {
 		uint8_t b = (uint8_t) str[(*offset)++];
-		
+
 		/* Must be 10xxxxxx */
 		if ((b & 0xc0) != 0x80)
 			return U_SPECIAL;
-		
+
 		/* Shift data bits to ch */
 		ch = (ch << CONT_BITS) | (wchar_t) (b & LO_MASK_8(CONT_BITS));
 		cbytes--;
 	}
-	
+
 	return ch;
 }
@@ -155,10 +155,10 @@
 	if (*offset == 0)
 		return 0;
-	
+
 	size_t processed = 0;
 	/* Continue while continuation bytes found */
 	while (*offset > 0 && processed < 4) {
 		uint8_t b = (uint8_t) str[--(*offset)];
-		
+
 		if (processed == 0 && (b & 0x80) == 0) {
 			/* 0xxxxxxx (Plain ASCII) */
@@ -200,17 +200,17 @@
 	if (*offset >= size)
 		return EOVERFLOW;
-	
+
 	if (!chr_check(ch))
 		return EINVAL;
-	
+
 	/* Unsigned version of ch (bit operations should only be done
 	   on unsigned types). */
 	uint32_t cc = (uint32_t) ch;
-	
+
 	/* Determine how many continuation bytes are needed */
-	
+
 	unsigned int b0_bits;  /* Data bits in first byte */
 	unsigned int cbytes;   /* Number of continuation bytes */
-	
+
 	if ((cc & ~LO_MASK_32(7)) == 0) {
 		b0_bits = 7;
@@ -229,9 +229,9 @@
 		return EINVAL;
 	}
-	
+
 	/* Check for available space in buffer */
 	if (*offset + cbytes >= size)
 		return EOVERFLOW;
-	
+
 	/* Encode continuation bytes */
 	unsigned int i;
@@ -240,11 +240,11 @@
 		cc = cc >> CONT_BITS;
 	}
-	
+
 	/* Encode first byte */
 	str[*offset] = (cc & LO_MASK_32(b0_bits)) | HI_MASK_8(8 - b0_bits - 1);
-	
+
 	/* Advance offset */
 	*offset += cbytes + 1;
-	
+
 	return EOK;
 }
@@ -263,8 +263,8 @@
 {
 	size_t size = 0;
-	
+
 	while (*str++ != 0)
 		size++;
-	
+
 	return size;
 }
@@ -302,12 +302,12 @@
 	size_t len = 0;
 	size_t offset = 0;
-	
+
 	while (len < max_len) {
 		if (str_decode(str, &offset, STR_NO_LIMIT) == 0)
 			break;
-		
+
 		len++;
 	}
-	
+
 	return offset;
 }
@@ -327,8 +327,8 @@
 {
 	size_t size = 0;
-	
+
 	while ((*str++ != 0) && (size < max_size))
 		size++;
-	
+
 	return size;
 }
@@ -379,8 +379,8 @@
 	size_t len = 0;
 	size_t offset = 0;
-	
+
 	while (str_decode(str, &offset, STR_NO_LIMIT) != 0)
 		len++;
-	
+
 	return len;
 }
@@ -396,8 +396,8 @@
 {
 	size_t len = 0;
-	
+
 	while (*wstr++ != 0)
 		len++;
-	
+
 	return len;
 }
@@ -415,8 +415,8 @@
 	size_t len = 0;
 	size_t offset = 0;
-	
+
 	while (str_decode(str, &offset, size) != 0)
 		len++;
-	
+
 	return len;
 }
@@ -435,10 +435,10 @@
 	size_t limit = ALIGN_DOWN(size, sizeof(wchar_t));
 	size_t offset = 0;
-	
+
 	while ((offset < limit) && (*str++ != 0)) {
 		len++;
 		offset += sizeof(wchar_t);
 	}
-	
+
 	return len;
 }
@@ -464,8 +464,8 @@
 	size_t offset = 0;
 	wchar_t ch;
-	
+
 	while ((ch = str_decode(str, &offset, STR_NO_LIMIT)) != 0)
 		width += chr_width(ch);
-	
+
 	return width;
 }
@@ -480,5 +480,5 @@
 	if (WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 127))
 		return true;
-	
+
 	return false;
 }
@@ -493,5 +493,5 @@
 	if (WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 1114111))
 		return true;
-	
+
 	return false;
 }
@@ -666,8 +666,8 @@
 	wchar_t c1 = 0;
 	wchar_t c2 = 0;
-	
+
 	size_t off1 = 0;
 	size_t off2 = 0;
-	
+
 	size_t len = 0;
 
@@ -710,5 +710,5 @@
 	wchar_t c1 = 0;
 	wchar_t c2 = 0;
-	
+
 	size_t off1 = 0;
 	size_t off2 = 0;
@@ -717,5 +717,5 @@
 		c1 = str_decode(s, &off1, STR_NO_LIMIT);
 		c2 = str_decode(p, &off2, STR_NO_LIMIT);
-		
+
 		if (c2 == 0)
 			return true;
@@ -723,5 +723,5 @@
 		if (c1 != c2)
 			return false;
-		
+
 		if (c1 == 0)
 			break;
@@ -747,8 +747,8 @@
 	/* There must be space for a null terminator in the buffer. */
 	assert(size > 0);
-	
+
 	size_t src_off = 0;
 	size_t dest_off = 0;
-	
+
 	wchar_t ch;
 	while ((ch = str_decode(src, &src_off, STR_NO_LIMIT)) != 0) {
@@ -756,5 +756,5 @@
 			break;
 	}
-	
+
 	dest[dest_off] = '\0';
 }
@@ -780,8 +780,8 @@
 	/* There must be space for a null terminator in the buffer. */
 	assert(size > 0);
-	
+
 	size_t src_off = 0;
 	size_t dest_off = 0;
-	
+
 	wchar_t ch;
 	while ((ch = str_decode(src, &src_off, n)) != 0) {
@@ -789,5 +789,5 @@
 			break;
 	}
-	
+
 	dest[dest_off] = '\0';
 }
@@ -811,5 +811,5 @@
 	if (dstr_size >= size)
 		return;
-	
+
 	str_cpy(dest + dstr_size, size - dstr_size, src);
 }
@@ -896,5 +896,5 @@
 	/* There must be space for a null terminator in the buffer. */
 	assert(size > 0);
-	
+
 	src_idx = 0;
 	dest_off = 0;
@@ -971,5 +971,5 @@
 
 	assert(dlen > 0);
-	
+
 	while ((c = str_decode(src, &offset, STR_NO_LIMIT)) != 0) {
 		if (c > 0x10000) {
@@ -1109,9 +1109,9 @@
 {
 	size_t len = str_length(str);
-	
+
 	wchar_t *wstr = calloc(len+1, sizeof(wchar_t));
 	if (wstr == NULL)
 		return NULL;
-	
+
 	str_to_wstr(wstr, len + 1, str);
 	return wstr;
@@ -1130,5 +1130,5 @@
 	size_t off = 0;
 	size_t last = 0;
-	
+
 	while ((acc = str_decode(str, &off, STR_NO_LIMIT)) != 0) {
 		if (acc == ch)
@@ -1136,5 +1136,5 @@
 		last = off;
 	}
-	
+
 	return NULL;
 }
@@ -1207,5 +1207,5 @@
 	size_t last = 0;
 	const char *res = NULL;
-	
+
 	while ((acc = str_decode(str, &off, STR_NO_LIMIT)) != 0) {
 		if (acc == ch)
@@ -1213,5 +1213,5 @@
 		last = off;
 	}
-	
+
 	return (char *) res;
 }
@@ -1234,14 +1234,14 @@
 {
 	size_t len = wstr_length(str);
-	
+
 	if ((pos > len) || (pos + 1 > max_pos))
 		return false;
-	
+
 	size_t i;
 	for (i = len; i + 1 > pos; i--)
 		str[i + 1] = str[i];
-	
+
 	str[pos] = ch;
-	
+
 	return true;
 }
@@ -1262,12 +1262,12 @@
 {
 	size_t len = wstr_length(str);
-	
+
 	if (pos >= len)
 		return false;
-	
+
 	size_t i;
 	for (i = pos + 1; i <= len; i++)
 		str[i - 1] = str[i];
-	
+
 	return true;
 }
@@ -1296,5 +1296,5 @@
 	if (dest == NULL)
 		return (char *) NULL;
-	
+
 	str_cpy(dest, size, src);
 	return dest;
@@ -1326,9 +1326,9 @@
 	if (size > n)
 		size = n;
-	
+
 	char *dest = (char *) malloc(size + 1);
 	if (dest == NULL)
 		return (char *) NULL;
-	
+
 	str_ncpy(dest, size + 1, src, size);
 	return dest;
@@ -1353,5 +1353,5 @@
 	if (!s)
 		return NULL;
-	
+
 	size_t len = str_size(s);
 	size_t cur;
@@ -1398,12 +1398,12 @@
 	assert(neg != NULL);
 	assert(result != NULL);
-	
+
 	*neg = false;
 	const char *str = nptr;
-	
+
 	/* Ignore leading whitespace */
 	while (isspace(*str))
 		str++;
-	
+
 	if (*str == '-') {
 		*neg = true;
@@ -1411,13 +1411,13 @@
 	} else if (*str == '+')
 		str++;
-	
+
 	if (base == 0) {
 		/* Decode base if not specified */
 		base = 10;
-		
+
 		if (*str == '0') {
 			base = 8;
 			str++;
-			
+
 			switch (*str) {
 			case 'b':
@@ -1454,11 +1454,11 @@
 		}
 	}
-	
+
 	*result = 0;
 	const char *startstr = str;
-	
+
 	while (*str != 0) {
 		unsigned int digit;
-		
+
 		if ((*str >= 'a') && (*str <= 'z'))
 			digit = *str - 'a' + 10;
@@ -1469,11 +1469,11 @@
 		else
 			break;
-		
+
 		if (digit >= base)
 			break;
-		
+
 		uint64_t prev = *result;
 		*result = (*result) * base + digit;
-		
+
 		if (*result < prev) {
 			/* Overflow */
@@ -1481,8 +1481,8 @@
 			return EOVERFLOW;
 		}
-		
+
 		str++;
 	}
-	
+
 	if (str == startstr) {
 		/*
@@ -1492,10 +1492,10 @@
 		str = nptr;
 	}
-	
+
 	*endptr = (char *) str;
-	
+
 	if (str == nptr)
 		return EINVAL;
-	
+
 	return EOK;
 }
@@ -1517,32 +1517,32 @@
 {
 	assert(result != NULL);
-	
+
 	bool neg;
 	char *lendptr;
 	uint64_t res;
 	errno_t ret = str_uint(nptr, &lendptr, base, &neg, &res);
-	
+
 	if (endptr != NULL)
 		*endptr = (char *) lendptr;
-	
+
 	if (ret != EOK)
 		return ret;
-	
+
 	/* Do not allow negative values */
 	if (neg)
 		return EINVAL;
-	
+
 	/* Check whether we are at the end of
 	   the string in strict mode */
 	if ((strict) && (*lendptr != 0))
 		return EINVAL;
-	
+
 	/* Check for overflow */
 	uint8_t _res = (uint8_t) res;
 	if (_res != res)
 		return EOVERFLOW;
-	
+
 	*result = _res;
-	
+
 	return EOK;
 }
@@ -1564,32 +1564,32 @@
 {
 	assert(result != NULL);
-	
+
 	bool neg;
 	char *lendptr;
 	uint64_t res;
 	errno_t ret = str_uint(nptr, &lendptr, base, &neg, &res);
-	
+
 	if (endptr != NULL)
 		*endptr = (char *) lendptr;
-	
+
 	if (ret != EOK)
 		return ret;
-	
+
 	/* Do not allow negative values */
 	if (neg)
 		return EINVAL;
-	
+
 	/* Check whether we are at the end of
 	   the string in strict mode */
 	if ((strict) && (*lendptr != 0))
 		return EINVAL;
-	
+
 	/* Check for overflow */
 	uint16_t _res = (uint16_t) res;
 	if (_res != res)
 		return EOVERFLOW;
-	
+
 	*result = _res;
-	
+
 	return EOK;
 }
@@ -1611,32 +1611,32 @@
 {
 	assert(result != NULL);
-	
+
 	bool neg;
 	char *lendptr;
 	uint64_t res;
 	errno_t ret = str_uint(nptr, &lendptr, base, &neg, &res);
-	
+
 	if (endptr != NULL)
 		*endptr = (char *) lendptr;
-	
+
 	if (ret != EOK)
 		return ret;
-	
+
 	/* Do not allow negative values */
 	if (neg)
 		return EINVAL;
-	
+
 	/* Check whether we are at the end of
 	   the string in strict mode */
 	if ((strict) && (*lendptr != 0))
 		return EINVAL;
-	
+
 	/* Check for overflow */
 	uint32_t _res = (uint32_t) res;
 	if (_res != res)
 		return EOVERFLOW;
-	
+
 	*result = _res;
-	
+
 	return EOK;
 }
@@ -1658,24 +1658,24 @@
 {
 	assert(result != NULL);
-	
+
 	bool neg;
 	char *lendptr;
 	errno_t ret = str_uint(nptr, &lendptr, base, &neg, result);
-	
+
 	if (endptr != NULL)
 		*endptr = (char *) lendptr;
-	
+
 	if (ret != EOK)
 		return ret;
-	
+
 	/* Do not allow negative values */
 	if (neg)
 		return EINVAL;
-	
+
 	/* Check whether we are at the end of
 	   the string in strict mode */
 	if ((strict) && (*lendptr != 0))
 		return EINVAL;
-	
+
 	return EOK;
 }
@@ -1697,32 +1697,32 @@
 {
 	assert(result != NULL);
-	
+
 	bool neg;
 	char *lendptr;
 	uint64_t res;
 	errno_t ret = str_uint(nptr, &lendptr, base, &neg, &res);
-	
+
 	if (endptr != NULL)
 		*endptr = (char *) lendptr;
-	
+
 	if (ret != EOK)
 		return ret;
-	
+
 	/* Do not allow negative values */
 	if (neg)
 		return EINVAL;
-	
+
 	/* Check whether we are at the end of
 	   the string in strict mode */
 	if ((strict) && (*lendptr != 0))
 		return EINVAL;
-	
+
 	/* Check for overflow */
 	size_t _res = (size_t) res;
 	if (_res != res)
 		return EOVERFLOW;
-	
+
 	*result = _res;
-	
+
 	return EOK;
 }
