mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-06 15:06:50 +08:00
re2 fixes for Windows
This commit is contained in:
@@ -11,7 +11,9 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#ifndef WIN32
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include "util/atomicops.h"
|
||||
#include "util/util.h"
|
||||
|
@@ -14,8 +14,10 @@
|
||||
|
||||
namespace re2 {
|
||||
|
||||
#define HAVE_PTHREAD 1
|
||||
#define HAVE_RWLOCK 1
|
||||
#ifndef WIN32
|
||||
#define HAVE_PTHREAD 1
|
||||
#define HAVE_RWLOCK 1
|
||||
#endif
|
||||
|
||||
#if defined(NO_THREADS)
|
||||
typedef int MutexType; // to keep a lock-count
|
||||
|
@@ -38,7 +38,11 @@ static void StringAppendV(string* dst, const char* format, va_list ap) {
|
||||
|
||||
// Restore the va_list before we use it again
|
||||
va_copy(backup_ap, ap);
|
||||
result = vsnprintf(buf, length, format, backup_ap);
|
||||
#ifdef WIN32
|
||||
result = vsnprintf_s(buf, length, length, format, backup_ap);
|
||||
#else
|
||||
result = vsnprintf(buf, length, format, backup_ap);
|
||||
#endif
|
||||
va_end(backup_ap);
|
||||
|
||||
if ((result >= 0) && (result < length)) {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
// Copyright 1999-2005 The RE2 Authors. All Rights Reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
#include <stdio.h>
|
||||
#include "re2/util/util.h"
|
||||
#include "re2/stringpiece.h"
|
||||
|
||||
@@ -38,7 +38,12 @@ int CEscapeString(const char* src, int src_len, char* dest,
|
||||
if (c < ' ' || c > '~') {
|
||||
if (dest_len - used < 5) // space for four-character escape + \0
|
||||
return -1;
|
||||
sprintf(dest + used, "\\%03o", c);
|
||||
#ifdef WIN32
|
||||
sprintf_s(dest + used, dest_len, "\\%03o", c);
|
||||
#else
|
||||
std::sprintf(dest + used, "\\%03o", c);
|
||||
#endif
|
||||
|
||||
used += 4;
|
||||
} else {
|
||||
dest[used++] = c; break;
|
||||
|
Reference in New Issue
Block a user