From 8d5c32ba92f8d4902b15bc5ba340a420a212ce73 Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Fri, 15 Apr 2016 10:57:01 -0700 Subject: [PATCH] Remove the strings.h portability header Summary:Although, according to the manpage, these functions are defined in `strings.h`, but they are also defined in `string.h`. We never actually use these functions via `strings.h`, and instead only ever reference them via `string.h`. To keep things sane, lets just move the functions into `string.h` and kill `strings.h`. Reviewed By: yfeldblum Differential Revision: D3181596 fb-gh-sync-id: 8a474df510ddafc4c595b08b809a7c33e3256177 fbshipit-source-id: 8a474df510ddafc4c595b08b809a7c33e3256177 --- folly/Makefile.am | 2 -- folly/portability/String.cpp | 16 +++++++++++++++- folly/portability/String.h | 7 ++++++- folly/portability/Strings.cpp | 31 ------------------------------- folly/portability/Strings.h | 29 ----------------------------- 5 files changed, 21 insertions(+), 64 deletions(-) delete mode 100755 folly/portability/Strings.cpp delete mode 100755 folly/portability/Strings.h diff --git a/folly/Makefile.am b/folly/Makefile.am index 95f36ac3..2c199540 100644 --- a/folly/Makefile.am +++ b/folly/Makefile.am @@ -282,7 +282,6 @@ nobase_follyinclude_HEADERS = \ portability/Memory.h \ portability/PThread.h \ portability/String.h \ - portability/Strings.h \ portability/Syslog.h \ portability/SysFile.h \ portability/SysMman.h \ @@ -428,7 +427,6 @@ libfolly_la_SOURCES = \ portability/Malloc.cpp \ portability/Memory.cpp \ portability/String.cpp \ - portability/Strings.cpp \ portability/SysFile.cpp \ portability/SysMman.cpp \ portability/SysResource.cpp \ diff --git a/folly/portability/String.cpp b/folly/portability/String.cpp index e48076b1..48ae5124 100755 --- a/folly/portability/String.cpp +++ b/folly/portability/String.cpp @@ -44,7 +44,21 @@ extern "C" char* strndup(const char* a, size_t len) { #endif #ifdef _WIN32 -extern "C" char* strtok_r(char* str, char const* delim, char** ctx) { +extern "C" { +void bzero(void* s, size_t n) { + memset(s, 0, n); +} + +int strcasecmp(const char* a, const char* b) { + return _stricmp(a, b); +} + +int strncasecmp(const char* a, const char* b, size_t c) { + return _strnicmp(a, b, c); +} + +char* strtok_r(char* str, char const* delim, char** ctx) { return strtok_s(str, delim, ctx); } +} #endif diff --git a/folly/portability/String.h b/folly/portability/String.h index d9022cde..f7b296a8 100755 --- a/folly/portability/String.h +++ b/folly/portability/String.h @@ -30,5 +30,10 @@ extern "C" char* strndup(const char* a, size_t len); #endif #ifdef _WIN32 -extern "C" char* strtok_r(char* str, char const* delim, char** ctx); +extern "C" { +void bzero(void* s, size_t n); +int strcasecmp(const char* a, const char* b); +int strncasecmp(const char* a, const char* b, size_t c); +char* strtok_r(char* str, char const* delim, char** ctx); +} #endif diff --git a/folly/portability/Strings.cpp b/folly/portability/Strings.cpp deleted file mode 100755 index ea51f373..00000000 --- a/folly/portability/Strings.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2016 Facebook, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#ifdef _WIN32 -#include - -extern "C" { -void bzero(void* s, size_t n) { memset(s, 0, n); } - -int strcasecmp(const char* a, const char* b) { return _stricmp(a, b); } - -int strncasecmp(const char* a, const char* b, size_t c) { - return _strnicmp(a, b, c); -} -} -#endif diff --git a/folly/portability/Strings.h b/folly/portability/Strings.h deleted file mode 100755 index 3c0b016d..00000000 --- a/folly/portability/Strings.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2016 Facebook, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#ifndef _WIN32 -#include -#else -#include - -extern "C" { -void bzero(void* s, size_t n); -int strcasecmp(const char* a, const char* b); -int strncasecmp(const char* a, const char* b, size_t c); -} -#endif -- 2.34.1