8000 Feature/apm 60 (#14700) · arangodb/arangodb@b251a0c · GitHub
[go: up one dir, main page]

Skip to content

Commit b251a0c

Browse files
authored
Feature/apm 60 (#14700)
1 parent 1898ac4 commit b251a0c

File tree

142 files changed

+4640
-1699
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+4640
-1699
lines changed

3rdParty/fuerte/src/message.cpp

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,19 @@
3232

3333
namespace {
3434
static std::string const emptyString;
35+
36+
inline int hex2int(char ch, int errorCode) {
37+
if ('0' <= ch && ch <= '9') {
38+
return ch - '0';
39+
} else if ('A' <= ch && ch <= 'F') {
40+
return ch - 'A' + 10;
41+
} else if ('a' <= ch && ch <= 'f') {
42+
return ch - 'a' + 10;
43+
}
44+
45+
return errorCode;
3546
}
47+
} // namespace
3648

3749
namespace arangodb { namespace fuerte { inline namespace v1 {
3850

@@ -98,7 +110,29 @@ void RequestHeader::parseArangoPath(std::string const& p) {
98110
++q;
99111
}
100112
FUERTE_ASSERT(q >= pathBegin);
101-
this->database = std::string(pathBegin, q - pathBegin);
113+
this->database.clear();
114+
char const* p = pathBegin;
115+
while (p != q) {
116+
std::string::value_type c = (*p);
117+
if (c == '%') {
118+
if (p + 2 < q) {
119+
int h = ::hex2int(p[1], 256) << 4;
120+
h += ::hex2int(p[2], 256);
121+
if (h >= 256) {
122+
throw std::invalid_argument("invalid encoding value in request URL");
123+
}
124+
this->database.push_back(static_cast<char>(h & 0xFF));
125+
p += 2;
126+
} else {
127+
throw std::invalid_argument("invalid encoding value in request URL");
128+
}
129+
} else if (c == '+') {
130+
this->database.push_back(' ');
131+
} else {
132+
this->database.push_back(c);
133+
}
134+
++p;
135+
}
102136
if (*q == '\0') {
103137
this->path = "/";
104138
} else {

3rdParty/linenoise-ng/src/linenoise.cpp

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,10 @@
129129
#include "linenoise.h"
130130
#include "ConvertUTF.h"
131131

132+
#include <atomic>
133+
#include <memory>
132134
#include <string>
133135
#include <vector>
134-
#include <memory>
135136

136137
using std::string;
137138
using std::vector;
@@ -544,20 +545,15 @@ struct linenoiseCompletions {
544545
// make control-characters more readable
545546
#define ctrlChar(upperCaseASCII) (upperCaseASCII - 0x40)
546547

547-
/**
548-
* Recompute widths of all characters in a char32_t buffer
549-
* @param text input buffer of Unicode characters
550-
* @param widths output buffer of character widths
551-
* @param charCount number of characters in buffer
552-
*/
553548
namespace linenoise_ng {
554-
int mk_wcwidth(char32_t ucs);
549+
int wcwidth(char32_t ucs);
550+
int wcswidth(char32_t const* ucs, size_t n);
555551
}
556552

557553
static void recomputeCharacterWidths(const char32_t* text, char* widths,
558554
int charCount) {
559555
for (int i = 0; i < charCount; ++i) {
560-
widths[i] = mk_wcwidth(text[i]);
556+
widths[i] = linenoise_ng::wcwidth(text[i]);
561557
}
562558
}
563559

@@ -591,17 +587,8 @@ static void calculateScreenPosition(int x, int y, int screenColumns,
591587
}
592588
}
593589

594-
/**
595-
* Calculate a column width using mk_wcswidth()
596-
* @param buf32 text to calculate
597-
* @param len length of text to calculate
598-
*/
599-
namespace linenoise_ng {
600-
int mk_wcswidth(const char32_t* pwcs, size_t n);
601-
}
602-
603590
static int calculateColumnPosition(char32_t* buf32, int len) {
604-
int width = mk_wcswidth(reinterpret_cast<const char32_t*>(buf32), len);
591+
int width = linenoise_ng::wcswidth(reinterpret_cast<const char32_t*>(buf32), len);
605592
if (width == -1)
606593
return len;
607594
else
@@ -661,7 +648,10 @@ struct PromptInfo : public PromptBase {
661648
*pOut = c;
662649
++pOut;
663650
++pIn;
664-
++len;
651+
int chars = linenoise_ng::wcwidth(c);
652+
if (chars >= 0) {
653+
len += chars;
654+
}
665655
if ('\n' == c || ++x >= promptScreenColumns) {
666656
x = 0;
667657
++promptExtraLines;
@@ -2499,7 +2489,7 @@ static bool isCharacterAlphanumeric(char32_t testChar) {
24992489
}
25002490

25012491
#ifndef _WIN32
2502-
static bool gotResize = false;
2492+
static std::atomic<bool> gotResize = false;
25032493
#endif
25042494
static int keyType = 0;
25052495

@@ -2559,10 +2549,9 @@ int InputBuffer::getInputLine(PromptBase& pi) {
25592549
}
25602550

25612551
#ifndef _WIN32
2562-
if (c == 0 && gotResize) {
2552+
if (c >= 0 && gotResize.load() && gotResize.exchange(false)) {
25632553
// caught a window resize event
25642554
// now redraw the prompt and line
2565-
gotResize = false;
25662555
pi.promptScreenColumns = getScreenColumns();
25672556
dynamicRefresh(pi, buf32, len,
25682557
pos); // redraw the original prompt with current input
@@ -3183,7 +3172,7 @@ void linenoisePreloadBuffer(const char* preloadText) {
31833172
*/
31843173
char* linenoise(const char* prompt) {
31853174
#ifndef _WIN32
3186-
gotResize = false;
3175+
gotResize.store(false);
31873176
#endif
31883177
if (isatty(STDIN_FILENO)) { // input is from a terminal
31893178
char32_t buf32[LINENOISE_MAX_LINE + 1];
@@ -3431,7 +3420,7 @@ void linenoisePrintKeyCodes(void) {
34313420
#ifndef _WIN32
34323421
static void WindowSizeChanged(int) {
34333422
// do nothing here but setting this flag
3434-
gotResize = true;
3423+
gotResize.store(true);
34353424
}
34363425
#endif
34373426

0 commit comments

Comments
 (0)
0