Skip to content

Commit

Permalink
header cleanup with Eric S. Raymond's deheader
Browse files Browse the repository at this point in the history
  • Loading branch information
velnias75 committed May 21, 2015
1 parent 538f859 commit e91e460
Show file tree
Hide file tree
Showing 34 changed files with 113 additions and 86 deletions.
21 changes: 11 additions & 10 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ AC_ARG_ENABLE([ai-image], [AS_HELP_STRING([--enable-ai-image], [path to image of
[ AM_CONDITIONAL([BRANDING], [ test x$enable_ai_image != xno ]) ],
[ AM_CONDITIONAL([BRANDING], [ false ]) ])

AC_ARG_ENABLE([ai-tracing], [AS_HELP_STRING([--enable-ai-tracing],
[enables tracing of AI decisions (useful for developers only, needs NDEBUG undefined)])],
AC_ARG_ENABLE([ai-tracing], [AS_HELP_STRING([--enable-ai-tracing],
[enables tracing of AI decisions (useful for developers only, needs NDEBUG undefined)])],
[ if test x$enable_ai_tracing = xyes; then
AC_DEFINE([TRACE_AI], [1], [Define to 1 to enable tracing of AI decisions])
fi
Expand Down Expand Up @@ -92,7 +92,7 @@ fi

if test -z "$ac_cv_prog_CPPCHECK"; then
AM_CONDITIONAL([CHECKCPP], [ false ])
else
else
AM_CONDITIONAL([CHECKCPP], [ true ])
fi

Expand All @@ -111,7 +111,7 @@ PKG_CHECK_MODULES([POPT], [popt >= 1.10])
AC_CHECK_LIB([magic], [magic_open])
AC_CHECK_LIB([rt], [timer_create])
PKG_CHECK_MODULES([GSL], [gsl >= 1.9],
[ AM_CONDITIONAL([GSL], [ true ])
[ AM_CONDITIONAL([GSL], [ true ])
echo "[[ENVIRONMENT]]
.TP
\fBGSL_RNG_TYPE\fR
Expand All @@ -122,15 +122,16 @@ the desired seed value
.PP
See the
.mso www.tmac
.URL \"http://www.gnu.org/software/gsl/manual/html_node/Random-number-environment-variables.html\" \"GSL Manual\" \" for more information\"" > gsl.h2m ],
.URL \"http://www.gnu.org/software/gsl/manual/html_node/Random-number-environment-variables.html\" \"GSL Manual\" \" for more information\"" > gsl.h2m ],
[ AM_CONDITIONAL([GSL], [ false ])] )
PKG_CHECK_MODULES([LIBSQLITE], [sqlite3 >= 3.4.2])
PKG_CHECK_MODULES([LIBLUA], [lua5.1 >= 5.1.2], [ AC_SUBST([PKGC_LUA], [lua5.1]) ],
PKG_CHECK_MODULES([LIBLUA], [lua5.1 >= 5.1.2], [ AC_SUBST([PKGC_LUA], [lua5.1]) ],
[ PKG_CHECK_MODULES([LIBLUA], [lua51 >= 5.1.2], [ AC_SUBST([PKGC_LUA], [lua51]) ],
[ PKG_CHECK_MODULES([LIBLUA], [lua >= 5.1.2 lua < 5.2], [AC_SUBST([PKGC_LUA], [lua])] ) ] ) ])

# Checks for header files.
AC_HEADER_STDBOOL
AC_CHECK_HEADERS([sys/wait.h])
AC_CHECK_HEADERS([sys/time.h])
AC_CHECK_HEADERS([magic.h])
AC_CHECK_HEADERS([poll.h])
Expand Down Expand Up @@ -164,8 +165,8 @@ AC_CHECK_FUNCS([socket])
AC_CHECK_FUNCS([select])
AC_CHECK_FUNCS([atexit])
AC_CHECK_FUNCS([strerror])
AC_CHECK_FUNC([arc4random_uniform],
[ AC_DEFINE([HAVE_ARC4RANDOM_UNIFORM], [1], [we have arc4random_uniform])
AC_CHECK_FUNC([arc4random_uniform],
[ AC_DEFINE([HAVE_ARC4RANDOM_UNIFORM], [1], [we have arc4random_uniform])
])
AC_FUNC_ERROR_AT_LINE
AC_FUNC_CHOWN
Expand Down Expand Up @@ -193,7 +194,7 @@ CFLAGS="${CFLAGS} -std=gnu99 -fvisibility-inlines-hidden"
CXXFLAGS="${CXXFLAGS} -std=gnu++98 -fvisibility=${VISIBILITY} -fvisibility-inlines-hidden -fstrict-aliasing"
CPPFLAGS="${CPPFLAGS} -DBASICLOGGER_NO_PTHREADS -D_GLIBCXX_VISIBILITY=0"
NO_EXCEPTIONS="-fno-exceptions" ;

if test x$CLANG = xyes; then CXXFLAGS="-fexceptions -frtti ${CXXFLAGS}" ; fi

AC_SUBST([LDFLAGS])
Expand All @@ -209,5 +210,5 @@ AC_CONFIG_FILES([src/server/netmaumau.rc doc/client.dox netmaumau.h2m])
AC_MSG_RESULT([You may want to install a client too: https://github.com/velnias75/NetMauMau-Qt-Client])

AC_OUTPUT([Makefile doc/Makefile src/Makefile src/ai/Makefile src/client/Makefile
src/common/Makefile src/engine/Makefile src/images/Makefile src/include/Makefile
src/common/Makefile src/engine/Makefile src/images/Makefile src/include/Makefile
src/lua/Makefile src/server/Makefile src/sqlite/Makefile src/test/Makefile])
5 changes: 1 addition & 4 deletions src/ai/abstractaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@

#include "abstractaction.h"

#include <cstddef> // for size_t
#include <cstring> // for memset
#include <functional> // for binder2nd, etc
#include <iterator> // for distance

#include "cardtools.h" // for findSuit, isRank, isSuit

Expand Down Expand Up @@ -69,7 +66,7 @@ AbstractAction::~AbstractAction() {}
const IConditionPtr &AbstractAction::operator()(IAIState &state) const {
#if defined(TRACE_AI) && !defined(NDEBUG)

if(!getenv("NMM_NO_TRACE")) logDebug("-> " << traceLog());
if(!std::getenv("NMM_NO_TRACE")) logDebug("-> " << traceLog());

#endif

Expand Down
2 changes: 1 addition & 1 deletion src/ai/abstractcondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ IActionPtr AbstractCondition::operator()(const IAIState &state) const {

#if defined(TRACE_AI) && !defined(NDEBUG)

if(!getenv("NMM_NO_TRACE")) logDebug(" * " << traceLog());
if(!std::getenv("NMM_NO_TRACE")) logDebug(" * " << traceLog());

#endif

Expand Down
1 change: 1 addition & 0 deletions src/ai/checkjacksuitaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <algorithm> // for find_if
#include <cassert> // for assert
#include <stdbool.h>

#include "random_gen.h" // for genRandom
#include "stdcardfactory.h" // for StdCardFactory
Expand Down
2 changes: 1 addition & 1 deletion src/ai/decisionbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

#include "decisionbase.h"
#include <functional> // for pointer_to_binary_function, etc

#include "cardtools.h" // for isRank, isSuit

namespace {
Expand Down
2 changes: 0 additions & 2 deletions src/ai/havejackcondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

#include "havejackcondition.h"

#include <iterator>

#include "bestjackaction.h" // for BestJackAction
#include "cardtools.h" // for findRank
#include "havelessthancondition.h" // for HaveLessThanCondition
Expand Down
1 change: 0 additions & 1 deletion src/ai/jacksuitaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "jacksuitaction.h"

#include <cassert> // for assert
#include <functional> // for pointer_to_binary_function, etc

#include "bestjackaction.h" // for BestJackAction
#include "cardtools.h" // for isRank
Expand Down
4 changes: 2 additions & 2 deletions src/ai/maxsuitaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/

#include "maxsuitaction.h"

#include <cassert> // for assert
#include <cstddef> // for size_t
#include <functional>

#include "aceroundcondition.h" // for AceRoundCondition
#include "cardtools.h" // for findRank, findSuit
#include "iruleset.h" // for IRuleSet
Expand Down
1 change: 0 additions & 1 deletion src/ai/powerplayaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "powerplayaction.h"

#include <cassert> // for assert
#include <iterator> // for distance

#include "aceroundcondition.h" // for AceRoundCondition
#include "cardtools.h" // for findSuit
Expand Down
2 changes: 0 additions & 2 deletions src/ai/randomjackaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

#include "randomjackaction.h"

#include <iterator> // for reverse_iterator

#include "cardtools.h" // for findSuit
#include "random_gen.h" // for genRandom

Expand Down
7 changes: 5 additions & 2 deletions src/client/abstractclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@

#include <cassert> // for assert
#include <cstdio> // for NULL, snprintf
#include <functional> // for pointer_to_binary_function, etc
#include <iterator> // for back_insert_iterator, etc
#include <stdbool.h>

#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif

#include "abstractclientv05impl.h" // for AbstractClientV05Impl
#include "logger.h" // for BasicLogger, logDebug
Expand Down
3 changes: 0 additions & 3 deletions src/client/abstractclientv05impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@

#include <algorithm> // for find_if
#include <cstring> // for memcpy
#include <functional> // for binder2nd, bind2nd, etc
#include <iterator> // for advance
#include <new> // for nothrow, operator new[]

#if defined(_WIN32)
#undef TRUE
Expand Down
10 changes: 6 additions & 4 deletions src/client/clientconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@

#include <cstdlib> // for NULL, strtoll, strtoul
#include <cstring> // for strncmp, memcpy
#include <new> // for nothrow, operator new[]
#include <sstream> // for operator<<, ostringstream, etc
#include <utility> // for make_pair, pair

#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif

#include "abstractclient.h" // for AbstractClient
#include "base64bridge.h" // for Base64Bridge
Expand Down Expand Up @@ -268,9 +270,9 @@ throw(NetMauMau::Common::Exception::SocketException) {
char name[4] = { 0 };
recv(name, 4, getSocketFD());

if(!strncmp(name, "NAME", 4)) {
if(!std::strncmp(name, "NAME", 4)) {
send(_pimpl->m_pName.c_str(), _pimpl->m_pName.length(), getSocketFD());
} else if(!strncmp(name, "NAMP", 4)) {
} else if(!std::strncmp(name, "NAMP", 4)) {

if(!(data && len)) {
send(_pimpl->m_pName.c_str(), _pimpl->m_pName.length(), getSocketFD());
Expand Down
6 changes: 4 additions & 2 deletions src/client/clientconnectionimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@

#include "clientconnectionimpl.h"

#include <cstddef> // for NULL

#ifndef _WIN32
#include <sys/select.h> // for select, FD_SET, FD_ZERO, etc
#endif

#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

#include <sys/time.h> // for timeval
#include <cerrno> // for errno, EINTR

Expand Down
3 changes: 0 additions & 3 deletions src/common/abstractconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
#include "config.h" // for HAVE_UNISTD_H, PACKAGE_NAME
#endif

#include <stdlib.h> // for strtoul

#ifndef _WIN32
#include <sys/select.h> // for select, FD_SET, FD_ZERO, etc
#endif
Expand All @@ -36,7 +34,6 @@
#include <algorithm> // for find_if, find, for_each
#include <cerrno> // for errno
#include <cstring> // for NULL, strlen
#include <functional> // for binder2nd, bind2nd, etc

#include "abstractconnectionimpl.h" // for AbstractConnectionImpl
#include "errorstring.h" // for errorString
Expand Down
10 changes: 7 additions & 3 deletions src/common/abstractsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,21 @@
#include <sys/select.h> // for FD_ISSET, FD_SET, select, etc
#endif

#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif

#include <sys/time.h>

#ifdef HAVE_UNISTD_H
#include <unistd.h> // for close, socklen_t, ssize_t
#endif

#include <algorithm> // for max
#include <cerrno> // for errno, ENOMEM
#include <cstddef> // for size_t
#include <cstdio> // for NULL, fileno, snprintf, etc
#include <cstring> // for memset
#include <new> // for bad_alloc
#include <vector> // for vector
#include <stdbool.h>

#include "abstractsocket.h" // for AbstractSocket
#include "abstractsocketimpl.h" // for AbstractSocketImpl
Expand Down
3 changes: 0 additions & 3 deletions src/common/base64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@

#include "base64.h"

#include <ctype.h> // for isalnum
#include <new> // for bad_alloc

#include "logger.h" // for logDebug

static const std::string base64_chars =
Expand Down
4 changes: 4 additions & 0 deletions src/common/cardtools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
* along with NetMauMau. If not, see <http://www.gnu.org/licenses/>.
*/

#if defined(HAVE_CONFIG_H) || defined(IN_IDE_PARSER)
#include "config.h"
#endif

#include "cardtools.h" // IWYU pragma: keep

#include <ctype.h> // for isdigit
Expand Down
1 change: 1 addition & 0 deletions src/common/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "logger.h"
#include <iostream> // for ostreambuf_iterator, cerr
#include <stdbool.h>

#ifdef HAVE_SYSLOG_H
#undef LOG_DEBUG
Expand Down
2 changes: 1 addition & 1 deletion src/engine/abstractplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

#include "abstractplayer.h"

#include <functional> // for pointer_to_binary_function, etc
#include <numeric> // for accumulate
#include <stdbool.h>

#include "cardtools.h" // for cardEqual, isRank
#include "icardcountobserver.h" // for ICardCountObserver
Expand Down
12 changes: 6 additions & 6 deletions src/engine/easyplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
#include "config.h" // IWYU pragma: keep
#endif

#include "easyplayer.h"
#include <ctime>

#include <ctime> // for time
#include "easyplayer.h"

#include "cardtools.h" // for findCard, getIllegalCard, etc
#include "cardtools.h"
#include "random_gen.h" // for genRandom

using namespace NetMauMau::Player;
Expand Down Expand Up @@ -66,9 +66,9 @@ EasyPlayer::requestCard(const NetMauMau::Common::ICardPtr &uncoveredCard,

const bool ansi = isatty(fileno(stderr));

if(!getenv("NMM_NO_TRACE")) logDebug("-> trace of AI \"" << getName() << "\" -> "
<< (rrc ? rrc->description(ansi) : "NO CARD")
<< " <-");
if(!std::getenv("NMM_NO_TRACE")) logDebug("-> trace of AI \"" << getName() << "\" -> "
<< (rrc ? rrc->description(ansi) : "NO CARD")
<< " <-");

#endif

Expand Down
14 changes: 8 additions & 6 deletions src/engine/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

#if defined(HAVE_CONFIG_H) || defined(IN_IDE_PARSER)
#include "config.h" // for HAVE_SYS_SOCKET_H, etc
#include "config.h" // for HAVE_SYS_SOCKET_H, etc
#endif

#ifdef _WIN32
Expand All @@ -27,23 +27,25 @@
#define SHUT_RDWR SD_BOTH
#endif
#elif defined(HAVE_SYS_SOCKET_H)
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/socket.h> // for shutdown, SHUT_RDWR
#endif

#if defined(HAVE_GSL)
#include <random_gen.h> // for GSLRNG
#endif

#include <ctype.h> // for tolower

#ifdef HAVE_UNISTD_H
#include <unistd.h> // for close
#endif

#include <cassert> // for assert
#include <functional> // for binder2nd, mem_fun1_t, etc
#include <iterator> // for advance, distance
#include <ostream> // for size_t, operator<<, etc
#include <stdbool.h>

#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif

#include "logger.h" // for logDebug, BasicLogger
#include "cardtools.h" // for getIllegalCard
Expand Down
2 changes: 1 addition & 1 deletion src/engine/talon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include <algorithm> // for random_shuffle, for_each
#include <cassert> // for assert
#include <functional> // for unary_function, etc
#include <stdbool.h>

#include "italonchange.h" // for ITalonChange
#include "random_gen.h" // for genRandom
Expand Down
1 change: 0 additions & 1 deletion src/lua/luaruleset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "luaruleset.h"

#include <algorithm> // for max, copy, for_each
#include <functional> // for unary_function, etc
#include <iterator> // for ostream_iterator
#include <limits> // for numeric_limits

Expand Down
Loading

0 comments on commit e91e460

Please sign in to comment.