Commit Graph

831 Commits

Author SHA1 Message Date
ISSOtm
20b2f5ee2f Fix incorrect line numbers with some IF blocks
If a line ended with a string's closing quote, or a newline escape, then
skipping over that line via IF/ELIF/ELSE would fail to count that line,
offsetting the rest of the file.
I have no idea why but for some reason 9829be1 changed *specifically*
`if_skip_to_else` to have incorrect behavior on string endings. The incorrect
behavior on newline escapes seems to have been here since the beginning.
Also added a test to check for both of those behaviors in both functions.

Honestly, it baffles me that nobody ever noticed. I didn't until I started
working on #395.
2019-09-01 03:59:29 +02:00
Eldred Habert
9b40663d54 Merge pull request #409 from rednex/dd-head
Use POSIX-compatible dd(1) instead of head -c.
2019-08-31 12:59:18 +02:00
Anthony J. Bentley
a517f900e4 Use POSIX-compatible dd(1) instead of head -c. 2019-08-30 23:11:28 -06:00
Eldred Habert
350f40300c Merge pull request #403 from dbrotz/multiple-charmaps
Add support for multiple charmaps
2019-08-31 04:44:58 +02:00
dbrotz
d3db5f0d76 Add pushc and popc directives 2019-08-30 19:36:23 -07:00
ISSOtm
7e3af4b3cd Make testing external projects use local RGBDS
Currently, the installed version is used instead, which isn't
consistent with the tests, which use the local version.
2019-08-31 04:17:16 +02:00
ISSOtm
02191135a0 Fix possible unterminated string
sym_SetMacroArgID used a `sprintf` that could write no \0.
In practice this was benign because %u cannot print 256 chars,
but better future-proof this.
2019-08-31 03:00:26 +02:00
ISSOtm
a21cef7190 Say which macro argument caused an error when one does 2019-08-30 20:57:11 +02:00
dbrotz
461ef6cea5 Don't complain about initializing statics
This error is specific to the way the Linux kernel handles statics.
It does not apply to userspace programs.
2019-08-29 22:48:16 -07:00
dbrotz
e05199ca1e Add support for multiple charmaps
This adds two new directives: newcharmap and setcharmap.
newcharmap creates a new charmap and switches to it.
setcharmap switches to an existing charmap.
2019-08-29 21:54:06 -07:00
Eldred Habert
12d82eb768 Remove extra entry in error stack on macro not defined (#394)
While working on #392, I noticed that the macro-@ test (as well
as the line-continuation test, but for that one see #393)
printed an additional '@(-1)' entry which doesn't make sense.
2019-08-30 02:14:21 +02:00
Eldred Habert
05becf3f4b Merge pull request #381 from NieDzejkob/rgbgfx-curve
rgbgfx: Add an option to take the CGB's color profile into account
2019-08-29 22:19:36 +02:00
Eldred Habert
3cc7981c82 Merge pull request #402 from dbrotz/fix-386
Fix nested if statements that don't have following whitespace
2019-08-29 22:06:10 +02:00
dbrotz
8f287eeef9 Fix nested if statements that don't have following whitespace
When trying to skip over nested if statements, if there was no whitespace
after an "if", then that "if" would not be recognized. That's a problem since
"if(" and "if{" are also valid ways to start an if statement. This change
will make it so that they are recognized correctly.
2019-08-29 12:37:59 -07:00
Eldred Habert
ce05cb5683 Merge pull request #401 from dbrotz/line-cont-test
Get rid of error in line continuation test
2019-08-29 21:23:00 +02:00
dbrotz
17945a7377 Get rid of error in line continuation test
The purpose of the test is to ensure that rgbasm doesn't segfault in this case.
The "Macro '@' not defined" error is unnecessary.
2019-08-29 11:49:17 -07:00
Eldred Habert
3a1b47129e Merge pull request #397 from NieDzejkob/test-local-without-parent
Add a test for a defining local label without a parent
2019-08-29 20:24:36 +02:00
Eldred Habert
6ffa751090 Merge pull request #390 from ISSOtm/print_types
Add "print types" to bracketed symbols
2019-08-29 20:12:32 +02:00
Eldred Habert
c3641321d7 Merge pull request #399 from ISSOtm/allow_dots
Allow periods to continue macro args
2019-08-29 20:09:32 +02:00
Eldred Habert
446173f0cb Merge pull request #387 from ISSOtm/set_doesnt_override_equ
Prevent `SET` from overriding constant symbols
2019-08-29 20:08:08 +02:00
Eldred Habert
e27f381842 Merge pull request #361 from ISSOtm/better_section_overflow
Improve section overflow error message
2019-08-29 20:04:48 +02:00
ISSOtm
a3ee76dddd Allow periods to continue macro args
c75a953 broke my (previously-working) project that defined, via
macros, 'sizeof_.player'.
A test was added to confirm that those are indeed accepted
outside of macros.
2019-08-29 19:51:47 +02:00
ISSOtm
995265c549 Improve testing bracketed symbols
Also test EQU and _RS constants, as well as that EQUS errors out,
and that labels don't work.
2019-08-29 19:16:28 +02:00
Jakub Kądziołka
03629b74d9 Add a test for a defining local label without a parent 2019-08-29 19:14:02 +02:00
Eldred Habert
b069278e98 Merge pull request #384 from dbrotz/fix-local-label-segfault
Check if parent exists for local label reference
2019-08-29 19:05:27 +02:00
Eldred Habert
9738c88f95 Merge pull request #383 from dbrotz/fix-380
Change the precedence of == to match the documentation
2019-08-29 17:14:05 +02:00
ISSOtm
a21ea30be0 Add tests for bracketed symbols 2019-08-29 17:08:54 +02:00
ISSOtm
64752da42d Add "print types" to bracketed symbols
Should partially cover #178 and close #270.
This allows printing numbers in different bases and without the dollar prefix
This is especially useful in macros because the dollar isnt a valid character
for symbol names, requiring heavy `STRSUB` usage.
2019-08-29 14:04:58 +02:00
ISSOtm
e3e18063c6 Prevent SET from overriding constant symbols
Fixes #341
2019-08-27 21:23:36 +02:00
ISSOtm
e400eac42b Improve section overflow error message
When trying to fix a section becoming too large, the size it reached is necessary to know whether to optimize away a few bytes or split it entirely.
This error is also commonly encountered when INCBINing too large a slice of a file, in which case the amount of bytes by which the section is too large is again an useful information
2019-08-20 19:13:01 +02:00
dbrotz
a6bf77718c Check if parent exists for local label reference
If an attempt is made to reference a local label before any non-local label
is defined, raise an error instead of segfaulting.
2019-08-20 09:57:53 -07:00
dbrotz
c2787a9ea9 Change the precedence of == to match the documentation
The documentation states that == has the same precedence as the other
comparison operators.
2019-08-20 08:50:18 -07:00
Antonio Niño Díaz
e33e6e2413 Merge pull request #382 from NieDzejkob/checkpatch-bool-member
checkpatch.conf: Don't complain when bools are used in struct
2019-08-20 14:17:15 +01:00
Jakub Kądziołka
3cb56c5a2e checkpatch.conf: Don't complain when bools are used in struct
In RGBDS's codebase, boolean struct members aren't a problem. See
include/asm/main.h, include/gfx/main.h for examples.
2019-08-20 14:43:31 +02:00
Jakub Kądziołka
91984cb7e7 rgbgfx: Add an option to take the CGB's color profile into account 2019-08-20 14:38:17 +02:00
Antonio Niño Díaz
b8d5dd1824 Merge pull request #366 from dbrotz/fix-313
Fix signed integer overflow issues
2019-08-17 16:09:09 +01:00
Antonio Niño Díaz
88b66f2941 Merge pull request #364 from dbrotz/fix-362
Don't append invalid characters to symbol name
2019-08-17 16:08:27 +01:00
Antonio Niño Díaz
3c7e59b9e1 Merge pull request #374 from Ben10do/pushs-outside-of-section
Allow PUSHS to be used before a section
2019-08-17 16:07:28 +01:00
Ben Hetherington
c4471e3300 Update CONTRIBUTORS.rst
Updated to reflect my current committer identity.
2019-08-16 13:22:19 +01:00
Ben Hetherington
16111f46ef Allow PUSHS to be used before a section
Previously, a PUSHS before a SECTION directive would cause rgbasm to crash when encountering a subsequent POPS.

This is because the subsequently-called out_setCurrentSection() expected the new section to be non-null, which wasn’t the case in this situation. This has been addressed by allowing the ‘null’ section to be set in this function, and only dereferencing it (to set nPC) if a non-null section is to be set.

In practice, this means that PUSHS/POPS can now be used to push/restore a context without a section.
2019-08-16 13:22:19 +01:00
Antonio Niño Díaz
b019b03946 Merge pull request #358 from dbrotz/fix-357
Fix buffer overflow when creating patches with long RPN expressions
2019-07-12 00:49:08 +01:00
Antonio Niño Díaz
605acd24ba Merge pull request #372 from jidoc01/master
Document the feature of input from stdin (resolves #371)
2019-07-12 00:48:25 +01:00
jidoc01
c8630eee95 Document the feature of input from stdin
Since #329, rgbasm can get input from stdin. I updated the manpage
file related to it, which explain the description and usages in
rgbasm.
2019-07-08 23:28:46 +09:00
Antonio Niño Díaz
4040555532 Merge pull request #365 from dbrotz/terminate-bracketed-symbol
Terminate standalone bracketed symbol strings
2019-07-07 11:46:43 +01:00
Antonio Niño Díaz
defb221c98 Merge pull request #360 from jidoc01/master
Improve charmap structure with trie.
2019-07-07 11:46:08 +01:00
jidoc01
e7dc094e56 Improve charmap structure with trie
Charmap's previous structure was using brute-force comparison for
converting the strings in source files. It always compared given
strings to all of the strings in charmap, which was very costly
in huge projects.
For its improvement, I changed its structure into trie, which is
being used in many string-processing areas. It's now much faster
than before.
2019-07-06 19:25:44 +09:00
Antonio Niño Díaz
dfdb107105 Merge pull request #370 from jidoc01/fix_bug
Fix comment bug
2019-07-06 11:10:17 +01:00
Antonio Niño Díaz
9f598dfdb7 Merge pull request #359 from dbrotz/fix-lexer-out-of-bounds
Fix out of bounds array access in lexer
2019-07-06 11:09:43 +01:00
jidoc01
38110a833d Fix comment bug
There is a bug in processing the comments in source files. It's
related to #326. And this bug comes out when you comment something
with the character ';', and include the quotation mark without its
pair in it.

The lastest version of rgbds compiler has a step to parse the given
source to convert its line endings to a unified one, and it
processes quotation marks even before it processes the comments.

I edited a little bit of the source, and it works fine now.
2019-07-05 13:48:24 +09:00
dbrotz
484d15dbb2 Handle unprintable characters more gracefully
* Skip UTF-8 byte order mark at beginning of file
* Error on other unexpected unprintable characters
2019-07-04 17:14:55 -07:00