theos / logos

Preprocessor that simplifies Objective-C hooking.
https://theos.dev/docs/logos
Other
205 stars 34 forks source link

Properly handle single-line mixed-format comments #96

Closed L1ghtmann closed 1 year ago

L1ghtmann commented 1 year ago

What does this implement/fix? Explain your changes.

See title

Does this close any currently open issues?

Appears to resolve #66, #70, and #77

Any relevant logs, error output, etc?

N/A

Any other comments?

Tested with:

/ Multiline comment including a // line comment /

// These lines are incorrectly ignored:

int func() { int a = 3; return a; / Another multiline comment; its closing sequence will be noticed / // The line below will cause an error }


- Modified code from #77
```logos
%ctor{
    /*// }}}*/
    /*// }}}*/
}

Output (all three examples in the same file with whitespace removed for brevity):

static __attribute__((constructor)) void _logosLocalCtor_5784034e(int __unused argc, char __unused **argv, char __unused **envp){    
}

static __attribute__((constructor)) void _logosLocalCtor_f0225b01(int __unused argc, char __unused **argv, char __unused **envp) { 
}

int func() {
    int a = 3;
    return a;
}

static __attribute__((constructor)) void _logosLocalCtor_854fe05f(int __unused argc, char __unused **argv, char __unused **envp){
}

Where has this been tested?

Operating System:

Linux (WSL)

Platform:

Target Platform:

Toolchain Version:

SDK Version: