Compare commits
4 Commits
aa172de2cf
...
5c8a3b16c5
Author | SHA1 | Date |
---|---|---|
Daniel Santos | 5c8a3b16c5 | |
Daniel Santos | 9e89a65676 | |
Daniel Santos | f5421e7612 | |
Daniel Santos | fcc6c957bf |
15
Makefile
15
Makefile
|
@ -1,6 +1,10 @@
|
|||
CFLAGS := -Wall -Wextra -O2
|
||||
DEP := cli.c numericx.o
|
||||
|
||||
INSTALL := install
|
||||
|
||||
prefix = /usr
|
||||
|
||||
.PHONY: all
|
||||
all: decimal-to-earth earth-to-decimal decimal-to-sun sun-to-decimal decimal-to-lori decimal-to-nonal_inf decimal-to-nonal lori-to-decimal nonal_inf-to-decimal nonal-to-decimal uninfinity decimal-to-binary binary-to-decimal
|
||||
|
||||
|
@ -13,19 +17,24 @@ numericx.o: numericx.c numericx.h
|
|||
|
||||
.PHONY: libnumericx.a libnumericx.so
|
||||
libnumericx.a: numericx.o
|
||||
@make lib-dirs
|
||||
@$(MAKE) lib-dirs
|
||||
ar -rcs lib/static/$@ $^
|
||||
@echo Compiled successfully to ./lib/static/
|
||||
|
||||
numericx-pic.o: numericx.c numericx.h
|
||||
$(CC) $(CFLAGS) -fPIC -c numericx.c -o $@
|
||||
|
||||
libnumericx.so: numericx-pic.o
|
||||
@make lib-dirs
|
||||
@$(MAKE) lib-dirs
|
||||
$(CC) -shared $^ -o lib/shared/$@
|
||||
@echo Compiled successfully to ./lib/shared/
|
||||
|
||||
.PHONY: libs
|
||||
.PHONY: libs install-lib
|
||||
libs: libnumericx.a libnumericx.so
|
||||
|
||||
install-lib: libnumericx.so
|
||||
$(INSTALL) -m 755 lib/shared/libnumericx.so $(prefix)/lib/
|
||||
|
||||
.PHONY: doc
|
||||
doc:
|
||||
rm -Rf doc/*
|
||||
|
|
14
cli.c
14
cli.c
|
@ -111,7 +111,7 @@ main(int argc, char* argv[])
|
|||
/* argument processing */
|
||||
if( !(argc == 2) )
|
||||
{
|
||||
fprintf(stderr, "usage: %s <number>\n", PROG_NAME);
|
||||
fprintf(stderr, "usage: %s <number>\n", "numericx");
|
||||
return E2BIG;
|
||||
}
|
||||
|
||||
|
@ -143,20 +143,20 @@ main(int argc, char* argv[])
|
|||
switch( status )
|
||||
{
|
||||
case EINVAL:
|
||||
fprintf(stderr, "error: %s: %s. Resulting string variable has to be NULL.\n",
|
||||
PROG_NAME, strerror(EINVAL));
|
||||
fprintf(stderr, "error: %s: %s. Resulting string argument value has to be NULL.\n",
|
||||
"numericx", strerror(EINVAL));
|
||||
break;
|
||||
case EDOM:
|
||||
fprintf(stderr, "error: %s: %s. Valid numerals are: \"%s\".\n",
|
||||
PROG_NAME, strerror(EDOM), from);
|
||||
"numericx", strerror(EDOM), from);
|
||||
break;
|
||||
case ERANGE:
|
||||
fprintf(stderr, "error: %s: Unrepresentable void number.\n", PROG_NAME);
|
||||
fprintf(stderr, "error: %s: Unrepresentable void number.\n", "numericx");
|
||||
break;
|
||||
}
|
||||
if( !(status == EXIT_SUCCESS) )
|
||||
if( !(status == true) )
|
||||
{
|
||||
fprintf(stderr, "error: %s: Incapable of translating.\n", PROG_NAME);
|
||||
fprintf(stderr, "error: %s: Incapable of translating.\n", "numericx");
|
||||
free(from);
|
||||
free(to);
|
||||
numericx_free(result);
|
||||
|
|
2
doc
2
doc
|
@ -1 +1 @@
|
|||
Subproject commit dda4bf1fbfc8a4f7be10ce11265a44042bc452ba
|
||||
Subproject commit 696534107c7a3bad0f8d5dd90fc7aed83c36c92a
|
|
@ -30,7 +30,7 @@ new_digit(numeral_ptr* last_numeral, char const* to_first)
|
|||
numeral_ptr* new_numeral = malloc(sizeof(numeral_ptr));
|
||||
if(new_numeral == NULL)
|
||||
{
|
||||
fprintf(stderr, "error: %s: %s!", PROG_NAME, strerror(ENOMEM));
|
||||
fprintf(stderr, "error: %s: %s!", "numericx", strerror(ENOMEM));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ is_number_void(char* number, char* void_numeral, bool is_infinite)
|
|||
* @return EINVAL if argument of result_string is not NULL.
|
||||
* @return EDOM if number doesn't belong to the 'from' numerical system.
|
||||
* @return ERANGE if the resulting number cannot be represented, because of a 'from' void number and a lack of void number in 'to'.
|
||||
* @return EXIT_SUCCESS in case of success.
|
||||
* @return true in case of success.
|
||||
*/
|
||||
int
|
||||
numericx_translate(char* from, bool from_units_on_the_end, bool from_first_number_void, bool from_infinite_base, char* to, bool to_units_on_the_end, bool to_first_number_void, bool to_infinite_base, char* number_arg, char** result_string)
|
||||
|
@ -442,5 +442,5 @@ numericx_translate(char* from, bool from_units_on_the_end, bool from_first_numbe
|
|||
free_numeral(result);
|
||||
free(number);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#define PROG_NAME "numericx"
|
||||
|
||||
/* ||DATA STRUCTURE|| */
|
||||
|
||||
|
|
Loading…
Reference in New Issue