Skip to content

Commit 1cc90d2

Browse files
committed
Minor fixes for the last commits
* src/fns.c (Fbase64url_encode_region) (Fbase64url_encode_string, Fbase64_decode_region) (Fbase64_decode_string): Fix doc strings. (base64_decode_1): Minor stylistic code changes. * doc/lispref/text.texi (Base 64): Fix typos and improve wording of the last committed text.
1 parent 468e7fb commit 1cc90d2

File tree

2 files changed

+28
-46
lines changed

2 files changed

+28
-46
lines changed

doc/lispref/text.texi

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4541,7 +4541,7 @@ Internet informational document describing a standard. RFCs are
45414541
usually written by technical experts acting on their own initiative,
45424542
and are traditionally written in a pragmatic, experience-driven
45434543
manner.
4544-
}2045 and also in RFC4648. This section describes the functions for
4544+
}2045 and also in RFC 4648. This section describes the functions for
45454545
converting to and from this code.
45464546

45474547
@deffn Command base64-encode-region beg end &optional no-line-break
@@ -4559,19 +4559,13 @@ the output is just one long line.
45594559
@end deffn
45604560

45614561
@deffn Command base64url-encode-region beg end &optional no-pad
4562-
This function converts the region from @var{beg} to @var{end} into base
4563-
64 code. It returns the length of the encoded text. An error is
4564-
signaled if a character in the region is multibyte, i.e., in a
4565-
multibyte buffer the region must contain only characters from the
4566-
charsets @code{ascii}, @code{eight-bit-control} and
4567-
@code{eight-bit-graphic}.
4568-
4569-
Contrary to the function @code{base64-encode-region}, this function
4570-
doesnt inserts newline characters into the encoded text, so the output
4571-
is just one long line.
4562+
This function is like @code{base64-encode-region}, but it implements
4563+
the URL variant if base 64 encoding, per RFC 4648, and it doesn't
4564+
inserts newline characters into the encoded text, so the output is
4565+
just one long line.
45724566

4573-
If the optional argument @var{no-pad} is non-@code{nil} then padding
4574-
(@code{=}) isn't generated.
4567+
If the optional argument @var{no-pad} is non-@code{nil} then this
4568+
function doesn't generate the padding (@code{=}).
45754569
@end deffn
45764570

45774571
@defun base64-encode-string string &optional no-line-break
@@ -4587,17 +4581,12 @@ the result string is just one long line.
45874581
@end defun
45884582

45894583
@defun base64url-encode-string string &optional no-pad
4590-
This function converts the string @var{string} into base 64 url code
4591-
(see RFC4648). It returns a string containing the encoded text. As
4592-
for @code{base64url-encode-region}, an error is signaled if a
4593-
character in the string is multibyte.
4584+
Like @code{base64-encode-string}, but generates the URL variant of
4585+
base 64, and doesn't insert newline characters into the encoded text,
4586+
so the result is just one long line.
45944587

4595-
Contrary to @code{base64-encode-string}, this function doesnt inserts
4596-
newline characters into the encoded text, so the result string is just
4597-
one long line.
4598-
4599-
If the optional argument @var{no-pad} is non-@code{nil} then padding
4600-
(@code{=}) isn't generated.
4588+
If the optional argument @var{no-pad} is non-@code{nil} then this
4589+
function doesn't generate the padding.
46014590
@end defun
46024591

46034592
@deffn Command base64-decode-region beg end &optional base64url
@@ -4607,8 +4596,8 @@ the decoded text.
46074596

46084597
The decoding functions ignore newline characters in the encoded text.
46094598

4610-
If optional argument @var{base64url} is is non-@code{nil} then padding
4611-
become optionnal and url variant is used (see RFC4648).
4599+
If optional argument @var{base64url} is is non-@code{nil}, then padding
4600+
is optional, and the URL variant of base 64 encoding is used.
46124601
@end deffn
46134602

46144603
@defun base64-decode-string string &optional base64url
@@ -4618,8 +4607,9 @@ decoded text.
46184607

46194608
The decoding functions ignore newline characters in the encoded text.
46204609

