HappenLee commented on code in PR #58004:
URL: https://github.com/apache/doris/pull/58004#discussion_r2544522149
##########
be/src/geo/wkt_parse.cpp:
##########
@@ -17,28 +17,30 @@
#include "geo/wkt_parse.h"
+#include <utility>
+
+#include "geo/wkt_lex.l.h"
#include "geo/wkt_parse_ctx.h"
#include "geo/wkt_parse_type.h" // IWYU pragma: keep
#include "geo/wkt_yacc.y.hpp"
-#define YYSTYPE WKT_STYPE
-#define YY_EXTRA_TYPE WktParseContext*
-#include "geo/wkt_lex.l.h"
+extern int wkt_lex_init_extra(WktParseContext*, yyscan_t*);
namespace doris {
#include "common/compile_check_avoid_begin.h"
-GeoParseStatus WktParse::parse_wkt(const char* str, size_t len, GeoShape**
shape) {
+GeoParseStatus WktParse::parse_wkt(const char* str, size_t len,
std::unique_ptr<GeoShape>& shape) {
WktParseContext ctx;
- // initialize lexer
- wkt_lex_init_extra(&ctx, &ctx.scaninfo);
- wkt__scan_bytes(str, len, ctx.scaninfo);
// parse
- auto res = wkt_parse(&ctx);
- wkt_lex_destroy(ctx.scaninfo);
- if (res == 0) {
- *shape = ctx.shape;
+ int st = wkt_parse(str, len, ctx);
+
+ if (st == GEO_PARSE_OK) {
+ if (ctx.shape != nullptr) {
+ shape = std::move(ctx.shape);
+ } else [[unlikely]] {
+ ctx.parse_status = GEO_PARSE_WKT_SYNTAX_ERROR;
+ }
} else {
if (ctx.parse_status == GEO_PARSE_OK) {
Review Comment:
为什么这里要重新设置一下parse_status,函数返回的st和ctx.parse_status有什么区别,能不能只保留一个
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]