Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqf: Fix sqfc byte offset #771

Merged
merged 2 commits into from
Sep 10, 2024
Merged

sqf: Fix sqfc byte offset #771

merged 2 commits into from
Sep 10, 2024

Conversation

PabstMirror
Copy link
Collaborator

Fixes two problems with sqfc offsets
Shouldn't be any functionality change, just effects arma errors and debugging.

  • It would use the macro's start location
from sqf:
#define IS_META_SYS(VAR,TYPE) (if (isNil {VAR}) then {false} else {(VAR) isEqualType TYPE})
#define IS_STRING(VAR)   IS_META_SYS(VAR,"STRING")  

before (nonsense because it's using the index of start of macro for both sub blocks):
push [{(if (},{(if (isNil {_pos}) then {fa}]
after:
push [{false},{(_pos) isEqualType "STRING"}]
  • Unicode would cause problems, as arma seems to expect bytes

e.g. the # is in the wrong location
before:
before
after:
after

@PabstMirror
Copy link
Collaborator Author

testing with

#define IS_META_SYS(VAR,TYPE) (if (isNil {VAR}) then {false} else {(VAR) isEqualType TYPE})
#define IS_STRING(VAR)   IS_META_SYS(VAR,"STRING")  
#define SOME(A,B) (if (random 1 < 0.5) then { A} else { B })
#define XXX(A,B) (A + B)
#define BAD 5 == "A"

z = IS_STRING(_pos);

and

#include "macros.inc"

x = "°°°°°°°°";
y = 123456;
if (BAD);

sqfc debug output
before.txt
after.txt

Copy link

codecov bot commented Sep 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.3%. Comparing base (fe78d1e) to head (e369dd6).
Report is 1 commits behind head on main.

Additional details and impacted files
Files with missing lines Coverage Δ
libs/sqf/src/compiler/mod.rs 96.8% <100.0%> (-0.1%) ⬇️
libs/workspace/src/reporting/processed.rs 89.2% <100.0%> (+0.1%) ⬆️

@BrettMayson
Copy link
Owner

Ah nice, good find and fix

@BrettMayson BrettMayson merged commit a53c917 into main Sep 10, 2024
29 of 31 checks passed
@BrettMayson BrettMayson deleted the fixSqfcOffset branch September 10, 2024 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants