Skip to content
Merged
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
69 changes: 69 additions & 0 deletions .github/workflows/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,72 @@ jobs:
with:
name: cygwin-packages
path: artifacts/cygwin/

release:
name: GitHub Release
needs: [debian, rpm, homebrew, freebsd, cygwin]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout source
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
fetch-depth: 0

- name: Download Debian packages
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372ec806872 # v4
with:
name: debian-packages
path: release-artifacts

- name: Download RPM packages
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372ec806872 # v4
with:
name: rpm-packages
path: release-artifacts

- name: Download Homebrew bottle
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372ec806872 # v4
with:
name: homebrew-bottle
path: release-artifacts

- name: Download FreeBSD package
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372ec806872 # v4
with:
name: freebsd-package
path: release-artifacts

- name: Download Cygwin packages
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372ec806872 # v4
with:
name: cygwin-packages
path: release-artifacts

- name: Generate release version and source archive
id: release_info
run: |
# Determine the fork version name
TAG_NAME="${{ github.ref_name }}"
FORK_VERSION="kruton-${TAG_NAME#v}"
echo "fork_version=${FORK_VERSION}" >> "$GITHUB_OUTPUT"

# Generate source tarball containing fork_version.txt
chmod +x packaging/make-source-archive.sh
packaging/make-source-archive.sh \
--prefix "tinyfugue-${FORK_VERSION}" \
"release-artifacts/tinyfugue-${FORK_VERSION}.tar.gz"

- name: Create Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Find all files to upload
files=$(find release-artifacts -type f)
gh release create "${{ github.ref_name }}" \
--title "${{ steps.release_info.outputs.fork_version }}" \
--notes "Automated release of TinyFugue fork version ${{ steps.release_info.outputs.fork_version }}" \
$files
40 changes: 39 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,44 @@ project(tinyfugue VERSION 5.0.8 LANGUAGES C)
set(TF_VERSION_SHORT "50b8")
set(TF_VERSION_STRING "TinyFugue version 5.0 beta 8")

# Custom Release Versioning System
set(TF_FORK_VERSION_DEFAULT "")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/fork_version.txt")
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/fork_version.txt" TF_FORK_VERSION_DEFAULT)
string(STRIP "${TF_FORK_VERSION_DEFAULT}" TF_FORK_VERSION_DEFAULT)
else()
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --exact-match --match "v*"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
if(GIT_TAG MATCHES "^v")
string(REGEX REPLACE "^v" "kruton-" TF_FORK_VERSION_DEFAULT "${GIT_TAG}")
else()
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
if(GIT_COMMIT_HASH)
set(TF_FORK_VERSION_DEFAULT "kruton-dev-g${GIT_COMMIT_HASH}")
endif()
endif()
endif()
endif()

if(NOT TF_FORK_VERSION_DEFAULT)
set(TF_FORK_VERSION_DEFAULT "kruton-dev")
endif()

set(TF_FORK_VERSION "${TF_FORK_VERSION_DEFAULT}" CACHE STRING "Fork release version")

list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")

include(GNUInstallDirs)
Expand Down Expand Up @@ -100,7 +138,7 @@ if(TF_EXTRA_LIBRARY_DIRS)
list(APPEND CMAKE_REQUIRED_LINK_DIRECTORIES ${TF_EXTRA_LIBRARY_DIRS})
endif()

message(STATUS "Configuring ${TF_VERSION_STRING}")
message(STATUS "Configuring ${TF_VERSION_STRING} (Fork: ${TF_FORK_VERSION})")

if(TF_CORE)
set(DISABLE_CORE 0)
Expand Down
19 changes: 18 additions & 1 deletion packaging/make-source-archive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ esac
mkdir -p "$(dirname "$output")"
tmp="${output}.tmp.$$"
tmp_tar="${output}.tar.tmp.$$"
trap 'rm -f "$tmp" "$tmp_tar"' EXIT HUP INT TERM
tmp_dir=
trap 'rm -f "$tmp" "$tmp_tar"; if [ -n "$tmp_dir" ]; then rm -rf "$tmp_dir"; fi' EXIT HUP INT TERM

