Repository: mesonbuild/meson

Issue:
[meson 0.56] Cannot handle spaces in [binaries] paths / string index out of range in ninjabackend.py
**Describe the bug**
```
Traceback (most recent call last):
  File "E:\vcpkg_cache\downloads\tools\meson\meson-0.56.0\mesonbuild\mesonmain.py", line 140, in run
    return options.run_func(options)
  File "E:\vcpkg_cache\downloads\tools\meson\meson-0.56.0\mesonbuild\msetup.py", line 253, in run
    app.generate()
  File "E:\vcpkg_cache\downloads\tools\meson\meson-0.56.0\mesonbuild\msetup.py", line 161, in generate
    self._generate(env)
  File "E:\vcpkg_cache\downloads\tools\meson\meson-0.56.0\mesonbuild\msetup.py", line 223, in _generate
    intr.backend.generate()
  File "E:\vcpkg_cache\downloads\tools\meson\meson-0.56.0\mesonbuild\backend\ninjabackend.py", line 533, in generate
    self.write_rules(outfile)
  File "E:\vcpkg_cache\downloads\tools\meson\meson-0.56.0\mesonbuild\backend\ninjabackend.py", line 1122, in write_rules
    b.count_rule_references()
  File "E:\vcpkg_cache\downloads\tools\meson\meson-0.56.0\mesonbuild\backend\ninjabackend.py", line 342, in count_rule_references
    if self._should_use_rspfile():
  File "E:\vcpkg_cache\downloads\tools\meson\meson-0.56.0\mesonbuild\backend\ninjabackend.py", line 336, in _should_use_rspfile
    return self.rule.length_estimate(infilenames,
  File "E:\vcpkg_cache\downloads\tools\meson\meson-0.56.0\mesonbuild\backend\ninjabackend.py", line 273, in length_estimate
    if chunk[1] == '{':
IndexError: string index out of range
```




Discussion:
added a `print(command)` in line 269 before the for loop and a `print(m)` in the loop. 
The output is: 
```
"C:/Program$ Files$ (x86)/Microsoft$ Visual$ Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe" $ARGS /Fo$out "/c" $in
<re.Match object; span=(0, 11), match='"C:/Program'>
<re.Match object; span=(11, 18), match='$ Files'>
```

Also it worked fine with meson 0.55.1
the important parts of the native file:
```
[binaries]
mt = 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.19041.0/x64/mt.exe'
c = 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe'
cpp = 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe'
rc = 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.19041.0/x64/rc.exe'
c_ld = 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/link.exe'
cpp_ld = 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/link.exe'
cmake = 'C:/Program Files/CMake/bin/cmake.exe'
```
The regex should probably be:
`for m in re.finditer(r'(\${\w+}|\$\w+)?[^$]*', command):`
and not 
`for m in re.finditer(r'(\${\w*}|\$\w*)?[^$]*', command):`
cc @bonzini 

Resolving patch:
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -266,7 +266,7 @@ def length_estimate(self, infiles, outfiles, elems):
         # expand variables in command
         command = ' '.join([self._quoter(x) for x in self.command + self.args])
         estimate = len(command)
-        for m in re.finditer(r'(\${\w*}|\$\w*)?[^$]*', command):
+        for m in re.finditer(r'(\${\w+}|\$\w+)?[^$]*', command):
             if m.start(1) != -1:
                 estimate -= m.end(1) - m.start(1) + 1
                 chunk = m.group(1)


Test patch: