diff --git a/.gitignore b/.gitignore index b4b23c1..416bc3b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -*.DS_STORE +*.DS_Store *.o *.log *.gcov @@ -6,5 +6,4 @@ *.gcno binary test -example -coverage +deps/ diff --git a/.travis.yml b/.travis.yml index 3cb95fa..f694616 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,17 @@ language: c + +services: + - docker + compiler: -- clang -- gcc -script: make run-test + - clang + - gcc + +before_install: + - docker pull abranhe/clib + - docker run -it -v $(pwd):/src -w /src abranhe/clib sh -c "clib install" + +script: docker run -it -v $(pwd):/src -w /src abranhe/clib sh -c "make run-test" + notifications: - email: false + email: false \ No newline at end of file diff --git a/Makefile b/Makefile index 67939ba..b6f24b5 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ PREFIX ?= /usr/local -SRC = binary-cli.c deps/binary.c/binary.c +SRC = cli.c deps/binary.c/binary.c OBJ_SRC = $(SRC:.c=.o) diff --git a/cli.c b/cli.c index dd74183..b77b12f 100644 --- a/cli.c +++ b/cli.c @@ -13,8 +13,10 @@ #include #include "binary.h" -const char -*show_help() { +#define VERSION "1.0.4" + +const char* +show_help(void) { return "\n\ An small library to work with binary numbers\n\n\ Usage:\n\n\ @@ -40,7 +42,7 @@ main(int argc, char **argv) { if (argc == 2) { if (!strcmp(a, "-v") || !strcmp(a, "--version")) { - printf("%s", "1.0.3\n"); + printf("%s\n", VERSION); return 0; } @@ -78,4 +80,4 @@ main(int argc, char **argv) { return 1; } return 0; -} +} \ No newline at end of file diff --git a/deps/binary.c/binary.c b/deps/binary.c/binary.c deleted file mode 100644 index 136d4f3..0000000 --- a/deps/binary.c/binary.c +++ /dev/null @@ -1,61 +0,0 @@ -// -// An small library to work with -// binary numbers. -// -// binary.c -// -// MIT licensed. -// Copyright (c) Abraham Hernandez -// - -#include - -bool -is_binary (long long binary) { - bool status = true; - while(true) { - if (binary == 0) break; - else { - int tmp = binary % 10; - if(tmp > 1) { - status = false; - break; - } - binary = binary / 10; - } - } - return status; -} - -long -to_decimal (long long binary) { - if(!is_binary(binary)) return -1; - - int decimal = 0; - int multiplier = 1; - - while (binary != 0) { - decimal += (binary % 10) * multiplier; - binary /= 10; - multiplier *= 2; - } - return decimal; -} - -long long to_binary(long number) { - long long binary = 0; - int remainder; - int i = 1; - - while (number != 0) { - remainder = number % 2; - number /= 2; - binary += remainder * i; - i *= 10; - } - return binary; -} - -// TODO: -// add_binary() -// substract_binary() ... diff --git a/deps/binary.c/binary.h b/deps/binary.c/binary.h deleted file mode 100644 index 70bcb95..0000000 --- a/deps/binary.c/binary.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef BINARY_H -#define BINARY_H - -// -// binary.h -// -// MIT licensed. -// Copyright (c) Abraham Hernandez -// - -#define bool int - -#ifdef __cplusplus -extern "C" { -#endif - -bool -is_binary(long binary); - -long -to_decimal(long long binary); - -long long to_binary(long number); - -#ifdef __cplusplus -} -#endif - -#endif // BINARY_H diff --git a/deps/binary.c/package.json b/deps/binary.c/package.json deleted file mode 100644 index af97db7..0000000 --- a/deps/binary.c/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "binary.c", - "version": "1.0.0", - "description": "An small library to work with binary numbers", - "license": "MIT", - "keywords": [ - "binary", "binary-numbers" - ], - "repo": "abranhe/binary.c", - "src": [ - "binary.h", - "binary.c" - ] -}