SVNからのミラー

This commit is contained in:
2026-01-06 21:10:07 +09:00
commit c3b25703bf
12 changed files with 488 additions and 0 deletions

2
CHANGELOG.md Normal file
View File

@@ -0,0 +1,2 @@
# 1.0.0 (2024/10)
* 開始

13
LICENSE.txt Normal file
View File

@@ -0,0 +1,13 @@
Copyright © 2018-2024 by 076.moe
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.

101
Makefile Normal file
View File

@@ -0,0 +1,101 @@
UNAME_S != uname -s
UNAME_M != uname -m
OS = ${UNAME_S}
ARCH = ${UNAME_M}
.if ${UNAME_S} == "OpenBSD"
OS = openbsd
.elif ${UNAME_S} == "NetBSD"
OS = netbsd
.elif ${UNAME_S} == "FreeBSD"
OS = freebsd
.elif ${UNAME_S} == "Linux"
OS = linux
.endif
.if ${UNAME_M} == "x86_64"
ARCH = amd64
.endif
NAME = txtconv
UDDUNAME != cat uddu.c | grep "const char \*sofname" | awk '{print $$5}' |\
sed "s/\"//g" | sed "s/;//"
UAAUNAME != cat uaau.c | grep "const char \*sofname" | awk '{print $$5}' |\
sed "s/\"//g" | sed "s/;//"
ADDANAME != cat adda.c | grep "const char \*sofname" | awk '{print $$5}' |\
sed "s/\"//g" | sed "s/;//"
VERSION != cat common.h | grep "const char \*version" | awk '{print $$5}' |\
sed "s/\"//g" | sed "s/;//"
PREFIX = /usr/local
.if ${UNAME_S} == "Linux"
PREFIX = /usr
.elif ${UNAME_S} == "Haiku"
PREFIX = /boot/home/config/non-packaged
.endif
MANPREFIX = ${PREFIX}/share/man
.if ${UNAME_S} == "OpenBSD"
MANPREFIX = ${PREFIX}/man
.elif ${UNAME_S} == "Haiku"
MANPREFIX = ${PREFIX}/documentation/man
.endif
CC = cc
CFLAGS = -Wall -Wextra -O3
LDFLAGS = -static -lc
.if ${UNAME_S} == "Haiku" || ${UNAME_S} == "Darwin" || ${UNAME_S} == "SunOS"\
|| ${UNAME_S} == "Minix"
LDFLAGS = -lc
.endif
all: compile
compile:
${CC} ${CFLAGS} -o uddu uddu.c ${LDFLAGS}
strip uddu
${CC} ${CFLAGS} -o uaau uaau.c ${LDFLAGS}
strip uaau
${CC} ${CFLAGS} -o adda adda.c ${LDFLAGS}
strip adda
clean:
rm -rf uddu uaau adda
dist: compile
mkdir -p ${NAME}-${VERSION} release/src\
release/bin/${VERSION}/${OS}/${ARCH} release/man/${VERSION}
cp -R LICENSE.txt Makefile README.md CHANGELOG.md\
*.1 *.c common.h ${NAME}-${VERSION}
tar zcfv release/src/${NAME}-${VERSION}.tar.gz ${NAME}-${VERSION}
rm -rf ${NAME}-${VERSION}
sed "s/VERSION/${VERSION}/g" < uddu.1 > release/man/${VERSION}/uddu.1
sed "s/VERSION/${VERSION}/g" < uaau.1 > release/man/${VERSION}/uaau.1
sed "s/VERSION/${VERSION}/g" < adda.1 > release/man/${VERSION}/adda.1
cp -R uddu uaau adda release/bin/${VERSION}/${OS}/${ARCH}
install:
mkdir -p ${DESTDIR}${PREFIX}/bin ${DESTDIR}${MANPREFIX}/man1
cp -rf uddu ${DESTDIR}${PREFIX}/bin
cp -rf uaau ${DESTDIR}${PREFIX}/bin
cp -rf adda ${DESTDIR}${PREFIX}/bin
chmod 755 ${DESTDIR}${PREFIX}/bin/uddu
chmod 755 ${DESTDIR}${PREFIX}/bin/uaau
chmod 755 ${DESTDIR}${PREFIX}/bin/adda
sed "s/VERSION/${VERSION}/g" < uddu.1 > ${DESTDIR}${MANPREFIX}/man1/uddu.1
sed "s/VERSION/${VERSION}/g" < uaau.1 > ${DESTDIR}${MANPREFIX}/man1/uaau.1
sed "s/VERSION/${VERSION}/g" < adda.1 > ${DESTDIR}${MANPREFIX}/man1/adda.1
chmod 644 ${DESTDIR}${MANPREFIX}/man1/uddu.1
chmod 644 ${DESTDIR}${MANPREFIX}/man1/uaau.1
chmod 644 ${DESTDIR}${MANPREFIX}/man1/adda.1
uninstall:
rm -rf ${DESTDIR}${PREFIX}/bin/uddu
rm -rf ${DESTDIR}${PREFIX}/bin/uaau
rm -rf ${DESTDIR}${PREFIX}/bin/adda
rm -rf ${DESTDIR}${MANPREFIX}/man1/uddu.1
rm -rf ${DESTDIR}${MANPREFIX}/man1/uaau.1
rm -rf ${DESTDIR}${MANPREFIX}/man1/adda.1
.PHONY: all compile clean dist install uninstall