if $exclude_debian; then
git -c "safe.directory=$repo" -C "$repo" archive \
Expand All @@ -56,6 +57,22 @@ else
--format=tar --prefix="${prefix}/" \
--output="$tmp_tar" HEAD
fi

# Determine the fork version to write
if git -c "safe.directory=$repo" -C "$repo" describe --tags --exact-match --match "v*" >/dev/null 2>&1; then
GIT_TAG=$(git -c "safe.directory=$repo" -C "$repo" describe --tags --exact-match --match "v*")
FORK_VERSION="kruton-${GIT_TAG#v}"
else
GIT_COMMIT_HASH=$(git -c "safe.directory=$repo" -C "$repo" rev-parse --short HEAD)
FORK_VERSION="kruton-dev-g${GIT_COMMIT_HASH}"
fi

# Append fork_version.txt to the tarball under the prefix directory
tmp_dir=$(mktemp -d "${TMPDIR:-/tmp}/tinyfugue-archive.XXXXXX")
mkdir -p "${tmp_dir}/${prefix}"
echo "${FORK_VERSION}" > "${tmp_dir}/${prefix}/fork_version.txt"
tar -C "$tmp_dir" -rf "$tmp_tar" "${prefix}/fork_version.txt"

gzip -n <"$tmp_tar" >"$tmp"
mv "$tmp" "$output"
rm -f "$tmp_tar"
Expand Down
11 changes: 10 additions & 1 deletion src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static void split_args(char *args);
static BuiltinCmd cmd_table[] =
{
#define defcmd(name, func, reserved) \
{ name, func, reserved },
{ name, func, reserved, NULL },
#include "cmdlist.h"
};

Expand Down Expand Up @@ -266,13 +266,18 @@ struct Value *handle_sh_command(String *args, int offset)

struct Value *handle_suspend_command(String *args, int offset)
{
(void)args;
(void)offset;
return newint(suspend());
}

