Don't use .Xo/.Xc. Fix date format.
[netbsd-mini2440.git] / gnu / usr.bin / groff / libgroff / itoa.cc
blobe155625f036441f1bcef341b47eb3953dc6fb1dc
1 /*-
2 * This code is derived from software copyrighted by the Free Software
3 * Foundation.
5 * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
6 */
8 #ifndef lint
9 static char sccsid[] = "@(#)itoa.cc 6.3 (Berkeley) 5/8/91";
10 #endif /* not lint */
12 /* Copyright (C) 1989, 1990 Free Software Foundation, Inc.
13 Written by James Clark (jjc@jclark.uucp)
15 This file is part of groff.
17 groff is free software; you can redistribute it and/or modify it under
18 the terms of the GNU General Public License as published by the Free
19 Software Foundation; either version 1, or (at your option) any later
20 version.
22 groff is distributed in the hope that it will be useful, but WITHOUT ANY
23 WARRANTY; without even the implied warranty of MERCHANTABILITY or
24 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25 for more details.
27 You should have received a copy of the GNU General Public License along
28 with groff; see the file LICENSE. If not, write to the Free Software
29 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
31 #include "lib.h"
33 const char *itoa(int i)
35 /* Room for 10 digits, - and '\0' */
36 static char buf[INT_DIGITS + 2];
37 char *p = buf + INT_DIGITS + 1; /* points to terminating '\0' */
38 if (i >= 0) {
39 do {
40 *--p = '0' + (i % 10);
41 i /= 10;
42 } while (i != 0);
43 return p;
45 else { /* i < 0 */
46 do {
47 *--p = '0' - (i % 10);
48 i /= 10;
49 } while (i != 0);
50 *--p = '-';
52 return p;