<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<meta content="text/html; charset=US-ASCII" http-equiv="Content-Type">
<title>
GitLab
</title>



<style>img {
max-width: 100%; height: auto;
}
</style>
</head>
<body>
<div class="content">

<h3>
PulseAudio Marge Bot pushed to branch master
at <a href="https://gitlab.freedesktop.org/pulseaudio/pulseaudio">PulseAudio / pulseaudio</a>
</h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/c3c84a3691e700157ccd3c75fdae53c6eec89775">c3c84a36</a></strong>
<div>
<span>by Olivier Gayot</span>
<i>at 2022-05-16T18:15:47+00:00</i>
</div>
<pre class="commit-message" style="white-space: pre-wrap; margin: 0;">pactl: fix invalid JSON output by overriding LC_NUMERIC

When the --format json parameter is given on the command line, we
attempt to produce a JSON output for most commands.

Our implementation of the JSON serialization uses vsnprintf to output
numbers. Unfortunately, vsnprintf is affected by the locale and more
specifically the LC_NUMERIC variable.

When LC_NUMERIC is set to, for instance, fr_FR.UTF-8, floating-point
numbers are output with a comma as the decimal separator, which is then
considered invalid JSON.

 $ LC_NUMERIC=fr_FR.UTF-8 pactl --format json list sinks | jq .
 parse error: Objects must consist of key:value pairs at line 1, column 435

This is the token which failed to parse:

 }},"balance":0,00,"base_volume":{

Fixed by overriding the LC_NUMERIC value when we request JSON output.

Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/702>
</pre>
</li>
</ul>
<h4>1 changed file:</h4>
<ul>
<li class="file-stats">
<a href="#6cfeb7a72abc7155cf94b60510e6dc2a7011a646">
src/utils/pactl.c
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id="6cfeb7a72abc7155cf94b60510e6dc2a7011a646">
<a href="https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/c3c84a3691e700157ccd3c75fdae53c6eec89775#6cfeb7a72abc7155cf94b60510e6dc2a7011a646"><strong>src/utils/pactl.c</strong></a>
<hr>
<table class="code white" style="font-family: monospace; font-size: 90%;" bgcolor="#fff" width="100%" cellpadding="0" cellspacing="0">
<tr class="line_holder match" style="line-height: 1.6;">
<td class="diff-line-num unfold js-unfold old_line" data-linenumber="2746" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">...</td>
<td class="diff-line-num unfold js-unfold new_line" data-linenumber="2746" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">...</td>
<td class="line_content match" style="padding-left: 0.5em; padding-right: 0.5em; color: rgba(0,0,0,0.3);" bgcolor="#fafafa">@@ -2746,6 +2746,7 @@ int main(int argc, char *argv[]) {</td>
</tr>
<tr class="line_holder" style="line-height: 1.6;">
<td class="old_line diff-line-num" data-linenumber="2746" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
2746
</td>
<td class="new_line diff-line-num" data-linenumber="2746" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
2746
</td>
<td class="line_content" style="padding-left: 0.5em; padding-right: 0.5em;"><pre style="margin: 0;"> <span id="LC2746" class="line" lang="c">        <span class="n" style="color: #333;">format</span> <span class="o" style="font-weight: 600;">=</span> <span class="n" style="color: #333;">TEXT</span><span class="p">;</span></span>
</pre></td>
</tr>
<tr class="line_holder" style="line-height: 1.6;">
<td class="old_line diff-line-num" data-linenumber="2747" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
2747
</td>
<td class="new_line diff-line-num" data-linenumber="2747" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
2747
</td>
<td class="line_content" style="padding-left: 0.5em; padding-right: 0.5em;"><pre style="margin: 0;"> <span id="LC2747" class="line" lang="c">    <span class="p">}</span> <span class="k" style="font-weight: 600;">else</span> <span class="k" style="font-weight: 600;">if</span> <span class="p">(</span><span class="n" style="color: #333;">pa_streq</span><span class="p">(</span><span class="n" style="color: #333;">opt_format</span><span class="p">,</span> <span class="s" style="color: #d14;">"json"</span><span class="p">))</span> <span class="p">{</span></span>
</pre></td>
</tr>
<tr class="line_holder" style="line-height: 1.6;">
<td class="old_line diff-line-num" data-linenumber="2748" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
2748
</td>
<td class="new_line diff-line-num" data-linenumber="2748" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
2748
</td>
<td class="line_content" style="padding-left: 0.5em; padding-right: 0.5em;"><pre style="margin: 0;"> <span id="LC2748" class="line" lang="c">        <span class="n" style="color: #333;">format</span> <span class="o" style="font-weight: 600;">=</span> <span class="n" style="color: #333;">JSON</span><span class="p">;</span></span>
</pre></td>
</tr>
<tr class="line_holder new" style="line-height: 1.6;">
<td class="old_line diff-line-num new" data-linenumber="2749" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="new_line diff-line-num new" data-linenumber="2749" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
2749
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0"><pre style="margin: 0;">+<span id="LC2749" class="line" lang="c">        <span class="n" style="color: #333;">setlocale</span><span class="p">(</span><span class="n" style="color: #333;">LC_NUMERIC</span><span class="p">,</span> <span class="s" style="color: #d14;">"C"</span><span class="p">);</span></span>
</pre></td>
</tr>
<tr class="line_holder" style="line-height: 1.6;">
<td class="old_line diff-line-num" data-linenumber="2749" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
2749
</td>
<td class="new_line diff-line-num" data-linenumber="2750" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
2750
</td>
<td class="line_content" style="padding-left: 0.5em; padding-right: 0.5em;"><pre style="margin: 0;"> <span id="LC2750" class="line" lang="c">    <span class="p">}</span> <span class="k" style="font-weight: 600;">else</span> <span class="p">{</span></span>
</pre></td>
</tr>
<tr class="line_holder" style="line-height: 1.6;">
<td class="old_line diff-line-num" data-linenumber="2750" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
2750
</td>
<td class="new_line diff-line-num" data-linenumber="2751" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
2751
</td>
<td class="line_content" style="padding-left: 0.5em; padding-right: 0.5em;"><pre style="margin: 0;"> <span id="LC2751" class="line" lang="c">        <span class="n" style="color: #333;">pa_log</span><span class="p">(</span><span class="n" style="color: #333;">_</span><span class="p">(</span><span class="s" style="color: #d14;">"Invalid format value '%s'"</span><span class="p">),</span> <span class="n" style="color: #333;">opt_format</span><span class="p">);</span></span>
</pre></td>
</tr>
<tr class="line_holder" style="line-height: 1.6;">
<td class="old_line diff-line-num" data-linenumber="2751" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
2751
</td>
<td class="new_line diff-line-num" data-linenumber="2752" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
2752
</td>
<td class="line_content" style="padding-left: 0.5em; padding-right: 0.5em;"><pre style="margin: 0;"> <span id="LC2752" class="line" lang="c">        <span class="k" style="font-weight: 600;">goto</span> <span class="n" style="color: #333;">quit</span><span class="p">;</span></span>
</pre></td>
</tr>

</table>
<br>
</li>

</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #666;">

<br>
<a href="https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/c3c84a3691e700157ccd3c75fdae53c6eec89775">View it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.freedesktop.org.
If you'd like to receive fewer emails, you can
adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Commit","url":"https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/c3c84a3691e700157ccd3c75fdae53c6eec89775"}}</script>


</p>
</div>
</body>
</html>