Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code formatting infrastructure #397

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
BasedOnStyle: Microsoft
AccessModifierOffset: -2
BreakBeforeBraces: Allman
ColumnLimit: 100
IndentWidth: 2
Language: Cpp
Standard: Cpp11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't Standard be Cpp14?

TabWidth: 2
UseTab: Always

...
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ indent_size = 2
# C++ source
[*.c,*.cpp,*.h]
indent_style = tab
indent_size = 2
indent_size = tab
tab_width = 2
14 changes: 14 additions & 0 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: clang-format

on: [pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: DoozyX/[email protected]
with:
source: './src'
extensions: 'h,cpp,hpp'
clangFormatVersion: 9
54 changes: 27 additions & 27 deletions src/BinIO.cpp
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
#include <cstdio>
#include "BinIO.h"
#include <cstdio>

size_t fwrite_big(void *buffer,size_t size,size_t count, FILE *stream)
size_t fwrite_big(void *buffer, size_t size, size_t count, FILE *stream)
{
const unsigned long long mx=0x80000000;
unsigned long long j,n,st;
size_t ret=0;
const unsigned long long mx = 0x80000000;
unsigned long long j, n, st;
size_t ret = 0;
char *buf2;

st=mx/((unsigned long long) size);
n=count/st;
for(j=0;j<n;j++)
{
buf2=((char *)buffer)+j*st*size;
ret+=(fwrite(buf2,size,(size_t) st,stream));
}
buf2=((char *)buffer)+n*st*size;
ret+=(fwrite(buf2,size,(size_t) (count-n*st),stream));
st = mx / ((unsigned long long)size);
n = count / st;
for (j = 0; j < n; j++)
{
buf2 = ((char *)buffer) + j * st * size;
ret += (fwrite(buf2, size, (size_t)st, stream));
}
buf2 = ((char *)buffer) + n * st * size;
ret += (fwrite(buf2, size, (size_t)(count - n * st), stream));
return ret;
}

size_t fread_big(void *buffer,size_t size,size_t count, FILE *stream)
size_t fread_big(void *buffer, size_t size, size_t count, FILE *stream)
{
const unsigned long long mx=0x80000000;
unsigned long long j,n,st;
size_t ret=0;
const unsigned long long mx = 0x80000000;
unsigned long long j, n, st;
size_t ret = 0;
char *buf2;

st=mx/((unsigned long long) size);
n=count/st;
for(j=0;j<n;j++)
{
buf2=((char *)buffer)+j*st*size;
ret+=(fread(buf2,size,(size_t) st,stream));
}
buf2=((char *)buffer)+n*st*size;
ret+=(fread(buf2,size,(size_t) (count-n*st),stream));
st = mx / ((unsigned long long)size);
n = count / st;
for (j = 0; j < n; j++)
{
buf2 = ((char *)buffer) + j * st * size;
ret += (fread(buf2, size, (size_t)st, stream));
}
buf2 = ((char *)buffer) + n * st * size;
ret += (fread(buf2, size, (size_t)(count - n * st), stream));
return ret;
}
7 changes: 5 additions & 2 deletions src/BinIO.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
size_t fwrite_big(void *,size_t ,size_t , FILE *);
size_t fread_big(void *,size_t ,size_t , FILE *);
#include <stdio.h>
#include <stdlib.h>

size_t fwrite_big(void *, size_t, size_t, FILE *);
size_t fread_big(void *, size_t, size_t, FILE *);
Loading