Skip to content

Commit

Permalink
rewrote to match default branch parsing more closely
Browse files Browse the repository at this point in the history
  • Loading branch information
kentslaney committed Dec 1, 2023
1 parent 7199780 commit bf1f2e1
Showing 1 changed file with 5 additions and 23 deletions.
28 changes: 5 additions & 23 deletions src/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,34 +56,21 @@ bool isLocalSocket(const char* host) {
return host[0] == '/';
}

void verifyPort(const char* input, ServerSpec* res, bool* valid_port) {
/*
if (*valid_port && input > res->port) {
res->port[-1] = '\0';
} else if (res->alias == NULL) {
res->port = NULL;
}
*valid_port = false;
*/
if (res->port != NULL) {
res->port[-1] = '\0';
}
}

// modifies input string and output pointers reference input
ServerSpec splitServerString(char* input) {
bool escaped = false, valid_port = false;
bool escaped = false;
ServerSpec res = { input, NULL, NULL };
for (;; input++) {
switch (*input)
{
case '\0':
verifyPort(input, &res, &valid_port);
return res;
case ':':
if (res.alias == NULL) {
res.port = input + 1;
valid_port = true;
*input = '\0';
if (res.port == NULL) {
res.port = input + 1;
}
}
escaped = false;
continue;
Expand All @@ -92,21 +79,16 @@ ServerSpec splitServerString(char* input) {
*input = '\0';
if (res.alias == NULL) {
res.alias = input + 1;
verifyPort(input, &res, &valid_port);
continue;
} else {
return res;
}
}
default:
valid_port = false;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
escaped = false;
continue;
case '\\':
escaped ^= 1;
valid_port = false;
}
}
}
Expand Down

0 comments on commit bf1f2e1

Please sign in to comment.