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.
This commit is contained in:
Eli Zaretskii 2019-06-08 11:14:31 +03:00
parent 468e7fb5d4
commit 1cc90d21d6
2 changed files with 28 additions and 46 deletions

View file

@ -4541,7 +4541,7 @@ Internet informational document describing a standard. RFCs are
usually written by technical experts acting on their own initiative,
and are traditionally written in a pragmatic, experience-driven
manner.
}2045 and also in RFC4648. This section describes the functions for
}2045 and also in RFC 4648. This section describes the functions for
converting to and from this code.
@deffn Command base64-encode-region beg end &optional no-line-break
@ -4559,19 +4559,13 @@ the output is just one long line.
@end deffn
@deffn Command base64url-encode-region beg end &optional no-pad
This function converts the region from @var{beg} to @var{end} into base
64 code. It returns the length of the encoded text. An error is
signaled if a character in the region is multibyte, i.e., in a
multibyte buffer the region must contain only characters from the
charsets @code{ascii}, @code{eight-bit-control} and
@code{eight-bit-graphic}.
This function is like @code{base64-encode-region}, but it implements
the URL variant if base 64 encoding, per RFC 4648, and it doesn't
inserts newline characters into the encoded text, so the output is
just one long line.
Contrary to the function @code{base64-encode-region}, this function
doesnt inserts newline characters into the encoded text, so the output
is just one long line.
If the optional argument @var{no-pad} is non-@code{nil} then padding
(@code{=}) isn't generated.
If the optional argument @var{no-pad} is non-@code{nil} then this
function doesn't generate the padding (@code{=}).
@end deffn
@defun base64-encode-string string &optional no-line-break
@ -4587,17 +4581,12 @@ the result string is just one long line.
@end defun
@defun base64url-encode-string string &optional no-pad
This function converts the string @var{string} into base 64 url code
(see RFC4648). It returns a string containing the encoded text. As
for @code{base64url-encode-region}, an error is signaled if a
character in the string is multibyte.
Like @code{base64-encode-string}, but generates the URL variant of
base 64, and doesn't insert newline characters into the encoded text,
so the result is just one long line.
Contrary to @code{base64-encode-string}, this function doesnt inserts
newline characters into the encoded text, so the result string is just
one long line.
If the optional argument @var{no-pad} is non-@code{nil} then padding
(@code{=}) isn't generated.
If the optional argument @var{no-pad} is non-@code{nil} then this
function doesn't generate the padding.
@end defun
@deffn Command base64-decode-region beg end &optional base64url
@ -4607,8 +4596,8 @@ the decoded text.
The decoding functions ignore newline characters in the encoded text.
If optional argument @var{base64url} is is non-@code{nil} then padding
become optionnal and url variant is used (see RFC4648).
If optional argument @var{base64url} is is non-@code{nil}, then padding
is optional, and the URL variant of base 64 encoding is used.
@end deffn
@defun base64-decode-string string &optional base64url
@ -4618,8 +4607,9 @@ decoded text.
The decoding functions ignore newline characters in the encoded text.
If optional argument @var{base64url} is is non-@code{nil} then padding
become optionnal and url variant is used (see RFC4648).
If optional argument @var{base64url} is is non-@code{nil}, then padding
is optional, and the URL variant of base 64 encoding is used.
@end defun
@node Checksum/Hash

View file

@ -3317,7 +3317,7 @@ DEFUN ("base64url-encode-region", Fbase64url_encode_region, Sbase64url_encode_re
Return the length of the encoded text.
Optional second argument NO-PAD means do not add padding char =.
This is the variant defined in RFC4648. */)
This produces the URL variant of base 64 encoding defined in RFC 4648. */)
(Lisp_Object beg, Lisp_Object end, Lisp_Object no_pad)
{
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
doc: /* Base64url-encode STRING and return the result.
Optional second argument NO-PAD means do not add padding char =.
This is the variant defined in RFC4648. */)
This produces the URL variant of base 64 encoding defined in RFC 4648. */)
(Lisp_Object string, Lisp_Object no_pad)
{
@ -3553,8 +3553,8 @@ DEFUN ("base64-decode-region", Fbase64_decode_region, Sbase64_decode_region,
doc: /* Base64-decode the region between BEG and END.
Return the length of the decoded text.
If the region can't be decoded, signal an error and don't modify the buffer.
Optional third argument BASE64URL define if base64Url variant will be used
see RFC4648. */)
Optional third argument BASE64URL determines whether to use the URL variant
of the base 64 encoding, as defined in RFC 4648. */)
(Lisp_Object beg, Lisp_Object end, Lisp_Object base64url)
{
ptrdiff_t ibeg, iend, length, allength;
@ -3615,9 +3615,9 @@ see RFC4648. */)
DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string,
1, 2, 0,
doc: /* Base64-decode STRING and return the result
Optional argument BASE64URL define if base64Url variant will be used
see RFC4648. */)
doc: /* Base64-decode STRING and return the result as a string.
Optional argument BASE64URL determines whether to use the URL variant of
the base 64 encoding, as defined in RFC 4648. */)
(Lisp_Object string, Lisp_Object base64url)
{
char *decoded;
@ -3693,13 +3693,9 @@ base64_decode_1 (const char *from, char *to, ptrdiff_t length,
/* Process third byte of a quadruplet. */
if (!base64url)
{
READ_QUADRUPLET_BYTE (-1);
}
READ_QUADRUPLET_BYTE (-1);
else
{
READ_QUADRUPLET_BYTE (e-to);
}
READ_QUADRUPLET_BYTE (e-to);
if (c == '=')
{
@ -3724,13 +3720,9 @@ base64_decode_1 (const char *from, char *to, ptrdiff_t length,
/* Process fourth byte of a quadruplet. */
if (!base64url)
{
READ_QUADRUPLET_BYTE (-1);
}
READ_QUADRUPLET_BYTE (-1);
else
{
READ_QUADRUPLET_BYTE (e-to);
}
READ_QUADRUPLET_BYTE (e-to);
if (c == '=')
continue;