Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: actions/checkout@v2

- name: Run Regression
uses: exoticlibraries/exotic-action@v1.3
uses: exoticlibraries/exotic-action@v1.4
with:
download-exotic-libraries: true
run-regression: true
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
uses: actions/checkout@v2

- name: Setup Exotic Libraries
uses: exoticlibraries/exotic-action@v1.3
uses: exoticlibraries/exotic-action@v1.4
with:
download-exotic-libraries: true
run-regression: false
Expand Down
171 changes: 89 additions & 82 deletions include/exotic/cline/cliarg.h

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions include/exotic/cline/cline_common.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

/*!
\copyright MIT License Copyright (c) 2021, Adewale Azeez
\author Adewale Azeez <azeezadewale98@gmail.com>
\author Adewale Azeez <iamthecarisma@gmail.com>
\date 19 February 2021
\file cline_common.h

Expand All @@ -15,8 +15,13 @@
extern "C" {
#endif

#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <exotic/xtd/xcommon.h>
#include <exotic/xtd/util/xcrypto.h>
#include <exotic/xtd/container/xstring.h>
#include <exotic/xtd/container/xhashtable.h>

#ifdef _WIN32
#include <windows.h>
Expand Down Expand Up @@ -63,7 +68,7 @@ extern "C" {
/*!

*/
void cline_platform_printnl_if()
static void cline_platform_printnl_if()
{
#ifndef _WIN32
printf("\n");
Expand All @@ -74,7 +79,7 @@ void cline_platform_printnl_if()
printf("libcline FATAL_ERROR -> %s:%d ", file_name, line_number);\
printf(__VA_ARGS__); \
cline_platform_printnl_if(); \
exit(EXIT_FAILURE);\
exit(1);\
}

