Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
SChernykh committed Oct 2, 2021
2 parents 35a823f + 2e8f5d8 commit 5bbae3e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
2 changes: 1 addition & 1 deletion doc/dom.zh-cn.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DOM

文档对象模型(Document Object Model, DOM)是一种罝于内存中的 JSON 表示方式,以供查询及操作。我们己于 [教程](doc/tutorial.zh-cn.md) 中介绍了 DOM 的基本用法,本节将讲述一些细节及高级用法。
文档对象模型(Document Object Model, DOM)是一种罝于内存中的 JSON 表示方式,以供查询及操作。我们已于 [教程](doc/tutorial.zh-cn.md) 中介绍了 DOM 的基本用法,本节将讲述一些细节及高级用法。

[TOC]

Expand Down
35 changes: 25 additions & 10 deletions include/rapidjson/uri.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,20 +238,27 @@ class GenericUri {

// Allocate one block containing each part of the URI (5) plus base plus full URI, all null terminated.
// Order: scheme, auth, path, query, frag, base, uri
// Note need to set, increment, assign in 3 stages to avoid compiler warning bug.
size_t total = (3 * len + 7) * sizeof(Ch);
scheme_ = static_cast<Ch*>(allocator_->Malloc(total));
*scheme_ = '\0';
auth_ = scheme_ + 1;
auth_ = scheme_;
auth_++;
*auth_ = '\0';
path_ = auth_ + 1;
path_ = auth_;
path_++;
*path_ = '\0';
query_ = path_ + 1;
query_ = path_;
query_++;
*query_ = '\0';
frag_ = query_ + 1;
frag_ = query_;
frag_++;
*frag_ = '\0';
base_ = frag_ + 1;
base_ = frag_;
base_++;
*base_ = '\0';
uri_ = base_ + 1;
uri_ = base_;
uri_++;
*uri_ = '\0';
return total;
}
Expand Down Expand Up @@ -293,7 +300,9 @@ class GenericUri {
}
}
// Look for auth (//([^/?#]*))?
auth_ = scheme_ + GetSchemeStringLength() + 1;
// Note need to set, increment, assign in 3 stages to avoid compiler warning bug.
auth_ = scheme_ + GetSchemeStringLength();
auth_++;
*auth_ = '\0';
if (start < len - 1 && uri[start] == '/' && uri[start + 1] == '/') {
pos2 = start + 2;
Expand All @@ -308,7 +317,9 @@ class GenericUri {
start = pos2;
}
// Look for path ([^?#]*)
path_ = auth_ + GetAuthStringLength() + 1;
// Note need to set, increment, assign in 3 stages to avoid compiler warning bug.
path_ = auth_ + GetAuthStringLength();
path_++;
*path_ = '\0';
if (start < len) {
pos2 = start;
Expand All @@ -326,7 +337,9 @@ class GenericUri {
}
}
// Look for query (\?([^#]*))?
query_ = path_ + GetPathStringLength() + 1;
// Note need to set, increment, assign in 3 stages to avoid compiler warning bug.
query_ = path_ + GetPathStringLength();
query_++;
*query_ = '\0';
if (start < len && uri[start] == '?') {
pos2 = start + 1;
Expand All @@ -341,7 +354,9 @@ class GenericUri {
}
}
// Look for fragment (#(.*))?
frag_ = query_ + GetQueryStringLength() + 1;
// Note need to set, increment, assign in 3 stages to avoid compiler warning bug.
frag_ = query_ + GetQueryStringLength();
frag_++;
*frag_ = '\0';
if (start < len && uri[start] == '#') {
std::memcpy(frag_, &uri[start], (len - start) * sizeof(Ch));
Expand Down

0 comments on commit 5bbae3e

Please sign in to comment.