mirror of
https://github.com/esp8266/Arduino.git
synced 2025-09-09 18:40:33 +03:00
Migrate from astyle to clang-format (#8464)
This commit is contained in:
committed by
Max Prokhorov
parent
46190b61f1
commit
19b7a29720
@@ -7,29 +7,30 @@ namespace bs
|
||||
class ArduinoIOHelper
|
||||
{
|
||||
public:
|
||||
ArduinoIOHelper(Stream& stream) : m_stream(stream)
|
||||
{
|
||||
}
|
||||
ArduinoIOHelper(Stream& stream) : m_stream(stream) { }
|
||||
|
||||
size_t printf(const char *format, ...)
|
||||
size_t printf(const char* format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
char temp[128];
|
||||
char* buffer = temp;
|
||||
size_t len = vsnprintf(temp, sizeof(temp), format, arg);
|
||||
char temp[128];
|
||||
char* buffer = temp;
|
||||
size_t len = vsnprintf(temp, sizeof(temp), format, arg);
|
||||
va_end(arg);
|
||||
if (len > sizeof(temp) - 1) {
|
||||
if (len > sizeof(temp) - 1)
|
||||
{
|
||||
buffer = new char[len + 1];
|
||||
if (!buffer) {
|
||||
if (!buffer)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
va_start(arg, format);
|
||||
ets_vsnprintf(buffer, len + 1, format, arg);
|
||||
va_end(arg);
|
||||
}
|
||||
len = m_stream.write((const uint8_t*) buffer, len);
|
||||
if (buffer != temp) {
|
||||
len = m_stream.write((const uint8_t*)buffer, len);
|
||||
if (buffer != temp)
|
||||
{
|
||||
delete[] buffer;
|
||||
}
|
||||
return len;
|
||||
@@ -40,16 +41,20 @@ public:
|
||||
size_t len = 0;
|
||||
// Can't use Stream::readBytesUntil here because it can't tell the
|
||||
// difference between timing out and receiving the terminator.
|
||||
while (len < dest_size - 1) {
|
||||
while (len < dest_size - 1)
|
||||
{
|
||||
int c = m_stream.read();
|
||||
if (c < 0) {
|
||||
if (c < 0)
|
||||
{
|
||||
delay(1);
|
||||
continue;
|
||||
}
|
||||
if (c == '\r') {
|
||||
if (c == '\r')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (c == '\n') {
|
||||
if (c == '\n')
|
||||
{
|
||||
dest[len] = 0;
|
||||
break;
|
||||
}
|
||||
@@ -64,10 +69,11 @@ protected:
|
||||
|
||||
typedef ArduinoIOHelper IOHelper;
|
||||
|
||||
inline void fatal() {
|
||||
inline void fatal()
|
||||
{
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
} // namespace bs
|
||||
} // namespace bs
|
||||
|
||||
#endif //BS_ARDUINO_H
|
||||
#endif // BS_ARDUINO_H
|
||||
|
Reference in New Issue
Block a user