Merge 'akpm' patch series
[pandora-kernel.git] / lib / vsprintf.c
index c112056..d7222a9 100644 (file)
 #include <asm/div64.h>
 #include <asm/sections.h>      /* for dereference_function_descriptor() */
 
-/* Works only for digits and letters, but small and fast */
-#define TOLOWER(x) ((x) | 0x20)
-
 static unsigned int simple_guess_base(const char *cp)
 {
        if (cp[0] == '0') {
-               if (TOLOWER(cp[1]) == 'x' && isxdigit(cp[2]))
+               if (_tolower(cp[1]) == 'x' && isxdigit(cp[2]))
                        return 16;
                else
                        return 8;
@@ -59,13 +56,13 @@ unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int bas
        if (!base)
                base = simple_guess_base(cp);
 
-       if (base == 16 && cp[0] == '0' && TOLOWER(cp[1]) == 'x')
+       if (base == 16 && cp[0] == '0' && _tolower(cp[1]) == 'x')
                cp += 2;
 
        while (isxdigit(*cp)) {
                unsigned int value;
 
-               value = isdigit(*cp) ? *cp - '0' : TOLOWER(*cp) - 'a' + 10;
+               value = isdigit(*cp) ? *cp - '0' : _tolower(*cp) - 'a' + 10;
                if (value >= base)
                        break;
                result = result * base + value;
@@ -666,6 +663,8 @@ char *ip6_compressed_string(char *p, const char *addr)
                        colonpos = i;
                }
        }
+       if (longest == 1)               /* don't compress a single 0 */
+               colonpos = -1;
 
        /* emit address */
        for (i = 0; i < range; i++) {
@@ -826,7 +825,7 @@ int kptr_restrict __read_mostly;
  *       IPv4 uses dot-separated decimal with leading 0's (010.123.045.006)
  * - '[Ii]4[hnbl]' IPv4 addresses in host, network, big or little endian order
  * - 'I6c' for IPv6 addresses printed as specified by
- *       http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-00
+ *       http://tools.ietf.org/html/rfc5952
  * - 'U' For a 16 byte UUID/GUID, it prints the UUID/GUID in the form
  *       "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
  *       Options for %pU are:
@@ -1034,8 +1033,8 @@ precision:
 qualifier:
        /* get the conversion qualifier */
        spec->qualifier = -1;
-       if (*fmt == 'h' || TOLOWER(*fmt) == 'l' ||
-           TOLOWER(*fmt) == 'z' || *fmt == 't') {
+       if (*fmt == 'h' || _tolower(*fmt) == 'l' ||
+           _tolower(*fmt) == 'z' || *fmt == 't') {
                spec->qualifier = *fmt++;
                if (unlikely(spec->qualifier == *fmt)) {
                        if (spec->qualifier == 'l') {
@@ -1102,7 +1101,7 @@ qualifier:
                        spec->type = FORMAT_TYPE_LONG;
                else
                        spec->type = FORMAT_TYPE_ULONG;
-       } else if (TOLOWER(spec->qualifier) == 'z') {
+       } else if (_tolower(spec->qualifier) == 'z') {
                spec->type = FORMAT_TYPE_SIZE_T;
        } else if (spec->qualifier == 't') {
                spec->type = FORMAT_TYPE_PTRDIFF;
@@ -1147,8 +1146,7 @@ qualifier:
  * %pi4 print an IPv4 address with leading zeros
  * %pI6 print an IPv6 address with colons
  * %pi6 print an IPv6 address without colons
- * %pI6c print an IPv6 address as specified by
- *   http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-00
+ * %pI6c print an IPv6 address as specified by RFC 5952
  * %pU[bBlL] print a UUID/GUID in big or little endian using lower or upper
  *   case.
  * %n is ignored
@@ -1261,7 +1259,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
                        if (qualifier == 'l') {
                                long *ip = va_arg(args, long *);
                                *ip = (str - buf);
-                       } else if (TOLOWER(qualifier) == 'z') {
+                       } else if (_tolower(qualifier) == 'z') {
                                size_t *ip = va_arg(args, size_t *);
                                *ip = (str - buf);
                        } else {
@@ -1548,7 +1546,7 @@ do {                                                                      \
                        void *skip_arg;
                        if (qualifier == 'l')
                                skip_arg = va_arg(args, long *);
-                       else if (TOLOWER(qualifier) == 'z')
+                       else if (_tolower(qualifier) == 'z')
                                skip_arg = va_arg(args, size_t *);
                        else
                                skip_arg = va_arg(args, int *);
@@ -1854,8 +1852,8 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
 
                /* get conversion qualifier */
                qualifier = -1;
-               if (*fmt == 'h' || TOLOWER(*fmt) == 'l' ||
-                   TOLOWER(*fmt) == 'z') {
+               if (*fmt == 'h' || _tolower(*fmt) == 'l' ||
+                   _tolower(*fmt) == 'z') {
                        qualifier = *fmt++;
                        if (unlikely(qualifier == *fmt)) {
                                if (qualifier == 'h') {