From f3eaa1937ad84c722feddc2768a82f872f67ae18 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?=
<41315874+fumiama@users.noreply.github.com>
Date: Fri, 5 Apr 2024 17:17:54 +0900
Subject: [PATCH] fix(release): adapt to cosmopolitan
---
.github/workflows/release.yml | 3 ++-
base1432.c | 7 ++++---
base1464.c | 7 ++++---
base16384.c | 8 +++++++-
4 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 3a53864..978571d 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -14,6 +14,7 @@ jobs:
steps:
- name: Checkout Code
+ id: checkout
uses: actions/checkout@v2
- name: Setup Build Tools
@@ -27,7 +28,7 @@ jobs:
run: |
gcc -g -Os -static -nostdlib -nostdinc -fno-pie -no-pie -mno-red-zone \
-fno-omit-frame-pointer -pg -mnop-mcount -D__cosmopolitan \
- -DBASE16384_VERSION="${{ github.ref }}" -DBASE16384_VERSION_DATE="`date +"%Y%b/%d"`"\
+ -DBASE16384_VERSION=\"${{ steps.checkout.outputs.VERSION }}\" -DBASE16384_VERSION_DATE=\"`date +"%Y%b/%d"`\"\
-o base16384.com.dbg base16384.c file.c base1432.c -fuse-ld=bfd -Wl,-T,ape.lds \
-include cosmopolitan.h crt.o ape.o cosmopolitan.a
objcopy -S -O binary base16384.com.dbg base16384.com
diff --git a/base1432.c b/base1432.c
index eb97e9d..4ce6019 100644
--- a/base1432.c
+++ b/base1432.c
@@ -16,15 +16,16 @@
* along with this program. If not, see .
*/
+#ifndef __cosmopolitan
#include
+#endif
#include "binary.h"
-union remainder {
+typedef union {
uint8_t buf[4];
uint32_t val;
-};
-typedef union remainder remainder;
+} remainder;
int base16384_encode_safe(const char* data, int dlen, char* buf) {
int outlen = dlen / 7 * 8;
diff --git a/base1464.c b/base1464.c
index a754676..0641f05 100644
--- a/base1464.c
+++ b/base1464.c
@@ -16,15 +16,16 @@
* along with this program. If not, see .
*/
+#ifndef __cosmopolitan
#include
+#endif
#include "binary.h"
-union remainder {
+typedef union {
uint8_t buf[8];
uint64_t val;
-};
-typedef union remainder remainder;
+} remainder;
int base16384_encode_safe(const char* data, int dlen, char* buf) {
int outlen = dlen / 7 * 8;
diff --git a/base16384.c b/base16384.c
index eb9102e..05756b2 100644
--- a/base16384.c
+++ b/base16384.c
@@ -45,7 +45,13 @@ static base16384_err_t print_usage() {
#ifndef BASE16384_VERSION_DATE
#define BASE16384_VERSION_DATE "unknown date"
#endif
- fputs("Copyright (c) 2022-2024 Fumiama Minamoto.\nBase16384 "BASE16384_VERSION" ("BASE16384_VERSION_DATE"). Usage:\n", stderr);
+ fputs(
+ "Copyright (c) 2022-2024 Fumiama Minamoto.\nBase16384 "
+ BASE16384_VERSION
+ " ("
+ BASE16384_VERSION_DATE
+ "). Usage:\n", stderr
+ );
fputs("base16384 [-edtn] [inputfile] [outputfile]\n", stderr);
fputs(" -e\t\tencode (default)\n", stderr);
fputs(" -d\t\tdecode\n", stderr);