Update of /cvsroot/libwpd/libwpd2/src/lib
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv25004/src/lib
Modified Files:
Makefile.am WPXString.cpp libwpd_types.h
Added Files:
vsnprintf.c
Log Message:
allow compiling of libwpd and related tools for MS DOS using the djgpp tools
--- NEW FILE: vsnprintf.c ---
/* Copyright (C) 2001 DJ Delorie, see http://www.delorie.com/bin/cvsweb.cgi/djgpp/copying.dj?rev=1.5 for details */
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <limits.h>
#include <errno.h>
#define _IOWRT 000020
#define _IOSTRG 000400
#define _IONTERM 040000 /* file's handle not hooked by termios */
static __inline__ void __stropenw(FILE *p, char *str, int len)
{
p->_flag = _IOWRT | _IOSTRG | _IONTERM;
p->_ptr = str;
p->_cnt = len;
}
static __inline__ void __strclosew(FILE *p)
{
*p->_ptr = '\0';
}
int
vsnprintf(char *str, size_t n, const char *fmt, va_list ap)
{
FILE _strbuf;
int len;
/* _cnt is an int in the FILE structure. To prevent wrap-around, we limit
* n to between 0 and INT_MAX inclusively. */
if (n > INT_MAX)
{
errno = EFBIG;
return -1;
}
memset(&_strbuf, 0, sizeof(_strbuf));
/* If n == 0, just querying how much space is needed. */
if (n > 0)
__stropenw(&_strbuf, str, n - 1);
else
__stropenw(&_strbuf, NULL, 0);
len = _doprnt(fmt, ap, &_strbuf);
/* Ensure nul termination */
if (n > 0)
__strclosew(&_strbuf);
return len;
}
Index: Makefile.am
===================================================================
RCS file: /cvsroot/libwpd/libwpd2/src/lib/Makefile.am,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -d -r1.114 -r1.115
--- Makefile.am 19 Nov 2008 13:15:34 -0000 1.114
+++ Makefile.am 3 Sep 2009 08:00:52 -0000 1.115
@@ -440,6 +440,7 @@
$(libwpd_stream_sources) \
$(libwpd_stream_headers) \
makefile.mk \
+ vsnprintf.c \
libwpd-@WPD_MAJOR_VERSION@.@WPD_MINOR_VERSION@.def \
libwpd.h.in \
libwpd.rc.in \
Index: WPXString.cpp
===================================================================
RCS file: /cvsroot/libwpd/libwpd2/src/lib/WPXString.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- WPXString.cpp 4 Dec 2008 23:14:10 -0000 1.20
+++ WPXString.cpp 3 Sep 2009 08:00:54 -0000 1.21
@@ -31,6 +31,12 @@
#include <stdarg.h>
#include <stdio.h>
+#ifdef __DJGPP__
+namespace {
+#include "vsnprintf.c"
+}
+#endif
+
#define FIRST_BUF_SIZE 128
#ifdef _MSC_VER
#define vsnprintf _vsnprintf
Index: libwpd_types.h
===================================================================
RCS file: /cvsroot/libwpd/libwpd2/src/lib/libwpd_types.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- libwpd_types.h 9 Oct 2006 03:50:18 -0000 1.4
+++ libwpd_types.h 3 Sep 2009 08:00:54 -0000 1.5
@@ -25,7 +25,7 @@
#ifndef LIBWPD_TYPES_H
#define LIBWPD_TYPES_H
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined (__DJGPP__)
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
|