Skip to content

Instantly share code, notes, and snippets.

@MasterDuke17
Created August 8, 2019 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MasterDuke17/87f632b6b5c45af82a274961c2c5c941 to your computer and use it in GitHub Desktop.
Save MasterDuke17/87f632b6b5c45af82a274961c2c5c941 to your computer and use it in GitHub Desktop.
diff --git a/src/HLL/sprintf.nqp b/src/HLL/sprintf.nqp
index 50f80be9e..6f719308e 100644
--- a/src/HLL/sprintf.nqp
+++ b/src/HLL/sprintf.nqp
@@ -72,7 +72,7 @@ my module sprintf {
!! +@*ARGS_HAVE == 1 ?? "1 argument was"
!! +@*ARGS_HAVE ~ " arguments were")
~ " supplied", nqp::hash('DIRECTIVES_COUNT',
- nqp::hash('ARGS_HAVE', +@*ARGS_HAVE, 'ARGS_USED', $*ARGS_USED)))
+ nqp::hash('DIRECTIVE', nqp::join('', @statements), 'ARGS_HAVE', +@*ARGS_HAVE, 'ARGS_USED', $*ARGS_USED)))
}
make nqp::join('', @statements);
}
@@ -521,10 +521,15 @@ my module sprintf {
my $actions := Actions.new();
+ my class Lock is repr('ReentrantMutex') { }
sub sprintf($format, @arguments) {
+ my $l := Lock.new;
+ nqp::lock($l);
my @*ARGS_HAVE := @arguments;
$assert_used_args := 1;
- return Syntax.parse( $format, :actions($actions) ).made;
+ my $s := Syntax.parse( $format, :actions($actions) ).made;
+ nqp::unlock($l);
+ return $s;
}
nqp::bindcurhllsym('sprintf', &sprintf);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment