diff --git a/contrib/bash_compl/_rgbasm.bash b/contrib/bash_compl/_rgbasm.bash index 95bde528..b3e25d33 100755 --- a/contrib/bash_compl/_rgbasm.bash +++ b/contrib/bash_compl/_rgbasm.bash @@ -186,7 +186,6 @@ _rgbasm_completions() { empty-macro-arg empty-strrpl large-constant - long-string macro-shift nested-comment numeric-string diff --git a/contrib/zsh_compl/_rgbasm b/contrib/zsh_compl/_rgbasm index 8fa4759f..81a4872b 100644 --- a/contrib/zsh_compl/_rgbasm +++ b/contrib/zsh_compl/_rgbasm @@ -17,7 +17,6 @@ _rgbasm_warnings() { 'empty-macro-arg:Warn on empty macro arg' 'empty-strrpl:Warn on calling STRRPL with empty pattern' 'large-constant:Warn on constants too large for a signed 32-bit int' - 'long-string:Warn on strings too long' 'macro-shift:Warn when shifting macro args part their limits' 'nested-comment:Warn on "/*" inside block comments' 'numeric-string:Warn when a multi-character string is treated as a number' diff --git a/include/asm/lexer.hpp b/include/asm/lexer.hpp index 03bc4df5..00b6096f 100644 --- a/include/asm/lexer.hpp +++ b/include/asm/lexer.hpp @@ -13,8 +13,6 @@ #include "platform.hpp" // SSIZE_MAX -#define MAXSTRLEN 255 - #define LEXER_BUF_SIZE 42 // TODO: determine a sane value for this // The buffer needs to be large enough for the maximum `peekInternal` lookahead distance static_assert(LEXER_BUF_SIZE > 1, "Lexer buffer size is too small"); diff --git a/include/asm/warning.hpp b/include/asm/warning.hpp index 1da67749..dd068e0d 100644 --- a/include/asm/warning.hpp +++ b/include/asm/warning.hpp @@ -19,7 +19,6 @@ enum WarningID { WARNING_EMPTY_MACRO_ARG, // Empty macro argument WARNING_EMPTY_STRRPL, // Empty second argument in `STRRPL` WARNING_LARGE_CONSTANT, // Constants too large - WARNING_LONG_STR, // String too long for internal buffers WARNING_MACRO_SHIFT, // Shift past available arguments in macro WARNING_NESTED_COMMENT, // Comment-start delimiter in a block comment WARNING_OBSOLETE, // Obsolete things diff --git a/man/rgbasm.1 b/man/rgbasm.1 index e8f8f935..f12949e1 100644 --- a/man/rgbasm.1 +++ b/man/rgbasm.1 @@ -266,10 +266,6 @@ This warning is enabled by Warn when a constant too large to fit in a signed 32-bit integer is encountered. This warning is enabled by .Fl Wall . -.It Fl Wlong-string -Warn when a string too long to fit in internal buffers is encountered. -This warning is enabled by -.Fl Wall . .It Fl Wmacro-shift Warn when shifting macro arguments past their limits. This warning is enabled by diff --git a/src/asm/format.cpp b/src/asm/format.cpp index 92ff1191..6b5dc7f3 100644 --- a/src/asm/format.cpp +++ b/src/asm/format.cpp @@ -9,7 +9,6 @@ #include #include "asm/fixpoint.hpp" -#include "asm/lexer.hpp" // MAXSTRLEN #include "asm/warning.hpp" void FormatSpec::useCharacter(int c) { @@ -133,11 +132,6 @@ void FormatSpec::appendString(std::string &str, std::string const &value) const str.append(padLen, ' '); str.append(value); } - - if (str.length() > MAXSTRLEN) { - error("Formatted string value too long\n"); - str.resize(MAXSTRLEN); - } } void FormatSpec::appendNumber(std::string &str, uint32_t value) const { @@ -245,9 +239,4 @@ void FormatSpec::appendNumber(std::string &str, uint32_t value) const { } str.append(valueBuf); } - - if (str.length() > MAXSTRLEN) { - error("Formatted numeric value too long\n"); - str.resize(MAXSTRLEN); - } } diff --git a/src/asm/lexer.cpp b/src/asm/lexer.cpp index 303fa8b9..af4c517b 100644 --- a/src/asm/lexer.cpp +++ b/src/asm/lexer.cpp @@ -1347,11 +1347,6 @@ static std::string readString(bool raw) { } finish: - if (yylval.length() > MAXSTRLEN) { - warning(WARNING_LONG_STR, "String constant too long\n"); - yylval.resize(MAXSTRLEN); - } - lexerState->disableMacroArgs = false; lexerState->disableInterpolation = false; @@ -1495,11 +1490,6 @@ static void appendStringLiteral(std::string &yylval, bool raw) { } finish: - if (yylval.length() > MAXSTRLEN) { - warning(WARNING_LONG_STR, "String constant too long\n"); - yylval.resize(MAXSTRLEN); - } - lexerState->disableMacroArgs = false; lexerState->disableInterpolation = false; } @@ -1933,10 +1923,6 @@ append: } finish: - if (yylval.length() > MAXSTRLEN) { - warning(WARNING_LONG_STR, "Macro argument too long\n"); - yylval.resize(MAXSTRLEN); - } // Trim right whitespace auto rightPos = std::find_if_not(yylval.rbegin(), yylval.rend(), isWhitespace); yylval.resize(rightPos.base() - yylval.begin()); diff --git a/src/asm/parser.y b/src/asm/parser.y index d2feec93..8f32fb96 100644 --- a/src/asm/parser.y +++ b/src/asm/parser.y @@ -1615,10 +1615,6 @@ strcat_args: | strcat_args COMMA string { $$ = std::move($1); $$.append($3); - if ($$.length() > MAXSTRLEN) { - warning(WARNING_LONG_STR, "STRCAT: String too long '%s'\n", $$.c_str()); - $$.resize(MAXSTRLEN); - } } ; @@ -2556,7 +2552,7 @@ static std::string strsubUTF8(std::string const &str, uint32_t pos, uint32_t len uint32_t curLen = 0; // Compute the result length in bytes. - while (ptr[index] && index - startIndex < MAXSTRLEN && curLen < len) { + while (ptr[index] && curLen < len) { switch (decode(&state, &codep, ptr[index])) { case 1: errorInvalidUTF8Byte(ptr[index], "STRSUB"); @@ -2569,7 +2565,6 @@ static std::string strsubUTF8(std::string const &str, uint32_t pos, uint32_t len index++; } - // Check if `index - startIndex == MAXSTRLEN` before `curLen == len`. if (curLen < len) warning(WARNING_BUILTIN_ARG, "STRSUB: Length too big: %" PRIu32 "\n", len); @@ -2641,11 +2636,6 @@ static std::string strrpl(std::string_view str, std::string const &old, std::str str.remove_prefix(pos + old.size()); } - if (rpl.length() > MAXSTRLEN) { - warning(WARNING_LONG_STR, "STRRPL: String too long, got truncated\n"); - rpl.resize(MAXSTRLEN); - } - return rpl; } @@ -2656,7 +2646,7 @@ static std::string strfmt( std::string str; size_t argIndex = 0; - for (size_t i = 0; spec[i] != '\0' && str.length() <= MAXSTRLEN; ++i) { + for (size_t i = 0; spec[i] != '\0'; ++i) { int c = spec[i]; if (c != '%') { @@ -2712,10 +2702,6 @@ static std::string strfmt( argIndex ); - if (str.length() > MAXSTRLEN) { - warning(WARNING_LONG_STR, "STRFMT: String too long, got truncated\n"); - str.resize(MAXSTRLEN); - } return str; } diff --git a/src/asm/warning.cpp b/src/asm/warning.cpp index e2184a23..63a46b5f 100644 --- a/src/asm/warning.cpp +++ b/src/asm/warning.cpp @@ -29,7 +29,6 @@ static const WarningState defaultWarnings[ARRAY_SIZE(warningStates)] = { WARNING_DISABLED, // WARNING_EMPTY_MACRO_ARG WARNING_DISABLED, // WARNING_EMPTY_STRRPL WARNING_DISABLED, // WARNING_LARGE_CONSTANT - WARNING_DISABLED, // WARNING_LONG_STR WARNING_DISABLED, // WARNING_MACRO_SHIFT WARNING_ENABLED, // WARNING_NESTED_COMMENT WARNING_ENABLED, // WARNING_OBSOLETE @@ -77,7 +76,6 @@ static char const * const warningFlags[NB_WARNINGS] = { "empty-macro-arg", "empty-strrpl", "large-constant", - "long-string", "macro-shift", "nested-comment", "obsolete", @@ -157,7 +155,6 @@ static uint8_t const _wallCommands[] = { WARNING_EMPTY_DATA_DIRECTIVE, WARNING_EMPTY_STRRPL, WARNING_LARGE_CONSTANT, - WARNING_LONG_STR, WARNING_NESTED_COMMENT, WARNING_OBSOLETE, WARNING_NUMERIC_STRING_1, @@ -188,7 +185,6 @@ static uint8_t const _weverythingCommands[] = { WARNING_EMPTY_MACRO_ARG, WARNING_EMPTY_STRRPL, WARNING_LARGE_CONSTANT, - WARNING_LONG_STR, WARNING_MACRO_SHIFT, WARNING_NESTED_COMMENT, WARNING_OBSOLETE, diff --git a/test/asm/format-truncation.asm b/test/asm/format-truncation.asm index 4ab82443..30896d99 100644 --- a/test/asm/format-truncation.asm +++ b/test/asm/format-truncation.asm @@ -1,3 +1,5 @@ +; Strings used to be truncated to 255 characters with a warning. + def num equ 42 def fix equ 123.0 def str equs "hello" diff --git a/test/asm/format-truncation.err b/test/asm/format-truncation.err index 41d3ee5c..f583dd1a 100644 --- a/test/asm/format-truncation.err +++ b/test/asm/format-truncation.err @@ -1,35 +1,5 @@ -error: format-truncation.asm(5): - Formatted numeric value too long -error: format-truncation.asm(6): - Formatted numeric value too long -error: format-truncation.asm(7): - Fractional width 260 too long, limiting to 255 -error: format-truncation.asm(7): - Formatted numeric value too long -error: format-truncation.asm(8): - Formatted string value too long error: format-truncation.asm(9): - Formatted string value too long -error: format-truncation.asm(11): - Formatted numeric value too long -warning: format-truncation.asm(11): [-Wlong-string] - String constant too long -error: format-truncation.asm(12): - Formatted numeric value too long -warning: format-truncation.asm(12): [-Wlong-string] - String constant too long -error: format-truncation.asm(13): Fractional width 260 too long, limiting to 255 -error: format-truncation.asm(13): - Formatted numeric value too long -warning: format-truncation.asm(13): [-Wlong-string] - String constant too long -error: format-truncation.asm(14): - Formatted string value too long -warning: format-truncation.asm(14): [-Wlong-string] - String constant too long error: format-truncation.asm(15): - Formatted string value too long -warning: format-truncation.asm(15): [-Wlong-string] - String constant too long -error: Assembly aborted (12 errors)! + Fractional width 260 too long, limiting to 255 +error: Assembly aborted (2 errors)! diff --git a/test/asm/format-truncation.out b/test/asm/format-truncation.out index 6752131d..43fa2377 100644 --- a/test/asm/format-truncation.out +++ b/test/asm/format-truncation.out @@ -1,10 +1,10 @@ -$00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -$2a -000000000000000000000123.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 - -hello -<$0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -<$2a -<000000000000000000000123.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -< - +<$2a > +<000000000000000000000123.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000> +< hello> + diff --git a/test/asm/interpolation-overflow.err b/test/asm/interpolation-overflow.err index 8c5af27f..00cd9976 100644 --- a/test/asm/interpolation-overflow.err +++ b/test/asm/interpolation-overflow.err @@ -1,12 +1,10 @@ error: interpolation-overflow.asm(4): Fractional width 99999999 too long, limiting to 255 -error: interpolation-overflow.asm(4): - Formatted numeric value too long warning: interpolation-overflow.asm(4): [-Wlarge-constant] Precision of fixed-point constant is too large -while expanding symbol "0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" +while expanding symbol "0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" error: interpolation-overflow.asm(4): Macro argument '\1' not defined error: interpolation-overflow.asm(4): syntax error, unexpected number -error: Assembly aborted (4 errors)! +error: Assembly aborted (3 errors)! diff --git a/test/asm/long-format-spec.asm b/test/asm/long-format-spec.asm index a88a1c4f..4363721d 100644 --- a/test/asm/long-format-spec.asm +++ b/test/asm/long-format-spec.asm @@ -1,3 +1,3 @@ DEF n EQU 42 -; the format spec is truncated to "000...009", omitting the "x", so this prints "000000042" not "00000002a" +; the format spec used to be truncated, but not any more PRINTLN "{000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009x:n}" diff --git a/test/asm/long-section-name.asm b/test/asm/long-section-name.asm index 7c4b1f8f..9f0b3825 100644 --- a/test/asm/long-section-name.asm +++ b/test/asm/long-section-name.asm @@ -1,2 +1,2 @@ -SECTION "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit", ROM0[0] +SECTION "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", ROM0[0] println "This is section ", SECTION(@) diff --git a/test/asm/long-section-name.err b/test/asm/long-section-name.err deleted file mode 100644 index 412aa00f..00000000 --- a/test/asm/long-section-name.err +++ /dev/null @@ -1,2 +0,0 @@ -warning: long-section-name.asm(1): [-Wlong-string] - String constant too long diff --git a/test/asm/long-section-name.out b/test/asm/long-section-name.out index cfcbfe54..93fd6af4 100644 --- a/test/asm/long-section-name.out +++ b/test/asm/long-section-name.out @@ -1 +1 @@ -This is section Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor i +This is section Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. diff --git a/test/asm/long-string-constant.asm b/test/asm/long-string-constant.asm index 64380c2e..b489502b 100644 --- a/test/asm/long-string-constant.asm +++ b/test/asm/long-string-constant.asm @@ -1,13 +1,20 @@ -println """This paragraph has exactly 257--that's two hundred and -fifty-seven--characters altogether. That's just enough for its last -two characters to be truncated by rgbasm's lexer, since it can't -handle more than 255-character strings. The final two won't print: !?""" +println """Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium dol- +oremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore verita- +tis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam vol- +uptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur +magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam +est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed +quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam +quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam +corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis +autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil mole- +stiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?""" MACRO mac println "\1" ; x1 - println "\1\1\1\1\1\1" ; x6 + println "\1\1\1\1\1\1\1" ; x7 ENDM - mac Hello! ; 6x6 = 36 - mac This sentence spans forty-three characters. ; 43x6 = 258 + mac Hello! ; 6x7 = 42 + mac This sentence spans forty-three characters. ; 43x7 = 301 diff --git a/test/asm/long-string-constant.err b/test/asm/long-string-constant.err deleted file mode 100644 index b2154e3f..00000000 --- a/test/asm/long-string-constant.err +++ /dev/null @@ -1,4 +0,0 @@ -warning: long-string-constant.asm(5): [-Wlong-string] - String constant too long -warning: long-string-constant.asm(13) -> long-string-constant.asm::mac(9): [-Wlong-string] - String constant too long diff --git a/test/asm/long-string-constant.out b/test/asm/long-string-constant.out index d51bccaa..cd7f1b61 100644 --- a/test/asm/long-string-constant.out +++ b/test/asm/long-string-constant.out @@ -1,8 +1,15 @@ -This paragraph has exactly 257--that's two hundred and -fifty-seven--characters altogether. That's just enough for its last -two characters to be truncated by rgbasm's lexer, since it can't -handle more than 255-character strings. The final two won't print: +Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium dol- +oremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore verita- +tis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam vol- +uptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur +magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam +est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed +quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam +quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam +corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis +autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil mole- +stiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? Hello! -Hello!Hello!Hello!Hello!Hello!Hello! +Hello!Hello!Hello!Hello!Hello!Hello!Hello! This sentence spans forty-three characters. -This sentence spans forty-three characters.This sentence spans forty-three characters.This sentence spans forty-three characters.This sentence spans forty-three characters.This sentence spans forty-three characters.This sentence spans forty-three characte +This sentence spans forty-three characters.This sentence spans forty-three characters.This sentence spans forty-three characters.This sentence spans forty-three characters.This sentence spans forty-three characters.This sentence spans forty-three characters.This sentence spans forty-three characters. diff --git a/test/asm/macro-arguments.asm b/test/asm/macro-arguments.asm index a5e98621..0ec107b7 100644 --- a/test/asm/macro-arguments.asm +++ b/test/asm/macro-arguments.asm @@ -15,7 +15,7 @@ ENDM mac 1, 2 + /* another ; ; comment */ 2, 3 - mac a b ; truncated + mac a b ; long mac mac , diff --git a/test/asm/macro-arguments.err b/test/asm/macro-arguments.err index 6208792f..02f2ee09 100644 --- a/test/asm/macro-arguments.err +++ b/test/asm/macro-arguments.err @@ -1,5 +1,3 @@ -warning: macro-arguments.asm(18): [-Wlong-string] - Macro argument too long warning: macro-arguments.asm(21): [-Wempty-macro-arg] Empty macro argument warning: macro-arguments.asm(23): [-Wempty-macro-arg] diff --git a/test/asm/macro-arguments.out b/test/asm/macro-arguments.out index ba541c31..eaa5d771 100644 --- a/test/asm/macro-arguments.out +++ b/test/asm/macro-arguments.out @@ -13,8 +13,8 @@ \2: <2 + 2> \3: <3> -'mac a': -\1: +'mac a b': +\1: 'mac ': diff --git a/test/asm/strrpl.err b/test/asm/strrpl.err index e893a298..a1196175 100644 --- a/test/asm/strrpl.err +++ b/test/asm/strrpl.err @@ -1,4 +1,2 @@ warning: strrpl.asm(4): [-Wempty-strrpl] STRRPL: Cannot replace an empty string -warning: strrpl.asm(6): [-Wlong-string] - STRRPL: String too long, got truncated diff --git a/test/asm/strrpl.out b/test/asm/strrpl.out index 5779fc82..bd2deb3a 100644 --- a/test/asm/strrpl.out +++ b/test/asm/strrpl.out @@ -3,4 +3,4 @@ hahohahol hello world -[bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbb +[bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb][bbbbbbbb]