struct Value *handle_version_command(String *args, int offset)
{
(void)args;
(void)offset;
oprintf("%% %s.", version);
oprintf("%% %s.", copyright);
if (*fork_version) oprintf("%% Fork version: %s.", fork_version);
if (*contrib) oprintf("%% %s", contrib);
if (*mods) oprintf("%% %s", mods);
if (*sysname) oprintf("%% Built for %s", sysname);
Expand Down Expand Up @@ -458,6 +463,8 @@ struct Value *handle_relimit_command(String *args, int offset)
Screen *screen = display_screen;
Value *result = val_one;

(void)args;
(void)offset;
if (!enable_screen_filter(screen)) {
alert(limit_none);
result = val_zero;
Expand All @@ -473,6 +480,8 @@ struct Value *handle_unlimit_command(String *args, int offset)
{
Screen *screen = display_screen;

(void)args;
(void)offset;
if (!screen_has_filter(screen))
return shareval(val_zero);
clear_screen_filter(screen);
Expand Down
7 changes: 6 additions & 1 deletion src/dstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ String *dSinit(
const char *file,
int line)
{
#if !USE_MMALLOC
(void)md;
#endif
if (data && len < 0)
len = strlen(data);
if (!str) {
Expand All @@ -123,7 +126,9 @@ String *dSinit(
if (!md || !str)
#endif
{
#if USE_MMALLOC
md = NULL;
#endif
str = xmalloc(NULL, sizeof(*str) + len + 1, file, line);
}
str->data = (char*)str + sizeof(*str);
Expand Down Expand Up @@ -236,7 +241,7 @@ String *dSnadd(String *str, int c, int n, const char *file, int line)
String *dStrunc(String *str, int len, const char *file, int line)
{
/* if (str->size && str->len < len) return str; */
unsigned int oldlen = str->len;
int oldlen = str->len;
str->len = len;
lcheck(str, file, line);
if (len <= oldlen) {
Expand Down
2 changes: 1 addition & 1 deletion src/expand.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ Value *prog_interpret(const Program *prog, int in_expr)
constr = blankline;
if (patmatch(&looks_like_special_sub_ic, NULL, val->name)) {
char upper[64];
int i;
size_t i;
for (i = 0; i < sizeof(upper) && val->name[i]; i++)
upper[i] = ucase(val->name[i]);
tfwprintf("\"%%{%s}\" is a variable substitution, "
Expand Down
2 changes: 1 addition & 1 deletion src/expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static Value *valpool = NULL; /* freelist */

typedef struct ExprFunc {
const char *name; /* name invoked by user */
unsigned min, max; /* allowable argument counts */
int min, max; /* allowable argument counts */
} ExprFunc;

static ExprFunc functab[] = {
Expand Down
2 changes: 2 additions & 0 deletions src/globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const char version[] =
#endif
TF_VERSION_STRING;

const char fork_version[] = TF_FORK_VERSION;

const char mods[] = "";

const char copyright[] =
Expand Down
1 change: 1 addition & 0 deletions src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ enum Vars {
#define TFLIBDIR getstdvar(VAR_TFLIBDIR)
#define TFPATH getstdvar(VAR_TFPATH)
#define TFMAILPATH getstdvar(VAR_TFMAILPATH)
#define TF_FORK_VERSION_VAR getstdvar(VAR_TF_FORK_VERSION)
#define alert_attr getattrvar(VAR_alert_attr)
#define alert_time gettimevar(VAR_alert_time)
#define ansi_log getintvar(VAR_ansi_log)
Expand Down
3 changes: 2 additions & 1 deletion src/macro.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,8 @@ static int macro_match(Macro *spec, Macro *macro, AuxPat *aux)
/* -h0 */
if (macro->flags & MACRO_HOOK) return 0;
} else if (spec->flags & MACRO_HOOK) {
int i, hit = 0;
size_t i;
int hit = 0;
if (!(macro->flags & MACRO_HOOK)) return 0;
for (i = 0; i < sizeof(spec->hook)/sizeof(long); i++) {
if ((hit = (spec->hook.bits[i] & macro->hook.bits[i])))
Expand Down
8 changes: 8 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ int main(int argc, char *argv[])

puts("");
puts(version);
if (*fork_version) {
printf("Fork version: %s\n", fork_version);
}
puts(copyright);

while (--argc > 0 && (*++argv)[0] == '-') {
Expand Down Expand Up @@ -129,6 +132,11 @@ int main(int argc, char *argv[])
init_keyboard(); /* keyboard.c */

oputs(version);
if (*fork_version) {
char buf[128];
snprintf(buf, sizeof(buf), "Fork version: %s", fork_version);
oputs(buf);
}
oputs(copyright);
oputs("Type `/help copyright' for more information.");
if (*contrib) oputs(contrib);
Expand Down
5 changes: 5 additions & 0 deletions src/malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ void *xmalloc(void *md, long unsigned size, const char *file, const int line)
{
void *memory;

(void)md;
if ((long)size <= 0)
core("xmalloc(%ld).", file, line, (long)size);

Expand All @@ -47,6 +48,7 @@ void *xrealloc(void *md, void *ptr, long unsigned size,
{
void *memory;

(void)md;
if ((long)size <= 0)
core("xrealloc(%ld).", file, line, (long)size);

Expand Down Expand Up @@ -76,6 +78,9 @@ void *xcalloc(void *md, long unsigned size, const char *file, const int line)

void xfree(void *md, void *ptr, const char *file, const int line)
{
(void)md;
(void)file;
(void)line;
dfree(md, ptr, file, line);
if (!reserve)
init_malloc();
Expand Down
Loading
Loading