diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2022-11-05 16:00:01 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2022-11-06 01:14:25 +0100 |
commit | b6fbcac6f6933858db53a54e7505ff3a83465960 (patch) | |
tree | eaf61bdd00690c06eee00005852ff944f81d7258 /i18npool | |
parent | 7533d93cdcf3b6076275167b53450a1cbde045a7 (diff) |
-Werror,-Wdeprecated-declarations (sprintf, macOS 13 SDK): i18npool
Change-Id: Id5c9892df6dd3f4e66098a312a79e91bd6b9e8ea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142328
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'i18npool')
-rw-r--r-- | i18npool/source/calendar/calendar_gregorian.cxx | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/i18npool/source/calendar/calendar_gregorian.cxx b/i18npool/source/calendar/calendar_gregorian.cxx index 53fe9b1c70bd..e586470a0c31 100644 --- a/i18npool/source/calendar/calendar_gregorian.cxx +++ b/i18npool/source/calendar/calendar_gregorian.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/i18n/NativeNumberMode.hpp> #include <com/sun/star/i18n/reservedWords.hpp> #include <cppuhelper/supportsservice.hxx> +#include <o3tl/sprintf.hxx> #include <rtl/math.hxx> #include <sal/log.hxx> @@ -926,24 +927,31 @@ Calendar_gregorian::getDisplayStringImpl( sal_Int32 nCalendarDisplayCode, sal_In // The "#100211# - checked" comments serve for detection of "use of // sprintf is safe here" conditions. An sprintf encountered without // having that comment triggers alarm ;-) - char aStr[12]; // "-2147483648" and \0 switch( nCalendarDisplayCode ) { case CalendarDisplayCode::SHORT_MONTH: value += 1; // month is zero based [[fallthrough]]; case CalendarDisplayCode::SHORT_DAY: - sprintf(aStr, "%" SAL_PRIdINT32, value); // #100211# - checked + aOUStr = OUString::number(value); break; case CalendarDisplayCode::LONG_YEAR: if ( aCalendar.Name == "gengou" ) - sprintf(aStr, "%02" SAL_PRIdINT32, value); // #100211# - checked + { + char aStr[12]; // "-2147483648" and \0 + o3tl::sprintf(aStr, "%02" SAL_PRIdINT32, value); // #100211# - checked + aOUStr = OUString::createFromAscii(aStr); + } else - sprintf(aStr, "%" SAL_PRIdINT32, value); // #100211# - checked + aOUStr = OUString::number(value); break; case CalendarDisplayCode::LONG_MONTH: - value += 1; // month is zero based - sprintf(aStr, "%02" SAL_PRIdINT32, value); // #100211# - checked - break; + { + value += 1; // month is zero based + char aStr[12]; // "-2147483648" and \0 + o3tl::sprintf(aStr, "%02" SAL_PRIdINT32, value); // #100211# - checked + aOUStr = OUString::createFromAscii(aStr); + break; + } case CalendarDisplayCode::SHORT_YEAR: // Take last 2 digits, or only one if value<10, for example, // in case of the Gengou calendar. For combined era+year always @@ -957,13 +965,21 @@ Calendar_gregorian::getDisplayStringImpl( sal_Int32 nCalendarDisplayCode, sal_In // the only calendar using this. // See i#116701 and fdo#60915 if (value < 100 || bEraMode || (eraArray && (eraArray[0].flags & kDisplayEraForcedLongYear))) - sprintf(aStr, "%" SAL_PRIdINT32, value); // #100211# - checked + aOUStr = OUString::number(value); else - sprintf(aStr, "%02" SAL_PRIdINT32, value % 100); // #100211# - checked + { + char aStr[12]; // "-2147483648" and \0 + o3tl::sprintf(aStr, "%02" SAL_PRIdINT32, value % 100); // #100211# - checked + aOUStr = OUString::createFromAscii(aStr); + } break; case CalendarDisplayCode::LONG_DAY: - sprintf(aStr, "%02" SAL_PRIdINT32, value); // #100211# - checked - break; + { + char aStr[12]; // "-2147483648" and \0 + o3tl::sprintf(aStr, "%02" SAL_PRIdINT32, value); // #100211# - checked + aOUStr = OUString::createFromAscii(aStr); + break; + } case CalendarDisplayCode::SHORT_DAY_NAME: return getDisplayName(CalendarDisplayIndex::DAY, value, 0); @@ -1005,7 +1021,6 @@ Calendar_gregorian::getDisplayStringImpl( sal_Int32 nCalendarDisplayCode, sal_In default: throw RuntimeException(); } - aOUStr = OUString::createFromAscii(aStr); } // NatNum12 used only for selected parts if (nNativeNumberMode > 0 && nNativeNumberMode != 12) { |