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

Match literal numbers #78

Open
kevin-denis opened this issue Jan 9, 2023 · 0 comments
Open

Match literal numbers #78

kevin-denis opened this issue Jan 9, 2023 · 0 comments

Comments

@kevin-denis
Copy link

We can't easily match a number with weggli, we must use a wildcard.

Code:

void fun() {
	char a[45];
	char b[size];
}

Let say I want to find all stack variable with a fixed size, such as "a", but not "b".

$ weggli '{ _ $var[$c]; }' a.c 
void fun() {
	char a[45];
	char b[size];            <-- is highlighted
}
$ weggli '{ _ $var[_]; }' a.c
void fun() {
	char a[45];              <-- is highlighted
	char b[size];
}
void fun() {
	char a[45];
	char b[size];            <-- is highlighted
}

The only way to match the a[45] is to use a wildcard, but I don't want to match b[size].

It would be nice to have a special parameter for literal numbers, such as $# or $1 or $NUMBER:

$ weggli '{ _ $var[$#]; }' a.c 
void fun() {
	char a[45];            <-- is highlighted
	char b[size];          <-- is not highlighted
}
$
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

No branches or pull requests

1 participant