49
README.md Normal file
View File

@@ -0,0 +1,49 @@
# txconv
## インストールする方法 | Installation
### OpenBSD
```sh
make
doas make install
```
### NetBSD | FreeBSD | Dragonfly BSD
```sh
make
sudo make install
```
### CRUX
```sh
sudo prt-get bmake
bmake
sudo bmake install
```
### Void
```sh
sudo xbps-install bmake
bmake
sudo bmake install
```
### Artix
```sh
sudo pacman -S base-devel bmake
bmake
sudo bmake install
```
### Debian | Devuan | Ubuntu | Linux Mint | PopOS
```sh
sudo apt install -y build-essential bmake git
bmake
sudo bmake install
```
### Fedora | Red Hat | CentOS | Rocky Linux
```sh
sudo dnf install bmake clang
bmake
sudo bmake install
```

12
adda.1 Normal file
View File

@@ -0,0 +1,12 @@
.TH ADDA 1 VERSION
.SH NAME
adda - Amiga/MacOS 9 to DOS, DOS to Amiga/MacOS 9
.br
.B adda
[-s]
.SH DESCRIPTION
.PP
Amiga/MacOS 9 to DOS, DOS to Amiga/MacOS 9
.SH AUTHORS
.PP
テクニカル諏訪子(開発者)

102
adda.c Normal file
View File

@@ -0,0 +1,102 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
const char *sofname = "adda";
const char *syoumei = "Amiga/MacOS 9 to DOS, DOS to Amiga/MacOS 9";
void amiga_to_dos(FILE *in, FILE *out) {
int c;
while ((c = fgetc(in)) != EOF) {
if (c != '\r') {
fputc(c, out);
}
if ((c = fgetc(in)) != '\n') {
fputc('\r', out);
fputc('\n', out);
ungetc(c, in);
} else {
fputc('\r', out);
fputc('\n', out);
}
}
}
void dos_to_amiga(FILE *in, FILE *out) {
int c;
int last_char = '\0';
while ((c = fgetc(in)) != EOF) {
if (last_char == '\r' && c == '\n') continue;
if (last_char != '\r' && c == '\n') fputc('\r', out);
else fputc(c, out);
last_char = c;
}
}
int detect_line_ending(FILE *in) {
int c;
int islf = 0;
int iscr = 0;
while ((c = fgetc(in)) != EOF) {
if (c == '\r') iscr = 1;
if (c == '\n') islf = 1;
}
if (iscr && islf) return 1; // DOS
return 0; // Amiga
}
void usage() {
fprintf(stderr, "%s-%s\n%s\n", sofname, version, syoumei);
fprintf(stderr, "usage: %s <ファイル.txt>\n", sofname);
}
int main(int argc, char *argv[]) {
if (argc != 2) {
usage();
return 1;
}
FILE *in = fopen(argv[1], "r");
if (in == NULL) {
perror("fopen input");
usage();
return 1;
}
FILE *tmp = fopen("tmp.txt", "w");
if (tmp == NULL) {
perror("fopen tmp");
fclose(in);
usage();
return 1;
}
int line_ending_style = detect_line_ending(in);
rewind(in);
if (line_ending_style == 0) { // AMIGA
amiga_to_dos(in, tmp);
} else { // DOS
dos_to_amiga(in, tmp);
}
fclose(in);
fclose(tmp);
if (remove(argv[1]) != 0) {
perror("元のファイルの削除");
usage();
return 1;
}
if (rename("tmp.txt", argv[1]) != 0) {
perror("tmpファイル名の変更");
usage();
return 1;
}
return 0;
}

6
common.h Normal file
View File

@@ -0,0 +1,6 @@
#ifndef COMMON_H
#define COMMON_H
const char *version = "1.0.0";
#endif

2
test.txt Normal file
View File

@@ -0,0 +1,2 @@
manco
pussy

12
uaau.1 Normal file
View File

