uncrustify source code

master
neingeist 10 years ago
parent ca15f19709
commit 8141a18cab

@ -35,6 +35,10 @@ cppcheck.txt: *.c *.h
tags: *.c tags: *.c
ctags -R . ctags -R .
.PHONY: uncrustify
uncrustify:
uncrustify -c uncrustify.cfg --no-backup *.c
mandelbrot: mandelbrot.c mandelbrot: mandelbrot.c
$(CC) $(CFLAGS) $(shell sdl-config --cflags) -o $@ $< $(shell sdl-config --libs) -lm $(CC) $(CFLAGS) $(shell sdl-config --cflags) -o $@ $< $(shell sdl-config --libs) -lm

@ -6,7 +6,7 @@
double mean(double set[], int set_n) { double mean(double set[], int set_n) {
double sum = 0.0; double sum = 0.0;
for(int i=0; i<set_n; i++) { for (int i=0; i<set_n; i++) {
sum += set[i]; sum += set[i];
} }
@ -40,7 +40,7 @@ double sample_stddev(double set[], int set_n) {
double set_min(double set[], int set_n) { double set_min(double set[], int set_n) {
double min = MAXDOUBLE; double min = MAXDOUBLE;
for(int i=0; i<set_n; i++) { for (int i=0; i<set_n; i++) {
min=fmin(set[i], min); min=fmin(set[i], min);
} }

@ -1,7 +1,7 @@
/* /*
Write a recursive function that searches for a target in a sorted array using Write a recursive function that searches for a target in a sorted array using
binay search, where the array, its size and the target are given as parameters. binay search, where the array, its size and the target are given as parameters.
*/ */
#include <limits.h> #include <limits.h>
#include <stdio.h> #include <stdio.h>
@ -9,7 +9,7 @@ binay search, where the array, its size and the target are given as parameters.
#define DEBUG 1 #define DEBUG 1
#define debug_printf(fmt, ...) \ #define debug_printf(fmt, ...) \
do { if (DEBUG) fprintf(stderr, fmt, __VA_ARGS__); } while (0) do { if (DEBUG) fprintf(stderr, fmt, __VA_ARGS__); } while (0)
void assert_sorted(int array[], int arraylen) { void assert_sorted(int array[], int arraylen) {
int n = INT_MIN; int n = INT_MIN;
@ -51,7 +51,8 @@ int main(void) {
21090, 22277, 22624, 24634, 24877, 21090, 22277, 22624, 24634, 24877,
25367, 25586, 26706, 26720, 26958, 25367, 25586, 26706, 26720, 26958,
27478, 28269, 29142, 30630, 30804, 27478, 28269, 29142, 30630, 30804,
31984, 32398, 32588 }; 31984, 32398, 32588
};
assert_sorted(a, 43); assert_sorted(a, 43);
assert(binsearch(a, 43, 912) == 0); assert(binsearch(a, 43, 912) == 0);

@ -77,7 +77,7 @@ uint32_t Murmur3_32(uint8_t * key, size_t len, uint32_t seed) {
// by the modulo arithmetic under overflow. We don't want that. // by the modulo arithmetic under overflow. We don't want that.
remainingbytes = remainingbytes * c1; remainingbytes = remainingbytes * c1;
remainingbytes = remainingbytes =
(remainingbytes << r1) | (remainingbytes >> (32 - r1)); (remainingbytes << r1) | (remainingbytes >> (32 - r1));
remainingbytes = remainingbytes * c2; remainingbytes = remainingbytes * c2;
hash = hash ^ remainingbytes; hash = hash ^ remainingbytes;

@ -8,7 +8,7 @@
#define DEBUG 0 #define DEBUG 0
#define debug_printf(fmt, ...) \ #define debug_printf(fmt, ...) \
do { if (DEBUG) fprintf(stderr, fmt, __VA_ARGS__); } while (0) do { if (DEBUG) fprintf(stderr, fmt, __VA_ARGS__); } while (0)
#define CB_SIZE 42 #define CB_SIZE 42

@ -2,6 +2,6 @@
int main(void) { int main(void) {
#pragma omp parallel #pragma omp parallel
printf("Hello, world.\n"); printf("Hello, world.\n");
return 0; return 0;
} }

@ -254,7 +254,7 @@ int main(void) {
assert(list_elementat(foolist, list_length(foolist)+2) == NULL); assert(list_elementat(foolist, list_length(foolist)+2) == NULL);
/* Free up remaining items and the list. */ /* Free up remaining items and the list. */
while(!list_empty(foolist)) { while (!list_empty(foolist)) {
list_node_t *el = list_elementat(foolist, 0); list_node_t *el = list_elementat(foolist, 0);
free(list_remove(foolist, el)); free(list_remove(foolist, el));
} }

@ -45,7 +45,7 @@ int main(void) {
{ "string", luaopen_string }, { "string", luaopen_string },
{ NULL, NULL} { NULL, NULL}
}; };
for(luaL_Reg *lib = lualibs; lib->func; lib++) { for (luaL_Reg *lib = lualibs; lib->func; lib++) {
printf("Loading %s\n", lib->name); printf("Loading %s\n", lib->name);
lib->func(L); lib->func(L);
lua_setglobal(L, lib->name); lua_setglobal(L, lib->name);

@ -27,7 +27,7 @@ void drawmandelbrot(SDL_Surface * surface) {
int x = i % surface->w; int x = i % surface->w;
float complex c = ((3.0f * x / surface->w) - 2.0f) float complex c = ((3.0f * x / surface->w) - 2.0f)
+ I * ((2.0f * y / surface->h) - 1.0f); + I * ((2.0f * y / surface->h) - 1.0f);
bool diverges = false; bool diverges = false;
float complex z = 0; float complex z = 0;
@ -54,7 +54,7 @@ void drawmandelbrot(SDL_Surface * surface) {
/* Update the screen every 10 lines. */ /* Update the screen every 10 lines. */
#pragma omp critical #pragma omp critical
{ {
if (y % 10 == 0 && x == 0) { if (y % 10 == 0 && x == 0) {
SDL_Flip(surface); SDL_Flip(surface);
} }

@ -26,7 +26,7 @@ void drawmandelbrot(SDL_Surface * surface) {
int x = i % surface->w; int x = i % surface->w;
float complex c = ((3.0f * x / surface->w) - 2.0f) float complex c = ((3.0f * x / surface->w) - 2.0f)
+ I * ((2.0f * y / surface->h) - 1.0f); + I * ((2.0f * y / surface->h) - 1.0f);
bool diverges = false; bool diverges = false;
float complex z = 0; float complex z = 0;

@ -50,7 +50,7 @@ void compmandelbrot_line(bitmap_t * mbrot, size_t y) {
for (size_t x = 0; x < mbrot->width; x++) { for (size_t x = 0; x < mbrot->width; x++) {
float complex c = ((3.0f * x / mbrot->width) - 2.0f) float complex c = ((3.0f * x / mbrot->width) - 2.0f)
+ I * ((2.0f * y / mbrot->height) - 1.0f); + I * ((2.0f * y / mbrot->height) - 1.0f);
bool diverges = false; bool diverges = false;
float complex z = 0; float complex z = 0;
@ -112,7 +112,7 @@ static int save_png_to_file(bitmap_t * bitmap, const char *path) {
} }
png_ptr = png_ptr =
png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (png_ptr == NULL) { if (png_ptr == NULL) {
goto png_create_write_struct_failed; goto png_create_write_struct_failed;
} }
@ -141,7 +141,7 @@ static int save_png_to_file(bitmap_t * bitmap, const char *path) {
row_pointers = png_malloc(png_ptr, bitmap->height * sizeof(png_byte *)); row_pointers = png_malloc(png_ptr, bitmap->height * sizeof(png_byte *));
for (y = 0; y < bitmap->height; ++y) { for (y = 0; y < bitmap->height; ++y) {
png_byte *row = png_byte *row =
png_malloc(png_ptr, sizeof(uint8_t) * bitmap->width * pixel_size); png_malloc(png_ptr, sizeof(uint8_t) * bitmap->width * pixel_size);
row_pointers[y] = row; row_pointers[y] = row;
for (x = 0; x < bitmap->width; ++x) { for (x = 0; x < bitmap->width; ++x) {
pixel_t *pixel = bitmap->pixels + (y * bitmap->width + x); pixel_t *pixel = bitmap->pixels + (y * bitmap->width + x);

@ -50,7 +50,7 @@ void compmandelbrot_line(bitmap_t * mbrot, size_t y) {
for (size_t x = 0; x < mbrot->width; x++) { for (size_t x = 0; x < mbrot->width; x++) {
float complex c = ((3.0f * x / mbrot->width) - 2.0f) float complex c = ((3.0f * x / mbrot->width) - 2.0f)
+ I * ((2.0f * y / mbrot->height) - 1.0f); + I * ((2.0f * y / mbrot->height) - 1.0f);
bool diverges = false; bool diverges = false;
float complex z = 0; float complex z = 0;
@ -143,7 +143,7 @@ static int save_png_to_file(bitmap_t * bitmap, const char *path) {
} }
png_ptr = png_ptr =
png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (png_ptr == NULL) { if (png_ptr == NULL) {
goto png_create_write_struct_failed; goto png_create_write_struct_failed;
} }
@ -172,7 +172,7 @@ static int save_png_to_file(bitmap_t * bitmap, const char *path) {
row_pointers = png_malloc(png_ptr, bitmap->height * sizeof(png_byte *)); row_pointers = png_malloc(png_ptr, bitmap->height * sizeof(png_byte *));
for (y = 0; y < bitmap->height; ++y) { for (y = 0; y < bitmap->height; ++y) {
png_byte *row = png_byte *row =
png_malloc(png_ptr, sizeof(uint8_t) * bitmap->width * pixel_size); png_malloc(png_ptr, sizeof(uint8_t) * bitmap->width * pixel_size);
row_pointers[y] = row; row_pointers[y] = row;
for (x = 0; x < bitmap->width; ++x) { for (x = 0; x < bitmap->width; ++x) {
pixel_t *pixel = bitmap->pixels + (y * bitmap->width + x); pixel_t *pixel = bitmap->pixels + (y * bitmap->width + x);
@ -235,7 +235,7 @@ int main(int argc, char *argv[]) {
for (int t = 0; t < num_threads; t++) { for (int t = 0; t < num_threads; t++) {
ret = ret =
pthread_create(&threads[t], NULL, compmandelbrot, (void *) NULL); pthread_create(&threads[t], NULL, compmandelbrot, (void *) NULL);
assert(ret == 0); assert(ret == 0);
} }

@ -4,11 +4,11 @@
int main() { int main() {
int i = 0xffff; int i = 0xffff;
asm("movl $23, %0" asm ("movl $23, %0"
: "=r" (i) /* output */ : "=r" (i) /* output */
/* : no input */ /* : no input */
/* : no clobbered */ /* : no clobbered */
); );
printf("i = %d\n", i); printf("i = %d\n", i);
assert(i == 23); assert(i == 23);

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save