資源簡介
可移植的snprintf,遵循C99標準-portable snprintf,comply with C99
代碼片段和文件信息
/*
?*?snprintf.c?-?a?portable?implementation?of?snprintf
?*
?*?AUTHOR
?*???Mark?Martinec??April?1999.
?*
?*???Copyright?1999?Mark?Martinec.?All?rights?reserved.
?*
?*?TERMS?AND?CONDITIONS
?*???This?program?is?free?software;?you?can?redistribute?it?and/or?modify
?*???it?under?the?terms?of?the?“Frontier?Artistic?License“?which?comes
?*???with?this?Kit.
?*
?*???This?program?is?distributed?in?the?hope?that?it?will?be?useful
?*???but?WITHOUT?ANY?WARRANTY;?without?even?the?implied?warranty
?*???of?MERCHANTABILITY?or?FITNESS?FOR?A?PARTICULAR?PURPOSE.
?*???See?the?Frontier?Artistic?License?for?more?details.
?*
?*???You?should?have?received?a?copy?of?the?Frontier?Artistic?License
?*???with?this?Kit?in?the?file?named?LICENSE.txt?.
?*???If?not?I‘ll?be?glad?to?provide?one.
?*
?*?FEATURES
?*?-?careful?adherence?to?specs?regarding?flags?field?width?and?precision;
?*?-?good?performance?for?large?string?handling?(large?format?large
?*???argument?or?large?paddings).?Performance?is?similar?to?system‘s?sprintf
?*???and?in?several?cases?significantly?better?(make?sure?you?compile?with
?*???optimizations?turned?on?tell?the?compiler?the?code?is?strict?ANSI
?*???if?necessary?to?give?it?more?freedom?for?optimizations);
?*?-?return?value?semantics?per?ISO/IEC?9899:1999?(“ISO?C99“);
?*?-?written?in?standard?ISO/ANSI?C?-?requires?an?ANSI?C?compiler.
?*
?*?SUPPORTED?CONVERSION?SPECIFIERS?AND?DATA?TYPES
?*
?*?This?snprintf?only?supports?the?following?conversion?specifiers:
?*?s?c?d?u?o?x?X?p??(and?synonyms:?i?D?U?O?-?see?below)
?*?with?flags:?‘-‘?‘+‘?‘?‘?‘0‘?and?‘#‘.
?*?An?asterisk?is?supported?for?field?width?as?well?as?precision.
?*
?*?Length?modifiers?‘h‘?(short?int)?‘l‘?(long?int)
?*?and?‘ll‘?(long?long?int)?are?supported.
?*?NOTE:
?*???If?macro?SNPRINTF_LONGLONG_SUPPORT?is?not?defined?(default)?the
?*???length?modifier?‘ll‘?is?recognized?but?treated?the?same?as?‘l‘
?*???which?may?cause?argument?value?truncation!?Defining
?*???SNPRINTF_LONGLONG_SUPPORT?requires?that?your?system‘s?sprintf?also
?*???handles?length?modifier?‘ll‘.??long?long?int?is?a?language?extension
?*???which?may?not?be?portable.
?*
?*?Conversion?of?numeric?data?(conversion?specifiers?d?u?o?x?X?p)
?*?with?length?modifiers?(none?or?h?l?ll)?is?left?to?the?system?routine
?*?sprintf?but?all?handling?of?flags?field?width?and?precision?as?well?as
?*?c?and?s?conversions?is?done?very?carefully?by?this?portable?routine.
?*?If?a?string?precision?(truncation)?is?specified?(e.g.?%.8s)?it?is
?*?guaranteed?the?string?beyond?the?specified?precision?will?not?be?referenced.
?*
?*?Length?modifiers?h?l?and?ll?are?ignored?for?c?and?s?conversions?(data
?*?types?wint_t?and?wchar_t?are?not?supported).
?*
?*?The?following?common?synonyms?for?conversion?characters?are?supported:
?*???-?i?is?a?synonym?for?d
?*???-?D?is?a?synonym?for?ld?explicit?length?modifiers?are?ignored
?*???-?U?is?a?synonym?for?lu?explicit?length?modifiers?are?ignored
?*???-?O?is?a?synonym?for?lo?expli
評論
共有 條評論