@@ -0,0 +1,12 @@
.TH UAAU 1 VERSION
.SH NAME
uaau - Unix/BeOS/Plan9 to Amiga/MacOS 9, Amiga/MacOS 9 to Unix/BeOS/Plan9
.br
.B uaau
[-s]
.SH DESCRIPTION
.PP
Unix/BeOS/Plan9 to Amiga/MacOS 9, Amiga/MacOS 9 to Unix/BeOS/Plan9
.SH AUTHORS
.PP
テクニカル諏訪子(開発者)

89
uaau.c Normal file
View File

@@ -0,0 +1,89 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
const char *sofname = "uaau";
const char *syoumei =
"Unix/BeOS/Plan9 to Amiga/MacOS 9, Amiga/MacOS 9 to Unix/BeOS/Plan9";
void unix_to_amiga(FILE *in, FILE *out) {
int c;
while ((c = fgetc(in)) != EOF) {
if (c == '\n') fputc('\r', out);
else fputc(c, out);
}
}
void amiga_to_unix(FILE *in, FILE *out) {
int c;
while ((c = fgetc(in)) != EOF) {
if (c == '\r') fputc('\n', out);
else fputc(c, out);
}
}
int detect_line_ending(FILE *in) {
int c;
int islf = 0;
int iscr = 0;
while ((c = fgetc(in)) != EOF) {
if (c == '\r') iscr = 1;
if (c == '\n') islf = 1;
}
if (iscr && !islf) return 1; // Amiga
return 0; // Unix
}
void usage() {
fprintf(stderr, "%s-%s\n%s\n", sofname, version, syoumei);
fprintf(stderr, "usage: %s <ファイル.txt>\n", sofname);
}
int main(int argc, char *argv[]) {
if (argc != 2) {
usage();
return 1;
}
FILE *in = fopen(argv[1], "r");
if (in == NULL) {
perror("fopen input");
usage();
return 1;
}
FILE *tmp = fopen("tmp.txt", "w");
if (tmp == NULL) {
perror("fopen tmp");
fclose(in);
usage();
return 1;
}
int line_ending_style = detect_line_ending(in);
rewind(in);
if (line_ending_style == 0) { // UNIX
unix_to_amiga(in, tmp);
} else { // AMIGA
amiga_to_unix(in, tmp);
}
fclose(in);
fclose(tmp);
if (remove(argv[1]) != 0) {
perror("元のファイルの削除");
usage();
return 1;
}
if (rename("tmp.txt", argv[1]) != 0) {
perror("tmpファイル名の変更");
usage();
return 1;
}
return 0;
}

12
uddu.1 Normal file
View File

@@ -0,0 +1,12 @@
.TH UDDU 1 VERSION
.SH NAME
uddu - Unix/BeOS/Plan9 to DOS, DOS to Unix/BeOS/Plan9
.br
.B uddu
[-s]
.SH DESCRIPTION
.PP
Unix/BeOS/Plan9 to DOS, DOS to Unix/BeOS/Plan9
.SH AUTHORS
.PP
テクニカル諏訪子(開発者)

88
uddu.c Normal file
View File

@@ -0,0 +1,88 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
const char *sofname = "uddu";
const char *syoumei = "Unix/BeOS/Plan9 to DOS, DOS to Unix/BeOS/Plan9";
void unix_to_dos(FILE *in, FILE *out) {
int c;
while ((c = fgetc(in)) != EOF) {
if (c == '\n') fputc('\r', out);
fputc(c, out);
}
}
void dos_to_unix(FILE *in, FILE *out) {
int c;
while ((c = fgetc(in)) != EOF) {
if (c == '\r') continue;
fputc(c, out);
}
}
int detect_line_ending(FILE *in) {
int c;
int islf = 0;
int iscr = 0;
while ((c = fgetc(in)) != EOF) {
if (c == '\r') iscr = 1;
if (c == '\n') islf = 1;
}
if (iscr && islf) return 1; // DOS
return 0; // Unix
}
void usage() {
fprintf(stderr, "%s-%s\n%s\n", sofname, version, syoumei);
fprintf(stderr, "usage: %s <ファイル.txt>\n", sofname);
}
int main(int argc, char *argv[]) {
if (argc != 2) {
usage();
return 1;
}
FILE *in = fopen(argv[1], "r");
if (in == NULL) {
perror("fopen input");
usage();
return 1;
}
FILE *tmp = fopen("tmp.txt", "w");
if (tmp == NULL) {
perror("fopen tmp");
fclose(in);
usage();
return 1;
}
int line_ending_style = detect_line_ending(in);
rewind(in);
if (line_ending_style == 0) { // UNIX
unix_to_dos(in, tmp);
} else { // DOS
dos_to_unix(in, tmp);
}
fclose(in);
fclose(tmp);
if (remove(argv[1]) != 0) {
perror("元のファイルの削除");
usage();
return 1;
}
if (rename("tmp.txt", argv[1]) != 0) {
perror("tmpファイル名の変更");
usage();
return 1;
}
return 0;
}