1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Make service_my_snprintf.h doc *more professional*

Per https://github.com/MariaDB/server/pull/3309#discussion_r1644436461,
it is crucial that services’ headers have reliable and legible docs.
This commit is contained in:
ParadoxV5
2024-06-22 16:11:19 -06:00
committed by Sergei Golubchik
parent b668a960cd
commit 891177418e

View File

@@ -37,43 +37,51 @@
@return a number of bytes written to a buffer *excluding* terminating '\0' @return a number of bytes written to a buffer *excluding* terminating '\0'
@post @note
The syntax of a format string is generally the same: The syntax of a format string is generally the same:
% <flag> <width> <.precision> <length modifier> <format> <format extension> %[<flag>][<length>][.<precision>][<size modifier>]<format>[<format extension>]
where everything but the format is optional. where everything but the <format> is optional.
Two one-character flags are recognized: Two one-character <flags> are recognized:
'0' has the standard zero-padding semantics; '0' has the standard zero-padding semantics;
'-' is parsed, but silently ignored; '-' is parsed, but silently ignored;
Both <width> and <precision> can be specified as numbers or '*'. Both <length> and <precision> are the same as in the standard.
If an asterisk is used, an argument of type int is consumed. They can be specified as integers, or as '*' to consume an int argument.
<length modifier> can be 'l', 'll', or 'z'. <size modifier> can be 'l', 'll', or 'z'.
Supported formats are 's' (null pointer is accepted, printed as "(null)"), Supported <format>s are 's' (null pointer is accepted, printed as "(null)"),
'c', 'd', 'i', 'u', 'x', 'X', 'o', 'p' (works as 0x%x), 'f', and 'g'. 'c', 'd', 'i', 'u', 'x', 'X', 'o', 'p' (works as "0x%x"), 'f', and 'g'.
Standard syntax for positional arguments $n is supported. The '$n' syntax for positional arguments is supported.
Format extensions: Format extensions:
Format 'sQ': quotes the string according to MySQL identifier quoting rules. Format 'sQ'
quotes the string with '`' (backtick)s similar to "`%s`",
but also "escapes" existing '`'s in the string to '``' as in SQL ''''.
Format 'sB': binary buffer, prints exactly <precision> bytes from the Format 'sB'
argument, without stopping at '\0'. The behavior for unspecified <precision> treats the argument as a byte sequence. It reads and prints exactly
is not yet defined. <precision> bytes without terminating on any '\0's in the sequence.
The default <precision> when it's unspecified is not defined.
Format 'uE': takes one integer, prints this integer, space, double quote, Format 'uE'
error message corresponding to this integer errno, double quote. In other words: treats the argument as an errno number. It prints this number, a space,
printf("%uE", n) === printf("%d \"%sT\"", n, strerror(n)) then its corresponding error message in double quotes. In other words:
printf("%uE", n) === printf("%d \"%sT\"", n, strerror(n))
Format 'sT': takes string and print it like s but if the strings should be Format 'sT'
truncated puts "..." at the end. replaces the end of the printed string with "..." if it was truncated.
Format 'sS' and 'uU': prints synonymously as s and u respectively. These two Format 'sS' and 'uU'
escape simple s and u from consuming the following plain text as one of the are synonyms of 's' and 'u' respectively. They are escapes that avoid
above extension suffixes; for example, "Data size: %uUEiB". consuming the following plain char as one of the above extension suffixes.
Example: "Data size: %uUEiB"
Unrecognized and multiple suffixes are not parsed;
for example, both "%sTQ" and "%uQ" will print a literal 'Q'.
*/ */
#ifdef __cplusplus #ifdef __cplusplus
@@ -108,4 +116,3 @@ size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
#define MYSQL_SERVICE_MY_SNPRINTF_INCLUDED #define MYSQL_SERVICE_MY_SNPRINTF_INCLUDED
#endif #endif