Compare commits

...

4 Commits

Author SHA1 Message Date
Daniel Santos 5c8a3b16c5 doc update
Signed-off-by: Daniel Santos <dacs.git@brilhante.top>
2022-03-19 08:25:58 +00:00
Daniel Santos 9e89a65676 add to Makefile
* change make into $(MAKE)
 * in compiling libraries, echo message with path
 * create Makefile variables: INSTALL and prefix
 * add rule install-lib

Signed-off-by: Daniel Santos <dacs.git@brilhante.top>
2022-03-19 08:22:20 +00:00
Daniel Santos f5421e7612 replace PROG_NAME with "numericx" literal
* replaced PROG_NAME for string literal "numericx".
 * deleted macro definition of PROG_NAME.

Signed-off-by: Daniel Santos <dacs.git@brilhante.top>
2022-03-19 07:43:14 +00:00
Daniel Santos fcc6c957bf numericx_translate() return true
* numericx_translate() was returning EXIT_SUCCESS in case of success.
   Doohh! Now it is return true, in case of success.

   Ajust doxygen comment accordingly.

Signed-off-by: Daniel Santos <dacs.git@brilhante.top>
2022-03-19 07:35:32 +00:00
5 changed files with 23 additions and 15 deletions

View File

@ -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
View File

@ -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

@ -1 +1 @@
Subproject commit dda4bf1fbfc8a4f7be10ce11265a44042bc452ba
Subproject commit 696534107c7a3bad0f8d5dd90fc7aed83c36c92a

View File

@ -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;
}

View File

@ -6,7 +6,6 @@
#include <stdbool.h>
#define PROG_NAME "numericx"
/* ||DATA STRUCTURE|| */