From 48b1fd65f19574b4f9fce6e1c95d20e1bee1e86b Mon Sep 17 00:00:00 2001 From: freemine Date: Mon, 26 Oct 2020 19:53:15 +0800 Subject: [PATCH] header file workaround for win_flex --- src/connector/odbc/src/todbc_conv.c | 3 +- src/connector/odbc/src/todbc_conv.h | 3 +- .../odbc/src/todbc_flex_workaround.h | 30 +++++++++++++++++++ src/connector/odbc/src/todbc_scanner.l | 12 ++++++++ src/connector/odbc/src/todbc_util.c | 3 -- src/connector/odbc/src/todbc_util.h | 3 +- src/connector/odbc/tests/CMakeLists.txt | 2 +- src/connector/odbc/tests/main.c | 9 ++++-- 8 files changed, 54 insertions(+), 11 deletions(-) create mode 100644 src/connector/odbc/src/todbc_flex_workaround.h diff --git a/src/connector/odbc/src/todbc_conv.c b/src/connector/odbc/src/todbc_conv.c index 695201af53..c6ce6a29f6 100644 --- a/src/connector/odbc/src/todbc_conv.c +++ b/src/connector/odbc/src/todbc_conv.c @@ -14,9 +14,10 @@ */ #include "todbc_conv.h" - #include "todbc_util.h" +#include "os.h" + #include #include #include diff --git a/src/connector/odbc/src/todbc_conv.h b/src/connector/odbc/src/todbc_conv.h index 4b326230f0..9753620ee2 100644 --- a/src/connector/odbc/src/todbc_conv.h +++ b/src/connector/odbc/src/todbc_conv.h @@ -16,8 +16,7 @@ #ifndef _todbc_conv_h_ #define _todbc_conv_h_ -#include -#include +#include "todbc_flex_workaround.h" #include #include "iconv.h" diff --git a/src/connector/odbc/src/todbc_flex_workaround.h b/src/connector/odbc/src/todbc_flex_workaround.h new file mode 100644 index 0000000000..d6c79cf19a --- /dev/null +++ b/src/connector/odbc/src/todbc_flex_workaround.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef _todbc_flex_workaround_h_ +#define _todbc_flex_workaround_h_ + +#ifdef _MSC_VER +#include +#include +#endif +#ifndef INT8_MIN +#include +#endif +#include +#include + +#endif // _todbc_flex_workaround_h_ + diff --git a/src/connector/odbc/src/todbc_scanner.l b/src/connector/odbc/src/todbc_scanner.l index 8e178aa366..4c7aa74f2c 100644 --- a/src/connector/odbc/src/todbc_scanner.l +++ b/src/connector/odbc/src/todbc_scanner.l @@ -1,8 +1,18 @@ %{ +#include +#include +#include + #include "todbc_util.h" #include +#ifdef _MSC_VER +#include "msvcLibgen.h" +#define strncasecmp _strnicmp +#define strcasecmp _stricmp +#endif + typedef struct params_s params_t; struct params_s { char *key; @@ -68,6 +78,8 @@ do { \ %option prefix="todbc_yy" %option extra-type="struct params_s *" +%option nounistd +%option never-interactive %option reentrant %option noyywrap %option noinput nounput diff --git a/src/connector/odbc/src/todbc_util.c b/src/connector/odbc/src/todbc_util.c index d462b37c1e..35f02bedd5 100644 --- a/src/connector/odbc/src/todbc_util.c +++ b/src/connector/odbc/src/todbc_util.c @@ -17,9 +17,6 @@ #include "iconv.h" -#include -#include -#include #include #include diff --git a/src/connector/odbc/src/todbc_util.h b/src/connector/odbc/src/todbc_util.h index 5f58ff13ce..b987c633a2 100644 --- a/src/connector/odbc/src/todbc_util.h +++ b/src/connector/odbc/src/todbc_util.h @@ -16,10 +16,9 @@ #ifndef _TODBC_UTIL_H_ #define _TODBC_UTIL_H_ +#include "todbc_flex_workaround.h" #include "todbc_log.h" -#include -#include const char* sql_sql_type(int type); const char* sql_c_type(int type); diff --git a/src/connector/odbc/tests/CMakeLists.txt b/src/connector/odbc/tests/CMakeLists.txt index 1649b45e02..d998527dc8 100644 --- a/src/connector/odbc/tests/CMakeLists.txt +++ b/src/connector/odbc/tests/CMakeLists.txt @@ -9,5 +9,5 @@ ENDIF () IF (TD_WINDOWS_64) AUX_SOURCE_DIRECTORY(. SRC) ADD_EXECUTABLE(tcodbc main.c) - TARGET_LINK_LIBRARIES(tcodbc odbc) + # TARGET_LINK_LIBRARIES(tcodbc odbc) ENDIF () diff --git a/src/connector/odbc/tests/main.c b/src/connector/odbc/tests/main.c index 1321ade328..2a0dca7a4d 100644 --- a/src/connector/odbc/tests/main.c +++ b/src/connector/odbc/tests/main.c @@ -1,4 +1,4 @@ -#include +#include "os.h" #include #include @@ -423,7 +423,12 @@ int test_sqls_in_stmt(SQLHENV env, SQLHDBC conn, SQLHSTMT stmt, const char *sqls char *line = NULL; size_t len = 0; - ssize_t n = getline(&line, &len, f); + ssize_t n = 0; +#ifdef _MSC_VER + n = taosGetlineImp(&line, &len, f); +#else + n = getline(&line, &len, f); +#endif if (n==-1) break; const char *p = NULL; -- GitLab