repo.or.cz
/
minix3.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Uninitialized vector entry?
[minix3.git]
/
lib
/
other
/
itoa.c
blob
f78717d247030137b9d6b7c67ba4cd3322e8b1a4
1
#include <lib.h>
2
/* Integer to ASCII for signed decimal integers. */
3
4
PRIVATE
int
next
;
5
PRIVATE
char
qbuf
[
8
];
6
7
_PROTOTYPE
(
char
*
itoa
, (
int
n
));
8
9
char
*
itoa
(
n
)
10
int
n
;
11
{
12
register
int
r
,
k
;
13
int
flag
=
0
;
14
15
next
=
0
;
16
if
(
n
<
0
) {
17
qbuf
[
next
++] =
'-'
;
18
n
= -
n
;
19
}
20
if
(
n
==
0
) {
21
qbuf
[
next
++] =
'0'
;
22
}
else
{
23
k
=
10000
;
24
while
(
k
>
0
) {
25
r
=
n
/
k
;
26
if
(
flag
||
r
>
0
) {
27
qbuf
[
next
++] =
'0'
+
r
;
28
flag
=
1
;
29
}
30
n
-=
r
*
k
;
31
k
=
k
/
10
;
32
}
33
}
34
qbuf
[
next
] =
0
;
35
return
(
qbuf
);
36
}