diff --git a/luna/src/Format.cpp b/luna/src/Format.cpp index 0231b3a2..0080475c 100644 --- a/luna/src/Format.cpp +++ b/luna/src/Format.cpp @@ -192,8 +192,8 @@ static usize to_string(usize value, usize base, char* buf, usize max, bool upper return 1; } do { - int digit = (int)(value % base); - char c = (char)(digit < 10 ? '0' + digit : ((uppercase ? 'A' : 'a') + (digit - 10))); + const int digit = (int)(value % base); + const char c = (char)(digit < 10 ? '0' + digit : ((uppercase ? 'A' : 'a') + (digit - 10))); buf[i++] = c; value /= base; } while (value && i < max); @@ -224,7 +224,7 @@ static Result output_integer(char specifier, conv_state& vstate, format_st if (!(vstate.flags & FLAG_LEFT_ALIGN) && (vstate.flags & FLAG_ZERO_PAD)) // we're padding with zeroes from the beginning { - bool extra_char = + const bool extra_char = negative || ((vstate.flags & FLAG_SIGN) || (vstate.flags & FLAG_BLANK_SIGNED)); // are we adding an extra character after the buffer? if (vstate.width && extra_char) vstate.width--; @@ -291,7 +291,7 @@ static Result va_output_integer(char specifier, conv_state& vstate, format } else { - unsigned char v = (unsigned char)va_arg(ap, unsigned int); + const unsigned char v = (unsigned char)va_arg(ap, unsigned int); return output_integer(specifier, vstate, state, v, false); } } @@ -309,7 +309,7 @@ static Result va_output_integer(char specifier, conv_state& vstate, format } else { - unsigned short v = (unsigned short)va_arg(ap, unsigned int); + const unsigned short v = (unsigned short)va_arg(ap, unsigned int); return output_integer(specifier, vstate, state, v, false); } } @@ -327,7 +327,7 @@ static Result va_output_integer(char specifier, conv_state& vstate, format } else { - unsigned long long v = va_arg(ap, unsigned long long); + const unsigned long long v = va_arg(ap, unsigned long long); return output_integer(specifier, vstate, state, v, false); } } @@ -345,7 +345,7 @@ static Result va_output_integer(char specifier, conv_state& vstate, format } else { - unsigned long v = va_arg(ap, unsigned long); + const unsigned long v = va_arg(ap, unsigned long); return output_integer(specifier, vstate, state, v, false); } } @@ -363,7 +363,7 @@ static Result va_output_integer(char specifier, conv_state& vstate, format } else { - unsigned int v = va_arg(ap, unsigned int); + const unsigned int v = va_arg(ap, unsigned int); return output_integer(specifier, vstate, state, v, false); } } @@ -396,13 +396,13 @@ Result cstyle_format(const char* format, callback_t callback, void* arg, // %[flags][width][.precision][length]conversion flags_t flags = parse_flags(&format); - usize width = parse_width(&format, flags, ap); + const usize width = parse_width(&format, flags, ap); usize precision = parse_precision(&format, flags, ap); parse_length(&format, flags); conv_state vstate = {flags, width, precision}; - char specifier = *format; + const char specifier = *format; format++; if (is_integer_format_specifier(specifier)) @@ -412,7 +412,7 @@ Result cstyle_format(const char* format, callback_t callback, void* arg, } else if (specifier == 'p') { - void* ptr = va_arg(ap, void*); + const void* ptr = va_arg(ap, void*); if (ptr == nullptr) { TRY(start_pad(vstate, state, 5));