Fix styling issues, rename scripts
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#define HEADER_SIZE 12
|
||||
#define ENTRY_SIZE 64
|
||||
|
||||
|
||||
typedef struct PakHeader
|
||||
{
|
||||
char id[4];
|
||||
|
||||
@@ -23,4 +23,3 @@ typedef size_t (*BH_HashCallback)(const void *);
|
||||
typedef void (*BH_GenericCallback)(void *);
|
||||
|
||||
#endif /* BH_COMMON_H */
|
||||
|
||||
|
||||
@@ -221,4 +221,3 @@ void *BH_HashmapIterValue(void *iter);
|
||||
|
||||
|
||||
#endif /* BH_HASHMAP_H */
|
||||
|
||||
|
||||
@@ -248,7 +248,6 @@ int BH_ConditionBroadcast(BH_Condition *condition);
|
||||
void BH_SpinlockLock(int *lock);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Tries to lock the \a spinlock.
|
||||
*
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -387,4 +387,3 @@ void *BH_HashmapIterValue(void *iter)
|
||||
{
|
||||
return ((BH_HashmapNode *)iter)->value;
|
||||
}
|
||||
|
||||
|
||||
2
src/IO.c
2
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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -401,7 +401,6 @@ BH_UNIT_TEST(Aesthetics)
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
77
util/style.sh
Executable file
77
util/style.sh
Executable file
@@ -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
|
||||
Reference in New Issue
Block a user