Skip to content

Commit

Permalink
Sync final newlines in source code (#2017)
Browse files Browse the repository at this point in the history
* Sync final newlines in source code

This patch syncs final newlines in source code files:
- trims multiple final newlines into one
- adds one final newline where it was missing

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 standard [2] and above [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Newline characters:
- LF (\n) (*nix and Mac, default)
- CRLF (\r\n) (Windows)
- CR (\r) (old Mac, obsolete)

Although it is not mandatory for all files to have this issue fixed, a
more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2

* Each block has three rows

Each block has three rows
  • Loading branch information
petk authored and twose committed Oct 1, 2018
1 parent ca7464a commit d0d30a3
Show file tree
Hide file tree
Showing 153 changed files with 74 additions and 169 deletions.
2 changes: 1 addition & 1 deletion CREDITS
@@ -1,3 +1,3 @@
Tianfeng Han(mikan.tenny@gmail.com)
Tencent Inc.
QQ: 350749960
QQ: 350749960
2 changes: 0 additions & 2 deletions Version2.md
Expand Up @@ -167,5 +167,3 @@ You should add "extension=swoole.so" to php.ini, execute the demo program.
* aop
* molten
* xhprof


2 changes: 1 addition & 1 deletion benchmark/ab.sh
@@ -1,4 +1,4 @@
ab -c 1000 -n 1000000 -k http://127.0.0.1:9501/
ab -c 1000 -n 1000000 -k -p post.data -T 'application/x-www-form-urlencoded' http://127.0.0.1:9501/
#post 24K
ab -c 100 -n 100000 -k -p post.big.data -T 'application/x-www-form-urlencoded' http://127.0.0.1:9501/
ab -c 100 -n 100000 -k -p post.big.data -T 'application/x-www-form-urlencoded' http://127.0.0.1:9501/
3 changes: 0 additions & 3 deletions benchmark/coroutine.php
Expand Up @@ -79,6 +79,3 @@ public function onRequest($request, $response)

$server = new Server();
$server->run();



1 change: 0 additions & 1 deletion benchmark/run.php
Expand Up @@ -571,4 +571,3 @@ function report()
echo "one req use(ms):\t".substr($usetime/$this->request_num*1000,0,5),"\n";
}
}

2 changes: 1 addition & 1 deletion benchmark/seria_bench.php
Expand Up @@ -480,4 +480,4 @@
}
$etime = microtime(true);
var_dump("swoole_unserialize :". ($etime - $stime));
?>
?>
1 change: 0 additions & 1 deletion benchmark/udp.php
Expand Up @@ -33,4 +33,3 @@ function my_onPacket(swoole_server $serv, $data, $addr)
$serv->on('Receive', 'my_onReceive');
//$serv->on('Packet', 'my_onPacket');
$serv->start();

1 change: 0 additions & 1 deletion build.sh
Expand Up @@ -14,4 +14,3 @@ make clean
./configure --enable-openssl --enable-sockets --enable-async-redis --enable-mysqlnd --enable-http2
make -j
make install