#ifdef _WIN32
Expand Down Expand Up @@ -104,7 +109,7 @@ static unsigned already_change_mode = 0;
/*!

*/
char *cline_ansi_encoder(const char *file_name, const int line_number, const char ansi_code_terminator, const int argscount, ...)
static char *cline_ansi_encoder(const char *file_name, const int line_number, const char ansi_code_terminator, const int argscount, ...)
{
va_list ap;
const char *p;
Expand Down
2 changes: 1 addition & 1 deletion include/exotic/cline/cursor_nav.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

/*!
\copyright MIT License Copyright (c) 2021, Adewale Azeez
\author Adewale Azeez <azeezadewale98@gmail.com>
\author Adewale Azeez <iamthecarisma@gmail.com>
\date 19 February 2021
\file cursor_nav.h

Expand Down
4 changes: 2 additions & 2 deletions include/exotic/cline/font_effect.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

/*!
\copyright MIT License Copyright (c) 2021, Adewale Azeez
\author Adewale Azeez <azeezadewale98@gmail.com>
\author Adewale Azeez <iamthecarisma@gmail.com>
\date 12 February 2021
\file font_effect.h

Expand Down Expand Up @@ -146,7 +146,7 @@ extern "C" {
this can be used to quick disable the effects without having to
delete the other font effect options.
*/
const char *cline_fe_str_with_end_fe(const char *file_name, const int line_number, const char *text, const char *fe, const char *end_fe)
static const char *cline_fe_str_with_end_fe(const char *file_name, const int line_number, const char *text, const char *fe, const char *end_fe)
{
int fe_length = strlen(fe);
int concatenated_length = strlen(text) + fe_length + (fe_length > 0 ? strlen(end_fe) : 0);
Expand Down
2 changes: 1 addition & 1 deletion include/exotic/cline/term_input.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

/*!
\copyright MIT License Copyright (c) 2021, Adewale Azeez
\author Adewale Azeez <azeezadewale98@gmail.com>
\author Adewale Azeez <iamthecarisma@gmail.com>
\date 19 February 2021
\file term_input.h

Expand Down
212 changes: 212 additions & 0 deletions include/exotic/cline/xtd_printers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@

/*!
\copyright MIT License Copyright (c) 2021, Adewale Azeez
\author Adewale Azeez <iamthecarisma@gmail.com>
\date 07 October 2021
\file xtd_printers.h

xtd_printers.h is ...
*/

#ifndef EXOTIC_CLINE_FONT_EFFECT_H
#define EXOTIC_CLINE_FONT_EFFECT_H

#ifdef __cplusplus
extern "C" {
#endif

/*!

*/
#include "cline_common.h"
#include <exotic/metaref.h>

/* LIBXTD FILLER */
#ifndef xpair
#define xpair xhashtable_entry
#endif

/*!

*/
#define CLINE_XTD_GENERIC_FORMAT_SPECIFIER(value) _Generic(value,\
char: "%c",\
unsigned char: "%c",\
short: "%hi",\
unsigned short: "%hu",\
int: "%i",\
unsigned int: "%u",\
long: "%ld",\
unsigned long: "%ld",\
float: "%f",\
double: "%lf",\
long double: "%Lf",\
char *: "%s",\
default: "%p"\
)

/*!

*/
#define CLINE_XTD_PRINTER_SELECT_QUOTE(value) _Generic(value,\
char: "'",\
char *: "\"",\
default: ""\
)

/*!

*/
#define CLINE_XTD_PRINTER_FPRINT_VALUE(stream, value) fprintf(stream, CLINE_XTD_PRINTER_SELECT_QUOTE(value));\
fprintf(stream, CLINE_XTD_GENERIC_FORMAT_SPECIFIER(value), value);\
fprintf(stream, CLINE_XTD_PRINTER_SELECT_QUOTE(value));\

/*!

*/
#define CLINE_XPRINT_XTD_CONTAINER(container_type, stream, type, container, var_suffix) XIterator *iterator##var_suffix = XITERATOR_INIT(container_type, type, container);\
fprintf(stream, "["); size_t size##var_suffix = container_type##_size(container);\
XFOREACH_INDEX(size_t index##var_suffix, type value##var_suffix, iterator##var_suffix, {\
CLINE_XTD_PRINTER_FPRINT_VALUE(stream, value##var_suffix); if (index##var_suffix < size##var_suffix-1) fprintf(stream, ", ");\
}); fprintf(stream, "]"); XITERATOR_DESTROY(iterator##var_suffix);


/*!

*/
#define CLINE_XPRINT_XTD_CONTAINER_PAIR(container_type, stream, type1, type2, container, var_suffix) \
XIterator *iterator##var_suffix = XITERATOR_INIT2(container_type, type1, type2, container);\
fprintf(stream, "{"); size_t size##var_suffix = container_type##_size(container);\
XFOREACH_INDEX(size_t index##var_suffix, const xpair(type1, type2) *value##var_suffix, iterator##var_suffix, {\
CLINE_XTD_PRINTER_FPRINT_VALUE(stream, (type1) value##var_suffix->key); fprintf(stream, ": ");\
CLINE_XTD_PRINTER_FPRINT_VALUE(stream, (type2) value##var_suffix->value); if (index##var_suffix < size##var_suffix-1) fprintf(stream, ", ");\
}); fprintf(stream, "}"); XITERATOR_DESTROY(iterator##var_suffix);

/*!

*/
#define CLINE_XPRINT_XDEQUE(stream, type, container) CLINE_XPRINT_XTD_CONTAINER(xdeque, stream, type, container, __LINE__)

/*!

*/
#define CLINE_XPRINT_XLIST(stream, type, container) CLINE_XPRINT_XTD_CONTAINER(xlist, stream, type, container, __LINE__)

/*!

*/
#define CLINE_XPRINT_XSLIST(stream, type, container) CLINE_XPRINT_XTD_CONTAINER(xslist, stream, type, container, __LINE__)

/*!

*/
#define CLINE_XPRINT_XQUEUE(stream, type, container) CLINE_XPRINT_XTD_CONTAINER(xqueue, stream, type, container, __LINE__)

/*!

*/
#define CLINE_XPRINT_XSTACK(stream, type, container) CLINE_XPRINT_XTD_CONTAINER(xstack, stream, type, container, __LINE__)

/*!

*/
#define CLINE_XPRINT_XPRIORITY_QUEUE(stream, type, container) CLINE_XPRINT_XTD_CONTAINER(xpriority_queue, stream, type, container, __LINE__)

/*!

*/
#define CLINE_XPRINT_XVECTOR(stream, type, container) CLINE_XPRINT_XTD_CONTAINER(xvector, stream, type, container, __LINE__)

/*!

*/
#define CLINE_XPRINT_XSET(stream, type, container) CLINE_XPRINT_XTD_CONTAINER(xset, stream, type, container, __LINE__)

/*!

*/
#define CLINE_XPRINT_XUNORDERED_SET(stream, type, container) CLINE_XPRINT_XTD_CONTAINER(xunordered_set, stream, type, container, __LINE__)

/*!

*/
#define CLINE_XPRINT_XHASHTABLE(stream, type1, type2, container) CLINE_XPRINT_XTD_CONTAINER_PAIR(xhashtable, stream, type1, type2, container, __LINE__)

/*!

*/
#define CLINE_XPRINT_XTD_CONTAINER_CUSTOM(container_type, stream, type, container, value_formatter, var_suffix) XIterator *iterator##var_suffix = XITERATOR_INIT(container_type, type, container);\
fprintf(stream, "["); size_t size##var_suffix = container_type##_size(container);\
XFOREACH_INDEX(size_t index##var_suffix, type value##var_suffix, iterator##var_suffix, {\
fprintf(stream, value_formatter(value##var_suffix));\
if (index##var_suffix < size##var_suffix-1) fprintf(stream, ", ");\
}); fprintf(stream, "]"); XITERATOR_DESTROY(iterator##var_suffix);

/*!

*/
#define CLINE_XPRINT_XTD_CONTAINER_CUSTOM_PAIR(container_type, stream, type1, type2, container, key_formatter, value_formatter, var_suffix)\
XIterator *iterator##var_suffix = XITERATOR_INIT2(container_type, type1, type2, container);\
fprintf(stream, "{"); size_t size##var_suffix = container_type##_size(container);\
XFOREACH_INDEX(size_t index##var_suffix, const xpair(type1, type2) *value##var_suffix, iterator##var_suffix, {\
fprintf(stream, key_formatter(value##var_suffix->key)); fprintf(stream, ": ");\
fprintf(stream, value_formatter(value##var_suffix->value)); if (index##var_suffix < size##var_suffix-1) fprintf(stream, ", ");\
}); fprintf(stream, "}"); XITERATOR_DESTROY(iterator##var_suffix);


/*!

*/
#define CLINE_XPRINT_XDEQUE_CUSTOM(stream, type, container, value_formatter) CLINE_XPRINT_XTD_CONTAINER_CUSTOM(xdeque, stream, type, container, value_formatter, __LINE__)

/*!

*/
#define CLINE_XPRINT_XLIST_CUSTOM(stream, type, container, value_formatter) CLINE_XPRINT_XTD_CONTAINER_CUSTOM(xlist, stream, type, container, value_formatter, __LINE__)

/*!

*/
#define CLINE_XPRINT_XSLIST_CUSTOM(stream, type, container, value_formatter) CLINE_XPRINT_XTD_CONTAINER_CUSTOM(xslist, stream, type, container, value_formatter, __LINE__)

/*!

*/
#define CLINE_XPRINT_XQUEUE_CUSTOM(stream, type, container, value_formatter) CLINE_XPRINT_XTD_CONTAINER_CUSTOM(xqueue, stream, type, container, value_formatter, __LINE__)

/*!

*/
#define CLINE_XPRINT_XSTACK_CUSTOM(stream, type, container, value_formatter) CLINE_XPRINT_XTD_CONTAINER_CUSTOM(xstack, stream, type, container, value_formatter, __LINE__)

/*!

*/
#define CLINE_XPRINT_XPRIORITY_QUEUE_CUSTOM(stream, type, container, value_formatter) CLINE_XPRINT_XTD_CONTAINER_CUSTOM(xpriority_queue, stream, type, container, value_formatter, __LINE__)

/*!

*/
#define CLINE_XPRINT_XVECTOR_CUSTOM(stream, type, container, value_formatter) CLINE_XPRINT_XTD_CONTAINER_CUSTOM(xvector, stream, type, container, value_formatter, __LINE__)

/*!

*/
#define CLINE_XPRINT_XSET_CUSTOM(stream, type, container, value_formatter) CLINE_XPRINT_XTD_CONTAINER_CUSTOM(xset, stream, type, container, value_formatter, __LINE__)

/*!

*/
#define CLINE_XPRINT_XUNORDERED_SET_CUSTOM(stream, type, container, value_formatter) CLINE_XPRINT_XTD_CONTAINER_CUSTOM(xunordered_set, stream, type, container, value_formatter, __LINE__)

/*!

*/
#define CLINE_XPRINT_XHASHTABLE_CUSTOM(stream, type1, type2, container, key_formatter, value_formatter) CLINE_XPRINT_XTD_CONTAINER_CUSTOM_PAIR(xhashtable, stream, type1, type2, container, key_formatter, value_formatter, __LINE__)


#ifdef __cplusplus
}
#endif

#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*!gcc {0} -I. -I../include/ -I../../include/ -o out; ./out */
/*!gcc {0} -I. -I../include/ -I../../../include/ -o out; ./out */

#include <exotic/cester.h>
#include <exotic/cline/cliarg.h>
Expand Down Expand Up @@ -101,7 +101,7 @@ CESTER_TEST(cline_arg_get_arg_option, inst, {
cester_assert_int_eq(cline_arg_add_option(cline_arg, XTD_NULL, "-h<:>--help", "Print this help message", FALSE), XTD_OK);
cester_assert_int_eq(cline_arg_add_option(cline_arg, XTD_NULL, "-v<:>--version", "Print the version information and exit", FALSE), XTD_OK);
cester_assert_int_eq(cline_arg_add_option(cline_arg, XTD_NULL, "--verbose", "Be extra verbose", FALSE), XTD_OK);

cester_assert_int_eq(cline_arg_get_arg_option(cline_arg, XTD_NULL, "--version", &cline_arg_option), TRUE);
cester_assert_str_equal_(cline_arg_option->splited_option_keys[0], "-v");
cester_assert_str_equal_(cline_arg_option->splited_option_keys[1], "--version");
Expand Down
Loading