From 3eea219548e84efdbc3148ce378fcba865f97a01 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Fri, 6 Dec 2013 14:15:43 -0800 Subject: Add basic source formatting tools --- src/common/const_array.hpp | 22 +++++----- src/common/core.hpp | 4 +- src/common/dumb_ptr.hpp | 18 ++++---- src/common/extract.hpp | 12 +++--- src/common/human_time_diff.hpp | 6 +-- src/common/intern-pool.hpp | 12 +++--- src/common/ip.hpp | 8 ++-- src/common/md5calc.cpp | 2 +- src/common/md5calc.hpp | 22 +++++----- src/common/mmo.hpp | 10 ++--- src/common/nullpo.hpp | 2 +- src/common/socket.cpp | 4 +- src/common/utils.hpp | 26 +++++------ src/common/utils2.hpp | 98 +++++++++++++++++++++--------------------- 14 files changed, 123 insertions(+), 123 deletions(-) (limited to 'src/common') diff --git a/src/common/const_array.hpp b/src/common/const_array.hpp index 383a4e2..fe15728 100644 --- a/src/common/const_array.hpp +++ b/src/common/const_array.hpp @@ -19,19 +19,19 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#include "../sanity.hpp" +# include "../sanity.hpp" -#include +# include -#include -#include -#include +# include +# include +# include -#ifdef WORKAROUND_GCC46_COMPILER +# ifdef WORKAROUND_GCC46_COMPILER // constexpr is buggy with templates in this version // Is this still needed now that const_string is removed? -# define constexpr /* nothing */ -#endif +# define constexpr /* nothing */ +# endif // TODO see if I ever actually use this, and not the subclass template @@ -125,8 +125,8 @@ public: } }; -#ifdef WORKAROUND_GCC46_COMPILER -# undef constexpr -#endif +# ifdef WORKAROUND_GCC46_COMPILER +# undef constexpr +# endif #endif // CONST_ARRAY_HPP diff --git a/src/common/core.hpp b/src/common/core.hpp index 11b04fd..f93f5a1 100644 --- a/src/common/core.hpp +++ b/src/common/core.hpp @@ -1,9 +1,9 @@ #ifndef CORE_HPP #define CORE_HPP -#include "../sanity.hpp" +# include "../sanity.hpp" -#include "../strings/fwd.hpp" +# include "../strings/fwd.hpp" /// core.c contains a server-independent main() function /// and then runs a do_sendrecv loop diff --git a/src/common/dumb_ptr.hpp b/src/common/dumb_ptr.hpp index 1dba39d..1ac237a 100644 --- a/src/common/dumb_ptr.hpp +++ b/src/common/dumb_ptr.hpp @@ -19,17 +19,17 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#include "../sanity.hpp" +# include "../sanity.hpp" -#include +# include -#include +# include -#include "../strings/fstring.hpp" -#include "../strings/zstring.hpp" -#include "../strings/xstring.hpp" +# include "../strings/fstring.hpp" +# include "../strings/zstring.hpp" +# include "../strings/xstring.hpp" -#include "const_array.hpp" +# include "const_array.hpp" // unmanaged new/delete-able pointer // should be replaced by std::unique_ptr @@ -210,9 +210,9 @@ struct dumb_string return dumb_string::copy(&*s.begin(), &*s.end()); } static -#ifndef __clang__ +# ifndef __clang__ __attribute__((warning("shouldn't use this - slice instead"))) -#endif +# endif dumb_string copyn(const char *sn, size_t n) { return dumb_string::copy(sn, sn + strnlen(sn, n)); diff --git a/src/common/extract.hpp b/src/common/extract.hpp index 4f90be4..e798204 100644 --- a/src/common/extract.hpp +++ b/src/common/extract.hpp @@ -19,15 +19,15 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#include "../sanity.hpp" +# include "../sanity.hpp" -#include +# include -#include "../strings/xstring.hpp" +# include "../strings/xstring.hpp" -#include "const_array.hpp" -#include "mmo.hpp" -#include "utils.hpp" +# include "const_array.hpp" +# include "mmo.hpp" +# include "utils.hpp" template::value && !std::is_same::value && !std::is_same::value>::type> bool extract(XString str, T *iv) diff --git a/src/common/human_time_diff.hpp b/src/common/human_time_diff.hpp index b8754b2..b8040b8 100644 --- a/src/common/human_time_diff.hpp +++ b/src/common/human_time_diff.hpp @@ -19,11 +19,11 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#include "../sanity.hpp" +# include "../sanity.hpp" -#include "../strings/xstring.hpp" +# include "../strings/xstring.hpp" -#include "extract.hpp" +# include "extract.hpp" struct HumanTimeDiff { diff --git a/src/common/intern-pool.hpp b/src/common/intern-pool.hpp index 204b659..163e5cc 100644 --- a/src/common/intern-pool.hpp +++ b/src/common/intern-pool.hpp @@ -1,14 +1,14 @@ #ifndef INTERN_POOL_HPP #define INTERN_POOL_HPP -#include +# include -#include -#include +# include +# include -#include "../strings/fstring.hpp" -#include "../strings/zstring.hpp" -#include "../strings/xstring.hpp" +# include "../strings/fstring.hpp" +# include "../strings/zstring.hpp" +# include "../strings/xstring.hpp" class InternPool { diff --git a/src/common/ip.hpp b/src/common/ip.hpp index 7e645bb..d6e6f04 100644 --- a/src/common/ip.hpp +++ b/src/common/ip.hpp @@ -19,13 +19,13 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#include "../sanity.hpp" +# include "../sanity.hpp" -#include +# include -#include "../strings/fwd.hpp" +# include "../strings/fwd.hpp" -#include "extract.hpp" +# include "extract.hpp" // TODO - in the long run ports belong here also // and of course, IPv6 stuff. diff --git a/src/common/md5calc.cpp b/src/common/md5calc.cpp index 8d650fa..d23f8e3 100644 --- a/src/common/md5calc.cpp +++ b/src/common/md5calc.cpp @@ -16,7 +16,7 @@ // auxilary data /* sin() constant table -# Reformatted output of: +#Reformatted output of: echo 'scale=40; obase=16; for (i=1;i<=64;i++) print 2^32 * sin(i), "\n"' | bc | sed 's/^-//;s/^/0x/;s/\..*$/,/' */ diff --git a/src/common/md5calc.hpp b/src/common/md5calc.hpp index 479c1a9..45bec84 100644 --- a/src/common/md5calc.hpp +++ b/src/common/md5calc.hpp @@ -1,23 +1,23 @@ #ifndef MD5CALC_HPP #define MD5CALC_HPP -#include "../sanity.hpp" +# include "../sanity.hpp" -#include +# include -#include -#include -#include +# include +# include +# include -#include +# include -#include "../strings/fwd.hpp" -#include "../strings/vstring.hpp" +# include "../strings/fwd.hpp" +# include "../strings/vstring.hpp" -#include "../io/fwd.hpp" +# include "../io/fwd.hpp" -#include "ip.hpp" -#include "mmo.hpp" +# include "ip.hpp" +# include "mmo.hpp" /// The digest state - becomes the output struct MD5_state diff --git a/src/common/mmo.hpp b/src/common/mmo.hpp index 0f89c81..178bb08 100644 --- a/src/common/mmo.hpp +++ b/src/common/mmo.hpp @@ -57,7 +57,7 @@ T stringish(VString iv) static_cast&>(rv) = iv; return rv; } -#define DEFAULT_EMAIL stringish("a@a.com") +# define DEFAULT_EMAIL stringish("a@a.com") // It is decreed: a mapname shall not contain an extension class MapName : public strings::_crtp_string @@ -111,12 +111,12 @@ public: } VString<23> to__canonical() const { -#if NAME_IGNORING_CASE == 0 +# if NAME_IGNORING_CASE == 0 return to__actual(); -#endif -#if NAME_IGNORING_CASE == 1 +# endif +# if NAME_IGNORING_CASE == 1 return to__lower(); -#endif +# endif } friend bool operator == (const CharName& l, const CharName& r) diff --git a/src/common/nullpo.hpp b/src/common/nullpo.hpp index 26aab20..0eaa1b2 100644 --- a/src/common/nullpo.hpp +++ b/src/common/nullpo.hpp @@ -11,7 +11,7 @@ /// nullpo_retr(rv, cond) - return given value instead # ifndef BUG_FREE -# define nullpo_retr(ret, t) \ +# define nullpo_retr(ret, t) \ if (nullpo_chk(__FILE__, __LINE__, __PRETTY_FUNCTION__, t)) \ return ret; # else // BUG_FREE diff --git a/src/common/socket.cpp b/src/common/socket.cpp index b507cd8..61552c7 100644 --- a/src/common/socket.cpp +++ b/src/common/socket.cpp @@ -208,7 +208,7 @@ int make_listen_port(uint16_t port) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wold-style-cast" #if __GNUC__ > 4 || __GNUC_MINOR__ >= 8 -#pragma GCC diagnostic ignored "-Wuseless-cast" +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif server_address.sin_addr.s_addr = htonl(INADDR_ANY); server_address.sin_port = htons(port); @@ -268,7 +268,7 @@ int make_connection(IP4Address ip, uint16_t port) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wold-style-cast" #if __GNUC__ > 4 || __GNUC_MINOR__ >= 8 -#pragma GCC diagnostic ignored "-Wuseless-cast" +# pragma GCC diagnostic ignored "-Wuseless-cast" #endif server_address.sin_port = htons(port); #pragma GCC diagnostic pop diff --git a/src/common/utils.hpp b/src/common/utils.hpp index 2d2e2d5..f975e34 100644 --- a/src/common/utils.hpp +++ b/src/common/utils.hpp @@ -1,21 +1,21 @@ #ifndef UTILS_HPP #define UTILS_HPP -#include "../sanity.hpp" +# include "../sanity.hpp" -#include -#include +# include +# include -#include +# include -#include "../strings/fwd.hpp" -#include "../strings/vstring.hpp" +# include "../strings/fwd.hpp" +# include "../strings/vstring.hpp" -#include "../io/fwd.hpp" +# include "../io/fwd.hpp" -#include "const_array.hpp" -#include "operators.hpp" -#include "utils2.hpp" +# include "const_array.hpp" +# include "operators.hpp" +# include "utils2.hpp" template struct is_trivially_copyable @@ -122,16 +122,16 @@ void stamp_time(timestamp_milliseconds_buffer&); void log_with_timestamp(io::WriteFile& out, XString line); // TODO VString? -#define TIMESTAMP_DUMMY "YYYY-MM-DD HH:MM:SS" +# define TIMESTAMP_DUMMY "YYYY-MM-DD HH:MM:SS" static_assert(sizeof(TIMESTAMP_DUMMY) == sizeof(timestamp_seconds_buffer), "timestamp size"); -#define WITH_TIMESTAMP(str) str TIMESTAMP_DUMMY +# define WITH_TIMESTAMP(str) str TIMESTAMP_DUMMY // str: prefix: YYYY-MM-DD HH:MM:SS // sizeof: 01234567890123456789012345678 // str + sizeof: ^ // -1: ^ // there's probably a better way to do this now -#define REPLACE_TIMESTAMP(str, t) \ +# define REPLACE_TIMESTAMP(str, t) \ stamp_time( \ reinterpret_cast( \ str + sizeof(str) \ diff --git a/src/common/utils2.hpp b/src/common/utils2.hpp index 7dbd741..0f72aff 100644 --- a/src/common/utils2.hpp +++ b/src/common/utils2.hpp @@ -1,19 +1,19 @@ #ifndef UTILS2_HPP #define UTILS2_HPP -#include "../sanity.hpp" +# include "../sanity.hpp" -#include -#include -#include -#include -#include +# include +# include +# include +# include +# include -#ifdef __clang__ -# define FALLTHROUGH [[clang::fallthrough]] -#else -# define FALLTHROUGH /* fallthrough */ -#endif +# ifdef __clang__ +# define FALLTHROUGH [[clang::fallthrough]] +# else +# define FALLTHROUGH /* fallthrough */ +# endif template struct earray @@ -136,44 +136,44 @@ struct remove_enum }; -#define ENUM_BITWISE_OPERATORS(E) \ -inline \ -E operator & (E l, E r) \ -{ \ - typedef underlying_type::type U; \ - return E(U(l) & U(r)); \ -} \ -inline \ -E operator | (E l, E r) \ -{ \ - typedef underlying_type::type U; \ - return E(U(l) | U(r)); \ -} \ -inline \ -E operator ^ (E l, E r) \ -{ \ - typedef underlying_type::type U; \ - return E(U(l) ^ U(r)); \ -} \ -inline \ -E& operator &= (E& l, E r) \ -{ \ - return l = l & r; \ -} \ -inline \ -E& operator |= (E& l, E r) \ -{ \ - return l = l | r; \ -} \ -inline \ -E& operator ^= (E& l, E r) \ -{ \ - return l = l ^ r; \ -} \ -inline \ -E operator ~ (E r) \ -{ \ - return E(-1) ^ r; \ +# define ENUM_BITWISE_OPERATORS(E) \ +inline \ +E operator & (E l, E r) \ +{ \ + typedef underlying_type::type U; \ + return E(U(l) & U(r)); \ +} \ +inline \ +E operator | (E l, E r) \ +{ \ + typedef underlying_type::type U; \ + return E(U(l) | U(r)); \ +} \ +inline \ +E operator ^ (E l, E r) \ +{ \ + typedef underlying_type::type U; \ + return E(U(l) ^ U(r)); \ +} \ +inline \ +E& operator &= (E& l, E r) \ +{ \ + return l = l & r; \ +} \ +inline \ +E& operator |= (E& l, E r) \ +{ \ + return l = l | r; \ +} \ +inline \ +E& operator ^= (E& l, E r) \ +{ \ + return l = l ^ r; \ +} \ +inline \ +E operator ~ (E r) \ +{ \ + return E(-1) ^ r; \ } template -- cgit v1.2.3-70-g09d2