slweb

Једноставни генератор статичких веб страна
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 342a3efbb7573870e45de4f5ba260b2965e7ca4e
родитељ c70c748acb77425ac4d1bfbf3d9a5b6a95b0a4f9
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Sat, 10 Jun 2023 23:37:34 +0200

Obey ext-in-permalink in process_timestamp; move declarations to block start

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
MREADME | 2+-
Mdefs.h | 2++
Mslweb.c | 40++++++++++++++++++++--------------------
измењених датотека: 3, додавања: 23(+), брисања: 21(-)

diff --git a/README b/README @@ -44,7 +44,7 @@ License ------- slweb - Simple static website generator. -Copyright (C) 2020, 2021, 2022, 2023 Страхиња Радић +Copyright (C) 2020-2023 Страхиња Радић This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software diff --git a/defs.h b/defs.h @@ -4,6 +4,8 @@ #define __DEFS_H #define _POSIX_C_SOURCE 200809L +#define _DEFAULT_SOURCE +#define _XOPEN_SOURCE #include <ctype.h> #include <dirent.h> diff --git a/slweb.c b/slweb.c @@ -1564,7 +1564,7 @@ reverse_alphacompare(const struct dirent** a, const struct dirent** b) } int process_timestamp(FILE* output, const u8* link_prefix, const char* link, - const u8* permalink_macro, const u8* date); + const u8* permalink_macro, const u8* date, const int ext_in_permalink); int process_incdir_subdir(FILE* output, const char* subdirname, @@ -1572,18 +1572,18 @@ process_incdir_subdir(FILE* output, const char* subdirname, const u8* footer_permalink_text, const char* permalink_url, int ext_in_permalink) { - print_output(output, "<li>\n<details%s>\n<summary>", - details_open ? " open" : ""); - if (macro_body) - print_output(output, "%s", macro_body); - print_output(output, "%s</summary>\n<div>\n", subdirname); - struct dirent** namelist; struct dirent** pnamelist; long names_total = 0; long names_output; char* abs_subdirname = NULL; + print_output(output, "<li>\n<details%s>\n<summary>", + details_open ? " open" : ""); + if (macro_body) + print_output(output, "%s", macro_body); + print_output(output, "%s</summary>\n<div>\n", subdirname); + CALLOC(abs_subdirname, char, BUFSIZE); snprintf(abs_subdirname, BUFSIZE, "%s/%s/%s", basedir, incdir, subdirname); @@ -1612,18 +1612,18 @@ process_incdir_subdir(FILE* output, const char* subdirname, wait(&pstatus); else if (pid == 0) { - char* filename = NULL; - set_basedir(&basedir, &basedir_size, abs_subdirname); - CALLOC(filename, char, BUFSIZE); - snprintf(filename, BUFSIZE, "%s/%s", abs_subdirname, - (*pnamelist)->d_name); - FILE* input = NULL; FILE* output = stdout; u8* buffer = NULL; size_t buffer_size = 0; int result = 0; ULLONG saved_state = ST_NONE; + char* filename = NULL; + + set_basedir(&basedir, &basedir_size, abs_subdirname); + CALLOC(filename, char, BUFSIZE); + snprintf(filename, BUFSIZE, "%s/%s", abs_subdirname, + (*pnamelist)->d_name); read_file_into_buffer(&input, &buffer, &buffer_size, filename, &input_dirname); @@ -1823,7 +1823,7 @@ int url_is_local(const char* url); int process_timestamp(FILE* output, const u8* link_prefix, const char* link, - const u8* permalink_macro, const u8* date) + const u8* permalink_macro, const u8* date, const int ext_in_permalink) { u8* day = NULL; u8* month = NULL; @@ -1861,15 +1861,15 @@ process_timestamp(FILE* output, const u8* link_prefix, const char* link, ptimestamp_format++; } print_output(output, - "<a href=\"%s%s%s\"" + "<a href=\"%s%s%s%s\"" " class=\"timestamp\">%s%s</a>\n", url_is_local(link) && global_link_prefix ? (const char*)global_link_prefix : "", url_is_local(link) && link_prefix ? (const char*)link_prefix : "", - link, permalink_macro ? (char*)permalink_macro : "", - formatted_date); + link, ext_in_permalink ? timestamp_output_ext : "", + permalink_macro ? (char*)permalink_macro : "", formatted_date); output_firstcol = 1; process_timestamp_cleanup: @@ -2613,10 +2613,10 @@ begin_article(FILE* output, const char* source_filename, const u8* link_prefix, if (permalink_url) process_timestamp(output, link_prefix, permalink_url, - permalink_macro, date); + permalink_macro, date, ext_in_permalink); else process_timestamp(output, link_prefix, link, - permalink_macro, date); + permalink_macro, date, ext_in_permalink); free(link); } @@ -3746,7 +3746,7 @@ do_line: break; } - if ((IN(state, ST_TAG)) && *(pline - 1) == '{') + if ((IN(state, ST_TAG)) && pline != line && *(pline - 1) == '{') { end_tag = 1; pline++;