some light cleanup of source files - iomenu - interactive terminal-based selection menu HTML git clone git://bitreich.org/iomenu git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/iomenu DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit dd61b7694b37cbd012413d7903a9daa1247d242c DIR parent 774936ea25643995d42c2ca1cd7052875fc35573 HTML Author: Josuah Demangeon <me@josuah.net> Date: Fri, 16 Jul 2021 00:02:28 +0200 some light cleanup of source files Diffstat: M Makefile | 19 +++++++------------ M compat.c | 4 +--- M compat.h | 15 +++++++-------- M term.c | 4 ++-- M term.h | 13 +++++++------ M utf8.c | 1 - M utf8.h | 3 +-- D wcwidth.h | 13 ------------- 8 files changed, 25 insertions(+), 47 deletions(-) --- DIR diff --git a/Makefile b/Makefile @@ -1,21 +1,16 @@ NAME = iomenu VERSION = 0.1 +CFLAGS = -DVERSION='"${VERSION}"' -I./src -Wall -Wextra -std=c99 --pedantic -g +LDFLAGS = -static +PREFIX = /usr/local +MANPREFIX = ${PREFIX}/man + SRC = utf8.c compat.c wcwidth.c term.c -HDR = utf8.h compat.h wcwidth.h term.h +HDR = utf8.h compat.h term.h OBJ = ${SRC:.c=.o} BIN = iomenu -MAN1 = ${BIN:=.1} -LIB = - -W = -Wall -Wextra -std=c99 --pedantic -I = -I./src -L = -D = -DVERSION='"${VERSION}"' -CFLAGS = $I $D $W -g -LDFLAGS = $L -static -PREFIX = /usr/local -MANPREFIX = ${PREFIX}/man +MAN1 = iomenu.1 all: ${BIN} DIR diff --git a/compat.c b/compat.c @@ -1,10 +1,8 @@ +#include "compat.h" #include <ctype.h> #include <stddef.h> - #include <string.h> -#include "compat.h" - char * strcasestr(const char *str1, const char *str2) { DIR diff --git a/compat.h b/compat.h @@ -6,13 +6,12 @@ #define wcwidth(c) mk_wcwidth_cjk(c) -/** src/compat/?*.c **/ -char * strcasestr(const char *str1, const char *str2); -size_t strlcpy(char *buf, char const *str, size_t sz); -char * strsep(char **str_p, char const *sep); -int mk_wcwidth(wchar_t ucs); -int mk_wcswidth(const wchar_t *pwcs, size_t n); -int mk_wcwidth_cjk(wchar_t ucs); -int mk_wcswidth_cjk(const wchar_t *pwcs, size_t n); +char *strcasestr(const char *str1, const char *str2); +size_t strlcpy(char *buf, char const *str, size_t sz); +char *strsep(char **str_p, char const *sep); +int mk_wcwidth(wchar_t ucs); +int mk_wcswidth(const wchar_t *pwcs, size_t n); +int mk_wcwidth_cjk(wchar_t ucs); +int mk_wcswidth_cjk(const wchar_t *pwcs, size_t n); #endif DIR diff --git a/term.c b/term.c @@ -7,10 +7,10 @@ #include <sys/ioctl.h> #include <termios.h> -#include "wcwidth.h" +#include "compat.h" #include "utf8.h" -struct term term = {0}; +struct term term; static int term_codepoint_width(uint32_t codepoint, int pos) DIR diff --git a/term.h b/term.h @@ -28,11 +28,12 @@ struct term { struct termios old_termios; }; -struct term term; -int term_width_at_pos(uint32_t codepoint, int pos); -int term_at_width(char const *s, int width, int pos); -int term_raw_on(int fd); -int term_raw_off(int fd); -int term_get_key(FILE *fp); +extern struct term term; + +int term_width_at_pos(uint32_t codepoint, int pos); +int term_at_width(char const *s, int width, int pos); +int term_raw_on(int fd); +int term_raw_off(int fd); +int term_get_key(FILE *fp); #endif DIR diff --git a/utf8.c b/utf8.c @@ -1,5 +1,4 @@ #include "utf8.h" - #include <stddef.h> #include <stdint.h> DIR diff --git a/utf8.h b/utf8.h @@ -9,8 +9,7 @@ enum { UTF8_REJECT, }; -/** src/utf8.c **/ -size_t utf8_encode(char *dest, uint32_t u); +size_t utf8_encode(char *dest, uint32_t u); uint32_t utf8_decode(uint32_t *state, uint32_t *codep, uint32_t byte); #endif DIR diff --git a/wcwidth.h b/wcwidth.h @@ -1,13 +0,0 @@ -#ifndef WCWIDTH_H -#define WCWIDTH_H - -#include <wchar.h> - -#define wcwidth(c) mk_wcwidth_cjk(c) - -int mk_wcwidth(wchar_t ucs); -int mk_wcswidth(const wchar_t *pwcs, size_t n); -int mk_wcwidth_cjk(wchar_t ucs); -int mk_wcswidth_cjk(const wchar_t *pwcs, size_t n); - -#endif