чување 4bc3ebc820a111063061cd1708b62ac0962890f9
родитељ 509991278a01b7205ec08eb02f43548663a6a2a8
Аутор: Страхиња Радић <sr@strahinja.org>
Датум: Mon, 6 Oct 2025 09:16:05 +0200
Use u32 constant instead of casting wchar_t; update copyright year
Diffstat:
измењених датотека: 7, додавања: 27(+), брисања: 25(-)
diff --git a/README b/README
@@ -12,5 +12,3 @@ How to build/install? See INSTALL.
Example?
$ ufold -s -w 50 LICENSE | less
-
-
diff --git a/defs.h b/defs.h
@@ -1,5 +1,5 @@
/* This program is licensed under the terms of GNU GPL v3 or (at your option)
- * any later version. Copyright (C) 2021-2024 Страхиња Радић.
+ * any later version. Copyright (C) 2021-2025 Страхиња Радић.
* See the file LICENSE for exact copyright and license details. */
#define MAXBUF 1024
diff --git a/ufold.1.in b/ufold.1.in
@@ -1,5 +1,5 @@
.\" This program is licensed under the terms of GNU GPL v3 or (at your option)
-.\" any later version. Copyright (C) 2021-2024 Страхиња Радић.
+.\" any later version. Copyright (C) 2021-2025 Страхиња Радић.
.\" See the file LICENSE for exact copyright and license details.
.Dd %DATE%
.Dt UFOLD 1
@@ -51,7 +51,7 @@ Set output width in glyphs.
.Xr fold 1
.Sh AUTHORS
.An Strahinya Radich Aq Mt contact@strahinja.org ,
-2021\-2024
+2021\-2025
.Sh BUGS
Bugs can be reported using the ticket tracker at:
.Lk https://\:todo.sr.ht/\:~strahinja/\:text-tools
diff --git a/ufold.c b/ufold.c
@@ -1,5 +1,5 @@
/* This program is licensed under the terms of GNU GPL v3 or (at your option)
- * any later version. Copyright (C) 2021-2024 Страхиња Радић.
+ * any later version. Copyright (C) 2021-2025 Страхиња Радић.
* See the file LICENSE for exact copyright and license details. */
#include <errno.h>
@@ -16,10 +16,13 @@
#define COPYRIGHT \
(" This program is licensed under the terms of GNU GPL v3" \
" or (at your option)\n" \
- " any later version. Copyright (C) 2021-2024 Strahinya Radich.\n" \
+ " any later version. Copyright (C) 2021-2025 Strahinya Radich.\n" \
" See the file LICENSE for exact copyright and license " \
"details.")
+const u32 U32_SPACE = (const u32)0x00000020;
+const u32 U32_TAB = (const u32)0x00000009;
+
char filename[MAXPATH];
int
@@ -69,6 +72,16 @@ starts_with(const char* s, const char* with)
void
fold_line_spaces(const u8* line, const int width)
{
+ u32* ptoken = NULL;
+ const u8* pline = line;
+ u32 uch = 0;
+ u32 token[MAXINPUTBUF];
+ u8 u8ch[7];
+ size_t u8ch_len = 0;
+ size_t delta = 0;
+ size_t len = 0;
+ size_t col = 0;
+
if (!line)
return;
@@ -86,15 +99,6 @@ fold_line_spaces(const u8* line, const int width)
* 2.2.2. (if they don't) output token
* 3. go to 1. unless line is exhausted
*/
- const u8* pline = line;
- u32 uch = 0;
- u32 token[MAXINPUTBUF];
- u32* ptoken = NULL;
- u8 u8ch[7];
- size_t u8ch_len = 0;
- size_t delta = 0;
- size_t len = 0;
- size_t col = 0;
*token = 0;
ptoken = token;
@@ -108,7 +112,7 @@ fold_line_spaces(const u8* line, const int width)
pline += len;
/* 2. */
- if (uch == (u32)L' ' || !uch)
+ if (uch == U32_SPACE || !uch)
{
if (ptoken - token > width)
{
@@ -131,7 +135,7 @@ fold_line_spaces(const u8* line, const int width)
return;
u8ch[u8ch_len] = 0;
- if (*ptoken == (u32)L'\t')
+ if (*ptoken == U32_TAB)
delta = 8 - (col % 8);
else
delta = 1;
@@ -140,7 +144,7 @@ fold_line_spaces(const u8* line, const int width)
{
printf("\n");
col = 0;
- if (*ptoken == (u32)'\t')
+ if (*ptoken == U32_TAB)
delta = 8;
else
delta = 1;
@@ -173,7 +177,7 @@ fold_line_spaces(const u8* line, const int width)
return;
u8ch[u8ch_len] = 0;
- if (*ptoken == (u32)L'\t')
+ if (*ptoken == U32_TAB)
delta = 8 - (col % 8);
else
delta = 1;
@@ -221,7 +225,7 @@ fold_line_normal(const u8* line, const int width)
*pu8_char++ = *pline_inner++;
*pu8_char = 0;
- if (uch == (u32)L'\t')
+ if (uch == U32_TAB)
delta = 8 - (col % 8);
else
delta = 1;
@@ -230,7 +234,7 @@ fold_line_normal(const u8* line, const int width)
{
printf("\n");
col = 0;
- if (uch == (u32)L'\t')
+ if (uch == U32_TAB)
delta = 8;
else
delta = 1;
diff --git a/utf8.c b/utf8.c
@@ -1,5 +1,5 @@
/* This program is licensed under the terms of GNU GPL v3 or (at your option)
- * any later version. Copyright (C) 2021-2024 Страхиња Радић.
+ * any later version. Copyright (C) 2021-2025 Страхиња Радић.
* See the file LICENSE for exact copyright and license details. */
#include "utf8.h"
diff --git a/utf8.h b/utf8.h
@@ -1,5 +1,5 @@
/* This program is licensed under the terms of GNU GPL v3 or (at your option)
- * any later version. Copyright (C) 2021-2024 Страхиња Радић.
+ * any later version. Copyright (C) 2021-2025 Страхиња Радић.
* See the file LICENSE for exact copyright and license details. */
#include <stdint.h>
diff --git a/version.h.in b/version.h.in
@@ -1,5 +1,5 @@
/* This program is licensed under the terms of GNU GPL v3 or (at your option)
- * any later version. Copyright (C) 2021-2023 Страхиња Радић.
+ * any later version. Copyright (C) 2021-2025 Страхиња Радић.
* See the file LICENSE for exact copyright and license details. */
#define PROGRAMNAME "ufold"