Initial import of the CDE 2.1.30 sources from the Open Group.

This commit is contained in:
Peter Howkins
2012-03-10 18:21:40 +00:00
commit 83b6996daa
18978 changed files with 3945623 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
/* $XConsortium: itoa.c /main/3 1995/11/08 10:33:12 rswiston $ */
/* From example in Kernighan and Ritchie, The C Programming Language,
Prentice-Hall, 1978 */
#include <string.h>
#include "basic.h"
char *m_itoa(
#if defined(M_PROTO)
int n, char *s
#endif
) ;
void reverse(
#if defined(M_PROTO)
char *s
#endif
) ;
char *m_itoa(n, s) /* convert n to characters in s */
char s[];
int n;
{
int sign ;
char *p = s ;
if ( (sign = n) < 0 ) /* record sign */
n = -n;
do { /* generate digits in reverse order */
*p++ = (char) (n % 10 + '0') ;
} while (( n/= 10) > 0);
if (sign < 0)
*p++ = '-';
*p = '\0';
reverse(s);
return(s) ;
}
void reverse(s)
char s[];
{
int c, i, j;
for (i=0, j=strlen(s)-1; i < j ; i++, j--) {
c = s[i];
s[i] = s[j];
s[j] = (char) c;
}
}