чување 5d13cb38f3b4be5db2ef9befda39124195b5db62
родитељ 15481f97f5e70f1fe9e50370391f9426d8a16b12
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Thu, 28 Sep 2023 14:21:31 +0200
Make config.redo behave more like config.mk; synchronize changes to build
scripts and INSTALL from sled; table.c: Use ISO-compatible \033 instead of \e
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
измењених датотека: 7, додавања: 18(+), брисања: 21(-)
diff --git a/.gitignore b/.gitignore
@@ -18,7 +18,6 @@ nohup.out
*.xz
*.png
*.1
-config.redo*
table
table.1
table.html
diff --git a/INSTALL b/INSTALL
@@ -1,7 +1,7 @@
Prerequisites
=============
-* C compiler (GCC-compatible) - ${TABLE_CC:-gcc -g}
+* C compiler defaults in config.redo
* gzip
@@ -24,7 +24,6 @@ if you don't:
Persistent build configuration file
-----------------------------------
-If a file config.redo exists in the build directory, it will be sourced when
-building targets which also accept configuration through environment variables.
-For example, TABLE_CC and PREFIX can be specified in config.redo, eliminating the
-need to pass them with each build.
+The file config.redo will be sourced when building targets which also accept
+configuration through environment variables. For example, CC and PREFIX can be
+specified in config.redo.
diff --git a/config.redo b/config.redo
@@ -0,0 +1,4 @@
+PREFIX=${PREFIX:-/usr/local}
+CC=${CC:-gcc -g -Wall -pedantic -std=c99 -D_POSIX_C_SOURCE=200809L \
+-D_XOPEN_SOURCE=700 -D_DEFAULT_SOURCE}
+STRIP=${STRIP:-:}
diff --git a/default.o.do b/default.o.do
@@ -1,5 +1,3 @@
redo-ifchange $2.c
-if [ -r ./config.redo ]; then
- . ./config.redo
-fi
-${TABLE_CC:-gcc -g} -Wall -std=c99 -o $3 -c $2.c
+. ./config.redo
+${CC} -o $3 -c $2.c
diff --git a/defs.h b/defs.h
@@ -2,16 +2,14 @@
* any later version. Copyright (C) 2020-2023 Страхиња Радић.
* See the file LICENSE for exact copyright and license details. */
-#define _POSIX_C_SOURCE 200809L
-
#include "utf8.h"
#define BUFSIZE 4096
#define SMALL_BUFSIZE 256
-// #define ANSI_SGR_RESET "\e[0m\e[?25h"
-#define ANSI_SGR_BOLD_ON "\e[1m"
-#define ANSI_SGR_BOLD_OFF "\e[0m"
+// #define ANSI_SGR_RESET "\033[0m\033[?25h"
+#define ANSI_SGR_BOLD_ON "\033[1m"
+#define ANSI_SGR_BOLD_OFF "\033[0m"
#define MIN(a, b) ((a) < (b) ? (a) : (b))
diff --git a/table.c b/table.c
@@ -398,7 +398,7 @@ skip_while_sgr(const u8* s, size_t* char_delta, int also_print, int whole_string
*char_delta = 0;
while (*ps)
{
- if (*ps != '\e' || *(ps + 1) != '[')
+ if (*ps != '\033' || *(ps + 1) != '[')
{
if (whole_string)
{
@@ -1018,7 +1018,7 @@ do_line:
continue_line:
u8_char_to_u32(&uch, pline, &ch_len);
- if (uch == (u32)L'\e' && *(pline + 1) == '[')
+ if (uch == (u32)L'\033' && *(pline + 1) == '[')
{
in_sgr = 1;
if (!no_ansi)
diff --git a/table.do b/table.do
@@ -1,6 +1,4 @@
-if [ -r ./config.redo ]; then
- . ./config.redo
-fi
+. ./config.redo
for f in *.h.in; do
echo $f | sed -e's/\.in$//g'
done | xargs redo-ifchange
@@ -8,4 +6,5 @@ for f in *.h *.c; do
echo $f
echo $f | sed -e's/\.c$/.o/g'
done | xargs redo-ifchange
-${TABLE_CC:-gcc -g} -Wall -std=c99 -o $3 table.o utf8.o ${LIBS}
+${CC} -o $3 table.o utf8.o ${LIBS}
+${STRIP} $3