printf.c (9fec6060d9e48ed7db0dac0e16d0f0f0e615b7f6) printf.c (f4ed2877b16e8146427306aea8819adac5c88374)
1/* -*- linux-c -*- ------------------------------------------------------- *
2 *
3 * Copyright (C) 1991, 1992 Linus Torvalds
4 * Copyright 2007 rPath, Inc. - All Rights Reserved
5 *
6 * This file is part of the Linux kernel, and is made available under
7 * the terms of the GNU General Public License version 2.
8 *

--- 20 unchanged lines hidden (view full) ---

29#define ZEROPAD 1 /* pad with zero */
30#define SIGN 2 /* unsigned/signed long */
31#define PLUS 4 /* show plus */
32#define SPACE 8 /* space if plus */
33#define LEFT 16 /* left justified */
34#define SMALL 32 /* Must be 32 == 0x20 */
35#define SPECIAL 64 /* 0x */
36
1/* -*- linux-c -*- ------------------------------------------------------- *
2 *
3 * Copyright (C) 1991, 1992 Linus Torvalds
4 * Copyright 2007 rPath, Inc. - All Rights Reserved
5 *
6 * This file is part of the Linux kernel, and is made available under
7 * the terms of the GNU General Public License version 2.
8 *

--- 20 unchanged lines hidden (view full) ---

29#define ZEROPAD 1 /* pad with zero */
30#define SIGN 2 /* unsigned/signed long */
31#define PLUS 4 /* show plus */
32#define SPACE 8 /* space if plus */
33#define LEFT 16 /* left justified */
34#define SMALL 32 /* Must be 32 == 0x20 */
35#define SPECIAL 64 /* 0x */
36
37#define do_div(n,base) ({ \
37#define __do_div(n, base) ({ \
38int __res; \
39__res = ((unsigned long) n) % (unsigned) base; \
40n = ((unsigned long) n) / (unsigned) base; \
41__res; })
42
43static char *number(char *str, long num, int base, int size, int precision,
44 int type)
45{

--- 32 unchanged lines hidden (view full) ---

78 else if (base == 8)
79 size--;
80 }
81 i = 0;
82 if (num == 0)
83 tmp[i++] = '0';
84 else
85 while (num != 0)
38int __res; \
39__res = ((unsigned long) n) % (unsigned) base; \
40n = ((unsigned long) n) / (unsigned) base; \
41__res; })
42
43static char *number(char *str, long num, int base, int size, int precision,
44 int type)
45{

--- 32 unchanged lines hidden (view full) ---

78 else if (base == 8)
79 size--;
80 }
81 i = 0;
82 if (num == 0)
83 tmp[i++] = '0';
84 else
85 while (num != 0)
86 tmp[i++] = (digits[do_div(num, base)] | locase);
86 tmp[i++] = (digits[__do_div(num, base)] | locase);
87 if (i > precision)
88 precision = i;
89 size -= precision;
90 if (!(type & (ZEROPAD + LEFT)))
91 while (size-- > 0)
92 *str++ = ' ';
93 if (sign)
94 *str++ = sign;

--- 215 unchanged lines hidden ---
87 if (i > precision)
88 precision = i;
89 size -= precision;
90 if (!(type & (ZEROPAD + LEFT)))
91 while (size-- > 0)
92 *str++ = ' ';
93 if (sign)
94 *str++ = sign;

--- 215 unchanged lines hidden ---