Chameleon

Chameleon Commit Details

Date:2014-01-07 08:15:50 (5 years 10 months ago)
Author:Chuck Fry
Commit:2292
Parents: 2291
Message:Implement snprintf(); implement missing zero-fill in strncpy()
Changes:
M/branches/chucko/i386/libsa/libsa.h
M/branches/chucko/i386/libsa/printf.c
M/branches/chucko/i386/libsa/string.c

File differences

branches/chucko/i386/libsa/libsa.h
136136
137137
138138
139
139140
140141
141142
* printf.c
*/
extern int sprintf(char *s, const char * format, ...);
extern int snprintf(char *s, size_t size, const char * format, ...);
extern int slvprintf(char * buffer, int len, const char * fmt, va_list arg);
/*
branches/chucko/i386/libsa/printf.c
6363
6464
6565
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
6681
6782
6883
}
/*VARARGS1*/
int snprintf(char * str, size_t size, const char * fmt, ...)
{
va_list ap;
struct putc_info pi;
va_start(ap, fmt);
pi.str = str;
pi.last_str = str + size - 1;
prf(fmt, ap, sputc, &pi);
*pi.str = '\0';
va_end(ap);
return (pi.str - str);
}
/*VARARGS1*/
int slvprintf(char * str, int len, const char * fmt, va_list ap)
{
struct putc_info pi;
branches/chucko/i386/libsa/string.c
161161
162162
163163
164
164
165
166
167
165168
166169
167170
{
register char *ret = s1;
while (n && (*s1++ = *s2++))
n--;
--n;
/* while (n--) *s1++ = '\0'; */
if (n > 0)
bzero(s1, n);
return ret;
}

Archive Download the corresponding diff file

Revision: 2292