4621-
If optional argument @var{base64url} is is non-@code{nil} then padding
4622-
become optionnal and url variant is used (see RFC4648).
4610+
4611+
If optional argument @var{base64url} is is non-@code{nil}, then padding
4612+
is optional, and the URL variant of base 64 encoding is used.
46234613
@end defun
46244614

46254615
@node Checksum/Hash

src/fns.c

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3317,7 +3317,7 @@ DEFUN ("base64url-encode-region", Fbase64url_encode_region, Sbase64url_encode_re
33173317
Return the length of the encoded text.
33183318
Optional second argument NO-PAD means do not add padding char =.
33193319
3320-
This is the variant defined in RFC4648. */)
3320+
This produces the URL variant of base 64 encoding defined in RFC 4648. */)
33213321
(Lisp_Object beg, Lisp_Object end, Lisp_Object no_pad)
33223322
{
33233323
return base64_encode_region_1(beg, end, false, NILP(no_pad), true);
@@ -3396,7 +3396,7 @@ DEFUN ("base64url-encode-string", Fbase64url_encode_string, Sbase64url_encode_st
33963396
doc: /* Base64url-encode STRING and return the result.
33973397
Optional second argument NO-PAD means do not add padding char =.
33983398
3399-
This is the variant defined in RFC4648. */)
3399+
This produces the URL variant of base 64 encoding defined in RFC 4648. */)
34003400
(Lisp_Object string, Lisp_Object no_pad)
34013401
{
34023402

@@ -3553,8 +3553,8 @@ DEFUN ("base64-decode-region", Fbase64_decode_region, Sbase64_decode_region,
35533553
doc: /* Base64-decode the region between BEG and END.
35543554
Return the length of the decoded text.
35553555
If the region can't be decoded, signal an error and don't modify the buffer.
3556-
Optional third argument BASE64URL define if base64Url variant will be used
3557-
see RFC4648. */)
3556+
Optional third argument BASE64URL determines whether to use the URL variant
3557+
of the base 64 encoding, as defined in RFC 4648. */)
35583558
(Lisp_Object beg, Lisp_Object end, Lisp_Object base64url)
35593559
{
35603560
ptrdiff_t ibeg, iend, length, allength;
@@ -3615,9 +3615,9 @@ see RFC4648. */)
36153615

36163616
DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string,
36173617
1, 2, 0,
3618-
doc: /* Base64-decode STRING and return the result
3619-
Optional argument BASE64URL define if base64Url variant will be used
3620-
see RFC4648. */)
3618+
doc: /* Base64-decode STRING and return the result as a string.
3619+
Optional argument BASE64URL determines whether to use the URL variant of
3620+
the base 64 encoding, as defined in RFC 4648. */)
36213621
(Lisp_Object string, Lisp_Object base64url)
36223622
{
36233623
char *decoded;
@@ -3693,13 +3693,9 @@ base64_decode_1 (const char *from, char *to, ptrdiff_t length,
36933693
/* Process third byte of a quadruplet. */
36943694

36953695
if (!base64url)
3696-
{
3697-
READ_QUADRUPLET_BYTE (-1);
3698-
}
3696+
READ_QUADRUPLET_BYTE (-1);
36993697
else
3700-
{
3701-
READ_QUADRUPLET_BYTE (e-to);
3702-
}
3698+
READ_QUADRUPLET_BYTE (e-to);
37033699

37043700
if (c == '=')
37053701
{
@@ -3724,13 +3720,9 @@ base64_decode_1 (const char *from, char *to, ptrdiff_t length,
37243720
/* Process fourth byte of a quadruplet. */
37253721

37263722
if (!base64url)
3727-
{
3728-
READ_QUADRUPLET_BYTE (-1);
3729-
}
3723+
READ_QUADRUPLET_BYTE (-1);
37303724
else
3731-
{
3732-
READ_QUADRUPLET_BYTE (e-to);
3733-
}
3725+
READ_QUADRUPLET_BYTE (e-to);
37343726

37353727
if (c == '=')
37363728
continue;

0 commit comments

Comments
 (0)