re2 fixes for Windows

This commit is contained in:
Matt Hill
2015-07-21 19:53:36 -04:00
parent b8456987d0
commit d5bc315744
4 changed files with 18 additions and 5 deletions

View File

@@ -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;