Improve MSVC support

Closes #18.
This commit is contained in:
Devin Torres 2013-09-27 17:53:14 -05:00
parent 8df5fc3bc7
commit 5c862b0615
6 changed files with 12 additions and 26 deletions

View file

@ -1,5 +1,5 @@
CC = cl
CFLAGS = /O2 /EHsc /I"src/"
CFLAGS = /O2 /sdl /Isrc /D_CRT_SECURE_NO_WARNINGS
HOEDOWN_SRC = \
src\autolink.obj \

View file

@ -5,7 +5,7 @@
#include <stdio.h>
#include <ctype.h>
#if defined(_WIN32)
#ifdef _MSC_VER
#define strncasecmp _strnicmp
#endif
@ -190,7 +190,7 @@ hoedown_autolink__email(
int nb = 0, np = 0;
for (rewind = 0; rewind < max_rewind; ++rewind) {
uint8_t c = data[-rewind - 1];
uint8_t c = data[-1 - rewind];
if (isalnum(c))
continue;
@ -247,7 +247,7 @@ hoedown_autolink__url(
if (size < 4 || data[1] != '/' || data[2] != '/')
return 0;
while (rewind < max_rewind && isalpha(data[-rewind - 1]))
while (rewind < max_rewind && isalpha(data[-1 - rewind]))
rewind++;
if (!hoedown_autolink_is_safe(data - rewind, size + rewind))

View file

@ -1,5 +1,3 @@
#define BUFFER_MAX_ALLOC_SIZE (1024 * 1024 * 16) /* 16mb */
#include "buffer.h"
#include <stdio.h>
@ -7,12 +5,7 @@
#include <string.h>
#include <assert.h>
/* MSVC compat */
#if defined(_MSC_VER)
# define _buf_vsnprintf _vsnprintf
#else
# define _buf_vsnprintf vsnprintf
#endif
#define BUFFER_MAX_ALLOC_SIZE (1024 * 1024 * 16) /* 16mb */
/* hoedown_buffer_new: allocation of a new buffer */
struct hoedown_buffer *
@ -176,25 +169,18 @@ hoedown_buffer_printf(struct hoedown_buffer *buf, const char *fmt, ...)
return;
va_start(ap, fmt);
n = _buf_vsnprintf((char *)buf->data + buf->size, buf->asize - buf->size, fmt, ap);
n = vsnprintf((char *)buf->data + buf->size, buf->asize - buf->size, fmt, ap);
va_end(ap);
if (n < 0) {
#ifdef _MSC_VER
va_start(ap, fmt);
n = _vscprintf(fmt, ap);
va_end(ap);
#else
if (n < 0)
return;
#endif
}
if ((size_t)n >= buf->asize - buf->size) {
if (hoedown_buffer_grow(buf, buf->size + n + 1) < 0)
return;
va_start(ap, fmt);
n = _buf_vsnprintf((char *)buf->data + buf->size, buf->asize - buf->size, fmt, ap);
n = vsnprintf((char *)buf->data + buf->size, buf->asize - buf->size, fmt, ap);
va_end(ap);
}

View file

@ -13,7 +13,7 @@ extern "C" {
#if defined(_MSC_VER)
#define __attribute__(x)
#define inline
#define inline __inline
#endif
typedef enum {

View file

@ -5,8 +5,8 @@
#include <stdio.h>
#include <ctype.h>
#if defined(_WIN32)
#define snprintf _snprintf
#ifdef _MSC_VER
#define snprintf _snprintf
#endif
struct smartypants_data {

View file

@ -9,7 +9,7 @@
#include "stack.h"
#if defined(_WIN32)
#ifdef _MSC_VER
#define strncasecmp _strnicmp
#endif