чување 6738172ac3c67a91bbef34d82e618152fa9d67c2
родитељ 2dae7d1ec7e366980e886c170d2c7f270c782d6c
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Sun, 25 Jun 2023 18:49:55 +0200
Bugfix: u32_char_to_u8 was assigning to to[len-1] instead of to[i] in loop
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
измењених датотека: 5, додавања: 4(+), брисања: 6(-)
diff --git a/TODO b/TODO
@@ -1,9 +1,10 @@
TODO
====
-[ ] Check UTF character handling (0x201E, 0x201F etc. quotes)
+[x] Check UTF character handling (0x201E, 0x201F etc. quotes)
Example:
for i in $(seq 100); do
printf "\u201etest\u201f test test testtest "
done | ufold -s -w 80
should output double quotes, but the output is messed up
+ - It was a bug in u32_char_to_u8
diff --git a/defs.h b/defs.h
@@ -5,4 +5,3 @@
#define MAXPATH 1024
#define MAX(a,b) ((a) > (b)) ? (a) : (b)
#define MIN(a,b) ((a) < (b)) ? (a) : (b)
-
diff --git a/ufold.c b/ufold.c
@@ -24,7 +24,7 @@ usage()
}
int
-error(int code, char* fmt, ...)
+error(const int code, const char* fmt, ...)
{
char buf[MAXBUF];
va_list args;
diff --git a/utf8.c b/utf8.c
@@ -103,7 +103,7 @@ u32_char_to_u8(u8 *to, const u32 from)
}
for (int i = len-1; i > 0; i--)
{
- to[len-1] = STARTR | (cfrom & XMASKR);
+ to[i] = STARTR | (cfrom & XMASKR);
cfrom >>= 6;
}
to[0] = start | cfrom;
@@ -158,4 +158,3 @@ u32_strlen(const u32* s)
ps++;
return ps - s;
}
-
diff --git a/utf8.h b/utf8.h
@@ -37,4 +37,3 @@ size_t u32_char_to_u8(u8* to, const u32 from);
int u8_to_u32(u32* to, const u8* from, size_t* from_delta);
size_t u32_to_u8(u8* to, const u32* from);
size_t u32_strlen(const u32* s);
-