aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/Examples/PakReader.c1
-rw-r--r--include/BH/Common.h1
-rw-r--r--include/BH/Hashmap.h1
-rw-r--r--include/BH/Thread.h1
-rw-r--r--include/BH/Util.h4
-rw-r--r--src/Hashmap.c1
-rw-r--r--src/IO.c2
-rw-r--r--src/Math/Ray2f.c1
-rw-r--r--src/Util.c4
-rw-r--r--test/src/TestArgs.c1
-rw-r--r--test/src/TestHashmap.c6
-rw-r--r--unit/src/Unit.c2
-rwxr-xr-xutil/style.sh77
-rwxr-xr-xutil/tests.sh (renamed from util/run-tests.sh)0
-rwxr-xr-xutil/whitespace.sh (renamed from util/trim-whitespace.sh)0
15 files changed, 91 insertions, 11 deletions
diff --git a/doc/Examples/PakReader.c b/doc/Examples/PakReader.c
index 671903a..e350b67 100644
--- a/doc/Examples/PakReader.c
+++ b/doc/Examples/PakReader.c
@@ -10,6 +10,7 @@
#define HEADER_SIZE 12
#define ENTRY_SIZE 64
+
typedef struct PakHeader
{
char id[4];
diff --git a/include/BH/Common.h b/include/BH/Common.h
index 1467b25..78fd503 100644
--- a/include/BH/Common.h
+++ b/include/BH/Common.h
@@ -23,4 +23,3 @@ typedef size_t (*BH_HashCallback)(const void *);
typedef void (*BH_GenericCallback)(void *);
#endif /* BH_COMMON_H */
-
diff --git a/include/BH/Hashmap.h b/include/BH/Hashmap.h
index 57d04fc..7dda9ec 100644
--- a/include/BH/Hashmap.h
+++ b/include/BH/Hashmap.h
@@ -221,4 +221,3 @@ void *BH_HashmapIterValue(void *iter);
#endif /* BH_HASHMAP_H */
-
diff --git a/include/BH/Thread.h b/include/BH/Thread.h
index 794abc5..b31b8ef 100644
--- a/include/BH/Thread.h
+++ b/include/BH/Thread.h
@@ -248,7 +248,6 @@ int BH_ConditionBroadcast(BH_Condition *condition);
void BH_SpinlockLock(int *lock);
-
/**
* Tries to lock the \a spinlock.
*
diff --git a/include/BH/Util.h b/include/BH/Util.h
index 1b1c53f..d88e47a 100644
--- a/include/BH/Util.h
+++ b/include/BH/Util.h
@@ -105,7 +105,6 @@ uint32_t BH_Read32BEu(const char *buffer);
int32_t BH_Read32BEs(const char *buffer);
-
/**
* Reads 64-bit unsigned integer from the \a buffer in big-endian format.
*
@@ -136,7 +135,6 @@ void BH_Write16LEu(char *buffer,
uint16_t value);
-
/**
* Writes 16-bit signed integer to the \a buffer in little-endian format.
*
@@ -177,7 +175,6 @@ void BH_Write64LEu(char *buffer,
uint64_t value);
-
/**
* Writes 64-bit signed integer to the \a buffer in little-endian format.
*
@@ -208,7 +205,6 @@ void BH_Write16BEs(char *buffer,
int16_t value);
-
/**
* Writes 32-bit unsigned integer to the \a buffer in big-endian format.
*
diff --git a/src/Hashmap.c b/src/Hashmap.c
index ad8e7bd..8253ec6 100644
--- a/src/Hashmap.c
+++ b/src/Hashmap.c
@@ -387,4 +387,3 @@ void *BH_HashmapIterValue(void *iter)
{
return ((BH_HashmapNode *)iter)->value;
}
-
diff --git a/src/IO.c b/src/IO.c
index c8516da..2b2b302 100644
--- a/src/IO.c
+++ b/src/IO.c
@@ -135,6 +135,7 @@ int BH_IOWrite(BH_IO *io,
return code;
}
+
int BH_IOPeek(BH_IO *io,
char *buffer,
size_t size,
@@ -227,7 +228,6 @@ int BH_IOClear(BH_IO *io)
}
-
BH_IO *BH_BufferNew(BH_IO *io)
{
(void)io;
diff --git a/src/Math/Ray2f.c b/src/Math/Ray2f.c
index ea2572b..7e217ea 100644
--- a/src/Math/Ray2f.c
+++ b/src/Math/Ray2f.c
@@ -155,6 +155,7 @@ int BH_Segment2fIntersectSegment(const float *aStart,
return BH_OK;
}
+
int BH_Ray2fIntersectBox2f(const float *aStart,
const float *aDirection,
const float *bMin,
diff --git a/src/Util.c b/src/Util.c
index 110f1ae..b388fed 100644
--- a/src/Util.c
+++ b/src/Util.c
@@ -110,6 +110,7 @@ int16_t BH_Read16BEs(const char *buffer)
return tmp.s;
}
+
uint32_t BH_Read32BEu(const char *buffer)
{
union I32 tmp;
@@ -120,6 +121,7 @@ uint32_t BH_Read32BEu(const char *buffer)
return tmp.u;
}
+
int32_t BH_Read32BEs(const char *buffer)
{
union I32 tmp;
@@ -130,6 +132,7 @@ int32_t BH_Read32BEs(const char *buffer)
return tmp.s;
}
+
uint64_t BH_Read64BEu(const char *buffer)
{
union I64 tmp;
@@ -144,6 +147,7 @@ uint64_t BH_Read64BEu(const char *buffer)
return tmp.u;
}
+
int64_t BH_Read64BEs(const char *buffer)
{
union I64 tmp;
diff --git a/test/src/TestArgs.c b/test/src/TestArgs.c
index 940a9c6..0175dd9 100644
--- a/test/src/TestArgs.c
+++ b/test/src/TestArgs.c
@@ -401,7 +401,6 @@ BH_UNIT_TEST(Aesthetics)
}
-
int main(int argc, char **argv)
{
(void)argc;
diff --git a/test/src/TestHashmap.c b/test/src/TestHashmap.c
index da73e4b..233a279 100644
--- a/test/src/TestHashmap.c
+++ b/test/src/TestHashmap.c
@@ -31,6 +31,7 @@ static int NewFree(void)
return 0;
}
+
static int GrowShrink(void)
{
BH_Hashmap *hashmap;
@@ -102,6 +103,7 @@ static int GrowShrink(void)
return 0;
}
+
static int InsertRemove(void)
{
BH_Hashmap *hashmap;
@@ -138,6 +140,7 @@ static int InsertRemove(void)
return 0;
}
+
static int Lookup(void)
{
BH_Hashmap *hashmap;
@@ -173,6 +176,7 @@ static int Lookup(void)
return 0;
}
+
static int Clear(void)
{
BH_Hashmap *hashmap;
@@ -195,6 +199,7 @@ static int Clear(void)
return 0;
}
+
static int Fields(void)
{
BH_Hashmap *hashmap;
@@ -217,6 +222,7 @@ static int Fields(void)
return 0;
}
+
int main(int argc, char **argv)
{
(void)argc;
diff --git a/unit/src/Unit.c b/unit/src/Unit.c
index a0b61e1..654839d 100644
--- a/unit/src/Unit.c
+++ b/unit/src/Unit.c
@@ -1,6 +1,7 @@
#include <BH/Unit.h>
#include <stdlib.h>
+
typedef struct BH_Unit
{
struct BH_Unit *next;
@@ -77,4 +78,3 @@ int BH_UnitRun(void)
BH_UnitCleanup();
return result;
}
-
diff --git a/util/style.sh b/util/style.sh
new file mode 100755
index 0000000..c892f7d
--- /dev/null
+++ b/util/style.sh
@@ -0,0 +1,77 @@
+#!/bin/sh
+
+
+# Check args
+if [ $# -lt 1 ]; then
+ echo "error: specify file"
+ exit 1
+fi
+
+if [ ! -f $1 ]; then
+ echo "error: file '$1' not found"
+ exit 1
+fi
+
+
+# Message about trailing space before EOL
+eolerrors=$(grep -n "\s$" "$1" | cut -f1 -d: | while read -r line; do
+ if [ "$line" ]; then
+ echo "$1:$line: error: whitepace before EOL"
+ fi
+done)
+
+
+# Message about non-empty last-line
+linecount=$(($(wc -l "$1" | cut -f1 -d " ") + 1))
+lastline=$(tail -n "+$linecount" $1)
+
+llerrors=$(if [ "$lastline" ]; then
+ echo "$1:$linecount: error: no EOL before EOF"
+fi)
+
+
+# Compute ranges of new lines
+count=0; start=0; next=0
+lines="$(grep -n "^$" "$1" | cut -f1 -d:)
+0"
+ranges=$(echo "$lines" | while read -r line; do
+ if [ "$line" ]; then
+ if [ $start -eq 0 ]; then
+ start="$line"; count=1; next=$(($start + 1))
+ elif [ "$line" -ne $next ]; then
+ echo $start $count
+ start="$line"; count=1; next=$(($start + 1))
+ else
+ count=$(($count + 1)); next=$(($next + 1))
+ fi
+ fi
+done)
+
+
+# Check that we have no more then 3 EOLs in the row
+fewerrors=$(echo "$ranges" | while read -r line; do
+ number=$(echo $line | cut -f1 -d " ")
+ size=$(echo $line | cut -f2 -d " ")
+ if [ $size -gt 2 ]; then
+ echo "$1:$number: error: too many EOLs"
+ fi
+done)
+
+# Print out errors
+code=0
+if [ "$eolerrors" ]; then
+ echo "$eolerrors" 1>&2
+ code=1
+fi
+
+if [ "$llerrors" ]; then
+ echo "$llerrors" 1>&2
+ code=1
+fi
+
+if [ "$fewerrors" ]; then
+ echo "$fewerrors" 1>&2
+ code=1
+fi
+
+exit $code
diff --git a/util/run-tests.sh b/util/tests.sh
index 1ee2183..1ee2183 100755
--- a/util/run-tests.sh
+++ b/util/tests.sh
diff --git a/util/trim-whitespace.sh b/util/whitespace.sh
index f661aa3..f661aa3 100755
--- a/util/trim-whitespace.sh
+++ b/util/whitespace.sh