You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by br...@apache.org on 2015/10/06 09:25:01 UTC
trafficserver git commit: TS-3956: clang format (sorry zwoop ;/)
Repository: trafficserver
Updated Branches:
refs/heads/master 147b9668e -> 61cbc5b95
TS-3956: clang format (sorry zwoop ;/)
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/61cbc5b9
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/61cbc5b9
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/61cbc5b9
Branch: refs/heads/master
Commit: 61cbc5b95a2d0ebbb1247d10628115112eac8827
Parents: 147b966
Author: Brian Geffon <br...@apache.org>
Authored: Tue Oct 6 00:24:52 2015 -0700
Committer: Brian Geffon <br...@apache.org>
Committed: Tue Oct 6 00:24:52 2015 -0700
----------------------------------------------------------------------
plugins/header_rewrite/header_rewrite_test.cc | 59 +++++++++++++---------
plugins/header_rewrite/parser.cc | 9 ++--
2 files changed, 38 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/61cbc5b9/plugins/header_rewrite/header_rewrite_test.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/header_rewrite_test.cc b/plugins/header_rewrite/header_rewrite_test.cc
index f4fdabd..4c836e4 100644
--- a/plugins/header_rewrite/header_rewrite_test.cc
+++ b/plugins/header_rewrite/header_rewrite_test.cc
@@ -27,45 +27,53 @@
const char PLUGIN_NAME[] = "TEST_header_rewrite";
const char PLUGIN_NAME_DBG[] = "TEST_dbg_header_rewrite";
-extern "C" void TSError(const char* fmt, ...) {
+extern "C" void
+TSError(const char *fmt, ...)
+{
char buf[2048];
int bytes = 0;
va_list args;
- va_start (args, fmt);
- if((bytes = vsnprintf (buf, sizeof(buf), fmt, args)) > 0) {
+ va_start(args, fmt);
+ if ((bytes = vsnprintf(buf, sizeof(buf), fmt, args)) > 0) {
fprintf(stderr, "TSError: %s: %.*s\n", PLUGIN_NAME, bytes, buf);
}
}
-extern "C" void TSDebug(const char *tag, const char* fmt, ...) {
+extern "C" void
+TSDebug(const char *tag, const char *fmt, ...)
+{
char buf[2048];
int bytes = 0;
va_list args;
- va_start (args, fmt);
- if((bytes = vsnprintf (buf, sizeof(buf), fmt, args)) > 0) {
+ va_start(args, fmt);
+ if ((bytes = vsnprintf(buf, sizeof(buf), fmt, args)) > 0) {
fprintf(stdout, "TSDebug: %s: %.*s\n", PLUGIN_NAME, bytes, buf);
}
}
-#define CHECK_EQ(x, y) \
- do { \
- if ( (x) != (y) ) { \
- fprintf(stderr, "CHECK FAILED\n"); \
- return 1; \
- } \
+#define CHECK_EQ(x, y) \
+ do { \
+ if ((x) != (y)) { \
+ fprintf(stderr, "CHECK FAILED\n"); \
+ return 1; \
+ } \
} while (false);
-class ParserTest : public Parser {
+class ParserTest : public Parser
+{
public:
- ParserTest(std::string line) : Parser(line) { }
+ ParserTest(std::string line) : Parser(line) {}
- std::vector<std::string> getTokens() {
+ std::vector<std::string>
+ getTokens()
+ {
return _tokens;
}
};
-int test_parsing() {
-
+int
+test_parsing()
+{
{
ParserTest p("cond %{READ_REQUEST_HDR_HOOK}");
CHECK_EQ(p.getTokens().size(), 2);
@@ -177,8 +185,9 @@ int test_parsing() {
return 0;
}
-int test_processing() {
-
+int
+test_processing()
+{
/*
* These tests are designed to verify that the processing of the parsed input is correct.
*/
@@ -210,16 +219,18 @@ int test_processing() {
return 0;
}
-int tests() {
- if (test_parsing() ||
- test_processing()) {
+int
+tests()
+{
+ if (test_parsing() || test_processing()) {
return 1;
}
return 0;
}
-int main () {
+int
+main()
+{
return tests();
}
-
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/61cbc5b9/plugins/header_rewrite/parser.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/parser.cc b/plugins/header_rewrite/parser.cc
index e7e32c3..43ead4a 100644
--- a/plugins/header_rewrite/parser.cc
+++ b/plugins/header_rewrite/parser.cc
@@ -36,9 +36,7 @@ Parser::Parser(const std::string &line) : _cond(false), _empty(false)
off_t cur_token_start = 0;
size_t cur_token_length = 0;
for (size_t i = 0; i < line.size(); ++i) {
-
- if (!inquote &&
- (std::isspace(line[i]) || (line[i] == '=' || line[i] == '>' || line[i] == '<'))) {
+ if (!inquote && (std::isspace(line[i]) || (line[i] == '=' || line[i] == '>' || line[i] == '<'))) {
if (extracting_token) {
cur_token_length = i - cur_token_start;
@@ -129,9 +127,8 @@ Parser::preprocess(std::vector<std::string> tokens)
std::string s = tokens[0].substr(2, tokens[0].size() - 3);
_op = s;
- if (tokens.size() > 2
- && (tokens[1][0] == '=' || tokens[1][0] == '>' || tokens[1][0] == '<')) { // cond + (=/</>) + argument
- _arg = tokens[1] + tokens[2];
+ if (tokens.size() > 2 && (tokens[1][0] == '=' || tokens[1][0] == '>' || tokens[1][0] == '<')) { // cond + (=/</>) + argument
+ _arg = tokens[1] + tokens[2];
} else if (tokens.size() > 1) {
_arg = tokens[1];
} else