[glib: 1/2] gbase64: Fix documentation for line wrapping lengths
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/2] gbase64: Fix documentation for line wrapping lengths
- Date: Wed, 15 Jan 2020 14:13:35 +0000 (UTC)
commit 8d3c5020740198e7f1456b4ae45ee06681193696
Author: Philip Withnall <withnall endlessm com>
Date: Wed Jan 15 11:05:41 2020 +0000
gbase64: Fix documentation for line wrapping lengths
The implementation has always wrapped at 76 characters, rather than 72,
ever since it was introduced in commit 5cf8f1d4a8 in 2006. At this
stage, it’s probably best to fix the documentation rather than the
implementation.
The likely bug in the implementation is the comparison
```
(++already) >= 19
```
19 × 4 = 76, so it seems like an off-by-one error in the comparison.
What was actually wanted was 18 × 4 = 72.
Thanks to Simon McVittie for the investigation and diagnosis.
Signed-off-by: Philip Withnall <withnall endlessm com>
Fixes: #1997
glib/gbase64.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/glib/gbase64.c b/glib/gbase64.c
index dd7ed20ac..f2d110e2e 100644
--- a/glib/gbase64.c
+++ b/glib/gbase64.c
@@ -76,10 +76,10 @@ static const char base64_alphabet[] =
* be written to it. Due to the way base64 encodes you will need
* at least: (@len / 3 + 1) * 4 + 4 bytes (+ 4 may be needed in case of
* non-zero state). If you enable line-breaking you will need at least:
- * ((@len / 3 + 1) * 4 + 4) / 72 + 1 bytes of extra space.
+ * ((@len / 3 + 1) * 4 + 4) / 76 + 1 bytes of extra space.
*
* @break_lines is typically used when putting base64-encoded data in emails.
- * It breaks the lines at 72 columns instead of putting all of the text on
+ * It breaks the lines at 76 columns instead of putting all of the text on
* the same line. This avoids problems with long lines in the email system.
* Note however that it breaks the lines with `LF` characters, not
* `CR LF` sequences, so the result cannot be passed directly to SMTP
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]