1 change: 0 additions & 1 deletion clear.sh
Expand Up @@ -4,4 +4,3 @@ find . -name \*.la -o -name \*.a | xargs rm -f
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp.la modules/* libs/*

1 change: 0 additions & 1 deletion core-tests/include/tests.h
Expand Up @@ -6,4 +6,3 @@
#include "coroutine.h"
#include "socket.h"
#include <gtest/gtest.h>

1 change: 0 additions & 1 deletion core-tests/src/hashmap.cpp
Expand Up @@ -83,4 +83,3 @@ TEST(hashmap, integer)
free(lists[i]);
}
}

1 change: 0 additions & 1 deletion core-tests/src/ringbuffer.cpp
Expand Up @@ -158,4 +158,3 @@ static void thread_read(int i)
}
printf("worker #%d finish, recv_count=%d\n", i, recv_count);
}

2 changes: 1 addition & 1 deletion core-tests/src/serv_test.cpp
Expand Up @@ -216,4 +216,4 @@ namespace swoole_test
printf("PID=%d\tClose fd=%d|from_id=%d\n", getpid(), info->fd, info->from_id);
}

}
}
2 changes: 1 addition & 1 deletion examples/atomic/long.php
Expand Up @@ -5,4 +5,4 @@
echo $l->sub(20)."\n";
echo $l->sub(-20)."\n";
echo $l->cmpset(-2 ** 36, 0)."\n";
echo $l->cmpset(-2 ** 36 + 20, 0)."\n";
echo $l->cmpset(-2 ** 36 + 20, 0)."\n";
1 change: 0 additions & 1 deletion examples/c10k.php
Expand Up @@ -26,4 +26,3 @@
}
}
sleep(1000);

1 change: 0 additions & 1 deletion examples/channel.php
Expand Up @@ -42,4 +42,3 @@
echo "total pop bytes: $bytes\n";
var_dump($chan->stats());
}

2 changes: 1 addition & 1 deletion examples/channel/leader_follower.php
Expand Up @@ -32,4 +32,4 @@
{
static $index = 0;
$chan->push("hello-" . $index++);
});
});
1 change: 0 additions & 1 deletion examples/client/get_socket.php
Expand Up @@ -31,4 +31,3 @@ function getClient()
}

$client->close();

1 change: 0 additions & 1 deletion examples/client/sync.php
Expand Up @@ -27,4 +27,3 @@
{
goto do_connect;
}

1 change: 0 additions & 1 deletion examples/client/test.txt
Expand Up @@ -7,4 +7,3 @@ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
DDDDDDDDDDDDDDDDDDDDDDDDDDD

2 changes: 0 additions & 2 deletions examples/client/udp_sync.php
Expand Up @@ -8,5 +8,3 @@
echo $client->recv()."\n";
sleep(1);
}


2 changes: 1 addition & 1 deletion examples/coroutine/TestHttpServ.php
Expand Up @@ -114,4 +114,4 @@ public function start(){
);
$th = new TestHttpServer();
$th ->set($setting);
$th ->start();
$th ->start();
2 changes: 1 addition & 1 deletion examples/coroutine/client_send_yield.php
Expand Up @@ -24,4 +24,4 @@
var_dump($client->errCode);
});

swoole_event_wait();
swoole_event_wait();
1 change: 0 additions & 1 deletion examples/coroutine/coro_call_user.php
Expand Up @@ -17,4 +17,3 @@ function test($params)
return "test return\n";
}
echo "main script last\n";

2 changes: 1 addition & 1 deletion examples/coroutine/coro_destruct.php
Expand Up @@ -25,4 +25,4 @@ function __destruct()

$t = new T();
$t->test();
echo "end \n";
echo "end \n";
1 change: 0 additions & 1 deletion examples/coroutine/coro_empty.php
Expand Up @@ -6,4 +6,3 @@
echo "no coro exit\n";
});
echo "exec file end\n";

2 changes: 1 addition & 1 deletion examples/coroutine/coro_gethost.php
Expand Up @@ -8,4 +8,4 @@
});
echo "111\n";

echo "222\n";
echo "222\n";
2 changes: 1 addition & 1 deletion examples/coroutine/coro_include.php
Expand Up @@ -6,4 +6,4 @@
if (!extension_loaded("swoole"))
{
exit("swoole extension is required");
}
}
1 change: 0 additions & 1 deletion examples/coroutine/coro_set_stack_size.php
Expand Up @@ -8,4 +8,3 @@
echo "no coro exit\n";
});
echo "exec file end\n";

2 changes: 1 addition & 1 deletion examples/coroutine/coro_stackless.php
Expand Up @@ -16,4 +16,4 @@
$data = $client->recv();
echo "recv data" . var_export($data, 1) . "\n";
});
echo "end\n";
echo "end\n";
2 changes: 1 addition & 1 deletion examples/coroutine/coro_util.php
Expand Up @@ -13,4 +13,4 @@
co::resume($id);
echo "start to resume $id @2\n";
co::resume($id);
echo "main\n";
echo "main\n";
2 changes: 1 addition & 1 deletion examples/coroutine/enable_coroutine.php
Expand Up @@ -24,4 +24,4 @@
}
});

$http->start();
$http->start();
1 change: 0 additions & 1 deletion examples/coroutine/exception/empty.php
Expand Up @@ -12,4 +12,3 @@
}
});
echo "exec file end\n";

2 changes: 1 addition & 1 deletion examples/coroutine/exit_in_coroutine.php
Expand Up @@ -23,4 +23,4 @@ function your_code()
assert($e->getFlags() === SWOOLE_EXIT_IN_COROUTINE);
return;
}
});
});
2 changes: 1 addition & 1 deletion examples/coroutine/exit_with_status.php
Expand Up @@ -9,4 +9,4 @@
}
});
swoole_event_wait();
exit($exit_status);
exit($exit_status);
2 changes: 1 addition & 1 deletion examples/coroutine/fread.php
Expand Up @@ -8,4 +8,4 @@
fseek($fp, 256);
$r = co::fread($fp);
var_dump($r);
});
});
2 changes: 1 addition & 1 deletion examples/coroutine/fwrite.php
Expand Up @@ -7,4 +7,4 @@
{
$r = co::fwrite($fp, "hello world\n", 5);
var_dump($r);
});
});
1 change: 0 additions & 1 deletion examples/coroutine/gethostbyname.php
Expand Up @@ -5,4 +5,3 @@
$ip = co::gethostbyname("www.baidu.com");
echo "IP: $ip\n";
});

2 changes: 1 addition & 1 deletion examples/coroutine/http2_client.php
Expand Up @@ -68,4 +68,4 @@
}

// $cli->close();
});
});
3 changes: 0 additions & 3 deletions examples/coroutine/http_backend_serv.php
Expand Up @@ -38,6 +38,3 @@ public static function staticFunc()
$server = new Server();

$server->run();



2 changes: 1 addition & 1 deletion examples/coroutine/http_download.php
Expand Up @@ -10,4 +10,4 @@
'Accept-Encoding' => 'gzip'
]);
$cli->download('/static/files/swoole-logo.svg', __DIR__ . '/logo.svg');
});
});
3 changes: 0 additions & 3 deletions examples/coroutine/httpmulti.php
Expand Up @@ -160,6 +160,3 @@ public static function staticFunc()
$server = new Server();

$server->run();



2 changes: 1 addition & 1 deletion examples/coroutine/mysql_execute_empty.php
Expand Up @@ -11,4 +11,4 @@
$stmt = $db->prepare('SELECT * FROM `userinfo`');
$ret = $stmt->execute();
var_dump($ret);
});
});
1 change: 0 additions & 1 deletion examples/coroutine/mysql_prepare.php
Expand Up @@ -39,4 +39,3 @@
$ret4 = $stmt2->execute(array(10, 99));
var_dump($ret4);
});

1 change: 0 additions & 1 deletion examples/coroutine/mysql_prepare_2.php
Expand Up @@ -22,4 +22,3 @@
var_dump($ret1);

});

2 changes: 1 addition & 1 deletion examples/coroutine/mysql_procedure_exec.php
Expand Up @@ -25,4 +25,4 @@
$ret = $stmt->execute(['hello mysql!']);
var_dump(current($ret[0])); // you said: "hello mysql!"
}
});
});
2 changes: 1 addition & 1 deletion examples/coroutine/mysql_unixsocket.php
Expand Up @@ -12,4 +12,4 @@
$stmt = $db->prepare('SELECT * FROM `user` WHERE id=?');
$ret = $stmt->execute([1]);
var_dump($ret);
});
});
2 changes: 1 addition & 1 deletion examples/coroutine/redis/auth.php
Expand Up @@ -5,4 +5,4 @@
$redis->auth('root');
$redis->set('key', 'swoole redis work');
var_dump($redis->get('key'));
});
});
2 changes: 1 addition & 1 deletion examples/coroutine/redis/eval.php
Expand Up @@ -4,4 +4,4 @@
$redis->connect('127.0.0.1', 6379);
$res = $redis->eval("return redis.call('get', 'key')");
var_dump($res);
});
});
2 changes: 1 addition & 1 deletion examples/coroutine/redis/request.php
Expand Up @@ -4,4 +4,4 @@
$redis->connect('127.0.0.1', 6379);
$res = $redis->request(['object', 'encoding', 'key1']);
var_dump($res);
});
});
2 changes: 1 addition & 1 deletion examples/coroutine/redis/serialize.php
Expand Up @@ -6,4 +6,4 @@
$redis->set('foo', ['bar' => 'baz']);
$ret = $redis->get('foo');
var_dump($ret);
});
});
2 changes: 1 addition & 1 deletion examples/coroutine/redis_pool.php
Expand Up @@ -20,4 +20,4 @@
$pool->push($redis);
});

$server->start();
$server->start();
2 changes: 1 addition & 1 deletion examples/coroutine/redis_subscribe.php
Expand Up @@ -12,4 +12,4 @@
//如果需要改变订阅的channel,请close掉连接,再调用subscribe
var_dump($val);
}
});
});
2 changes: 1 addition & 1 deletion examples/coroutine/select/1.php
Expand Up @@ -30,4 +30,4 @@
}

});
echo "main end\n";
echo "main end\n";
2 changes: 1 addition & 1 deletion examples/coroutine/select/2.php
Expand Up @@ -20,4 +20,4 @@
}

});
echo "main end\n";
echo "main end\n";
2 changes: 1 addition & 1 deletion examples/coroutine/select/6.php
Expand Up @@ -35,4 +35,4 @@
}

});
echo "main end\n";
echo "main end\n";
2 changes: 1 addition & 1 deletion examples/coroutine/select/7.php
Expand Up @@ -51,4 +51,4 @@
echo "chan2 pop [#$i] ret:".var_export($ret,1)."\n";
}
});
echo "main end\n";
echo "main end\n";
2 changes: 1 addition & 1 deletion examples/coroutine/select/8.php
Expand Up @@ -45,4 +45,4 @@
}

});
echo "main end\n";
echo "main end\n";
2 changes: 1 addition & 1 deletion examples/coroutine/select/9.php
Expand Up @@ -16,4 +16,4 @@
co::sleep(1);
$ret = $c1->pop();
echo "chan pop ret:".var_export($ret,1)."\n";
});
});
2 changes: 1 addition & 1 deletion examples/coroutine/select/poptimeout.php
Expand Up @@ -17,4 +17,4 @@
echo "sleep 2\n";
$ret = $c1->push("chan-1");
echo "chan push ret:".var_export($ret,1)." error:".$c1->errCode."\n";
});
});
1 change: 0 additions & 1 deletion examples/coroutine/socket/accept.php
Expand Up @@ -14,4 +14,3 @@
echo "send res {$ret} \n";
$conn->close();
});

1 change: 0 additions & 1 deletion examples/coroutine/tcp_backend_serv.php
Expand Up @@ -15,4 +15,3 @@
echo "Client: Close.\n";
});
$serv->start();

4 changes: 0 additions & 4 deletions examples/coroutine/udp_tcp_timeout.php
Expand Up @@ -120,7 +120,3 @@ public function start(){
$th = new TestHttpServer();
$th ->set($setting);
$th ->start();




0 comments on commit d0d30a3

Please sign in to comment.