added compiler info to nimisewi also removed error checks from nimisewi, nimisewi.cgi and nimisewi_gemini.cgi because this error check has to happen inside nimi_sewi() and not in those programs. FossilOrigin-Name: 2fd4c9495753569c904132ee83cd5f14662389c69399c27f289e0e3ae35aa0cb
la-ninpre leobrekalini@gmail.com
Fri, 10 Sep 2021 17:08:07 +0000
6 files changed,
39 insertions(+),
25 deletions(-)
M
CMakeLists.txt
→
CMakeLists.txt
@@ -1,16 +1,33 @@
cmake_minimum_required(VERSION 3.10) +# project specification + project(nimisewi - VERSION 0.3.0 + VERSION 0.3.1 DESCRIPTION "small program that generates random toki pona noun phrase" HOMEPAGE_URL "https://fsl.aaoth.xyz/nimisewi.c/home") +# get compiler name and version + +execute_process(COMMAND ${CMAKE_C_COMPILER} "--version" + OUTPUT_VARIABLE _PROJECT_C_COMPILER_VERSION) +string(REGEX REPLACE "\n" ";" + PROJECT_C_COMPILER_VERSION ${_PROJECT_C_COMPILER_VERSION}) +list(APPEND PROJECT_C_COMPILER_STRING ${PROJECT_C_COMPILER_VERSION}) +list(POP_FRONT PROJECT_C_COMPILER_STRING PROJECT_C_COMPILER_VERSION) + +# configuration header + configure_file(config.h.in config.h) +# main executable + add_executable(nimisewi main.c nimisewi.c ${PROJECT_BINARY_DIR}/nimitoki.c) target_include_directories(nimisewi PUBLIC "${PROJECT_BINARY_DIR}") +# supplementary executable + add_executable(makenimitoki makenimitoki.c) target_include_directories(makenimitoki PUBLIC "${PROJECT_BINARY_DIR}")@@ -20,9 +37,13 @@ ${PROJECT_BINARY_DIR}/nimitoki.h
COMMAND makenimitoki ${PROJECT_SOURCE_DIR}/nimitoki.txt DEPENDS makenimitoki) +# includes + include(CheckIncludeFile) include(CheckSymbolExists) include(CheckCSourceCompiles) + +# warning message set(WARNING_STATIC_BUILD "static build won't work here")@@ -178,6 +199,8 @@ if(BUILD_GEMINI_CGI)
install(TARGETS nimisewi_gemini.cgi DESTINATION $<TARGET_PROPERTY:nimisewi_gemini.cgi,GEMINI_CGI_INSTALL_DIR>) endif() + +# packaging include(InstallRequiredSystemLibraries) set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
M
cgi.c
→
cgi.c
@@ -75,26 +75,23 @@
int main(void) { + char *ns; + #ifdef HAVE_PLEDGE if (pledge("stdio", NULL) == -1) { err(EXIT_FAILURE, "pledge"); } #endif - char *ns; - ns = nimi_sewi(); - if (ns == NULL) { - err(EXIT_FAILURE, "memory allocation failed"); - } - print_response_header(); print_html_header(); printf("<h1>"); + ns = nimi_sewi(); printf("%s", ns); + weka_e_nimi_sewi(ns); printf("</h1>\n"); - weka_e_nimi_sewi(ns); print_html_footer();
M
cgi_gemini.c
→
cgi_gemini.c
@@ -9,22 +9,19 @@
int main(void) { + char *ns; + #ifdef HAVE_PLEDGE if (pledge("stdio", NULL) == -1) { err(EXIT_FAILURE, "pledge failed"); } #endif - char *ns; - - ns = nimi_sewi(); - if (ns == NULL) { - err(EXIT_FAILURE, "memory allocation failed"); - } - printf("20 text/gemini\r\n"); printf("sina o lukin e nimi sewi:\n\n"); + ns = nimi_sewi(); printf("# %s\n", ns); + weka_e_nimi_sewi(ns); return EXIT_SUCCESS; }
M
config.h.in
→
config.h.in
@@ -1,3 +1,4 @@
#define NIMISEWI_VERSION "@nimisewi_VERSION@" #define PACKAGE_STRING "@CMAKE_PROJECT_NAME@" " " NIMISEWI_VERSION #define PACKAGE_DESCRIPTION "@nimisewi_DESCRIPTION@" +#define COMPILER_NAME "@PROJECT_C_COMPILER_VERSION@"
M
main.c
→
main.c
@@ -32,6 +32,8 @@
int main(int argc, char *argv[]) { + char *ns; + #ifdef HAVE_PLEDGE if (pledge("stdio", NULL) == -1) { err(EXIT_FAILURE, "pledge");@@ -41,9 +43,8 @@ if (argc == 2) {
if (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-v")) { printf("%s\n", PACKAGE_STRING); printf("%s\n", PACKAGE_DESCRIPTION); -#if defined(HAVE_PLEDGE) || defined(HAVE_STRLCAT) - printf("features:\n"); -#endif + printf("compiled on %s %s using %s (%d-bit)\n", + __DATE__, __TIME__, COMPILER_NAME, sizeof(void*)*8); #ifdef HAVE_PLEDGE printf("HAVE_PLEDGE\n"); #endif@@ -56,14 +57,9 @@ #endif
return EXIT_SUCCESS; } } - char *ns; + ns = nimi_sewi(); - if (ns == NULL) { - err(EXIT_FAILURE, "memory allocation failed"); - } - printf("%s\n", ns); - weka_e_nimi_sewi(ns); return EXIT_SUCCESS;
M
nimisewi.c
→
nimisewi.c
@@ -218,7 +218,7 @@
nimi_pana = calloc(nn->suli_pi_nimi_sewi + 1, sizeof(char)); if (nimi_pana == NULL) { weka_e_nanpa_nimi(nn); - return NULL; + err(EXIT_FAILURE, "memory allocation failed"); } for (i = 0; i < nn->nanpa_nimi; i++) {