同步操作将从 OpenHarmony-SIG/python 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "Python.h"/* snprintf() wrappers. If the platform has vsnprintf, we use it, else weemulate it in a half-hearted way. Even if the platform has it, we wrapit because platforms differ in what vsnprintf does in case the bufferis too small: C99 behavior is to return the number of characters thatwould have been written had the buffer not been too small, and to setthe last byte of the buffer to 0円. At least MS _vsnprintf returns anegative value instead, and fills the entire buffer with non-0円 data.The wrappers ensure that str[size-1] is always 0円 upon return.PyOS_snprintf and PyOS_vsnprintf never write more than size bytes(including the trailing '0円') into str.If the platform doesn't have vsnprintf, and the buffer size needed toavoid truncation exceeds size by more than 512, Python aborts with aPy_FatalError.Return value (rv):When 0 <= rv < size, the output conversion was unexceptional, andrv characters were written to str (excluding a trailing 0円 byte atstr[rv]).When rv >= size, output conversion was truncated, and a buffer ofsize rv+1 would have been needed to avoid truncation. str[size-1]is 0円 in this case.When rv < 0, "something bad happened". str[size-1] is 0円 in thiscase too, but the rest of str is unreliable. It could be thatan error in format codes was detected by libc, or on platformswith a non-C99 vsnprintf simply that the buffer wasn't big enoughto avoid truncation, or on platforms without any vsnprintf thatPyMem_Malloc couldn't obtain space for a temp buffer.CAUTION: Unlike C99, str != NULL and size > 0 are required.*/intPyOS_snprintf(char *str, size_t size, const char *format, ...){int rc;va_list va;va_start(va, format);rc = PyOS_vsnprintf(str, size, format, va);va_end(va);return rc;}intPyOS_vsnprintf(char *str, size_t size, const char *format, va_list va){int len; /* # bytes written, excluding 0円 */#ifdef HAVE_SNPRINTF#define _PyOS_vsnprintf_EXTRA_SPACE 1#else#define _PyOS_vsnprintf_EXTRA_SPACE 512char *buffer;#endifassert(str != NULL);assert(size > 0);assert(format != NULL);/* We take a size_t as input but return an int. Sanity check* our input so that it won't cause an overflow in the* vsnprintf return value or the buffer malloc size. */if (size > INT_MAX - _PyOS_vsnprintf_EXTRA_SPACE) {len = -666;goto Done;}#ifdef HAVE_SNPRINTFlen = vsnprintf(str, size, format, va);#else/* Emulate it. */buffer = PyMem_MALLOC(size + _PyOS_vsnprintf_EXTRA_SPACE);if (buffer == NULL) {len = -666;goto Done;}len = vsprintf(buffer, format, va);if (len < 0)/* ignore the error */;else if ((size_t)len >= size + _PyOS_vsnprintf_EXTRA_SPACE)Py_FatalError("Buffer overflow in PyOS_snprintf/PyOS_vsnprintf");else {const size_t to_copy = (size_t)len < size ?(size_t)len : size - 1;assert(to_copy < size);memcpy(str, buffer, to_copy);str[to_copy] = '0円';}PyMem_FREE(buffer);#endifDone:if (size > 0)str[size-1] = '0円';return len;#undef _PyOS_vsnprintf_EXTRA_SPACE}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。