comparison dwcompat.c @ 1990:433b7c772ff0

OS/2: Mostly safe snprintf() for VisualAge.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 16 Sep 2019 17:48:21 +0000
parents 1dd49705bd1a
children d83a86f5fe7f
comparison
equal deleted inserted replaced
1989:1dd49705bd1a 1990:433b7c772ff0
27 #include <sys/vfs.h> 27 #include <sys/vfs.h>
28 #endif 28 #endif
29 #endif 29 #endif
30 #include <time.h> 30 #include <time.h>
31 #include <errno.h> 31 #include <errno.h>
32
33 /* Mostly safe but slow snprintf() for compilers that don't have it...
34 * like VisualAge. So we can write safe code and still use VAC to test.
35 */
36 #if defined(__IBMC__) && !defined(snprintf)
37 static int snprintf(char *str, size_t size, const char *format, ...)
38 {
39 va_list args;
40 char *outbuf = calloc(1, size + strlen(format) + 1024);
41 int retval = -1;
42
43 if(outbuf)
44 {
45 va_start(args, format);
46 vsprintf(outbuf, format, args);
47 va_end(args);
48 retval = strlen(outbuf);
49 strncpy(str, outbuf, size);
50 free(outbuf);
51 }
52 return retval;
53 }
54 #endif
32 55
33 #if defined(__UNIX__) || defined(__MAC__) 56 #if defined(__UNIX__) || defined(__MAC__)
34 void msleep(long period) 57 void msleep(long period)
35 { 58 {
36 #ifdef __sun__ 59 #ifdef __sun__