<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="12" style="border: 1px #c9c399 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="https://git.reviewboard.kde.org/r/119500/">https://git.reviewboard.kde.org/r/119500/</a>
     </td>
    </tr>
   </table>
   <br />




<table bgcolor="#e0e0e0" width="100%" cellpadding="12" style="border: 1px gray solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
 <tr>
  <td>
   <h1 style="margin: 0; padding: 0; font-size: 10pt;">This change has been marked as submitted.</h1>
  </td>
 </tr>
</table>
<br />


<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="12" style="border: 1px #888a85 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
 <tr>
  <td>

<div>Review request for KDE Bindings, Arno Rehn and Luca Beltrame.</div>
<div>By Raphael Kubo da Costa.</div>


<p style="color: grey;"><i>Updated Aug. 1, 2014, 8:17 a.m.</i></p>









<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
smokegen
</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">A null directive such as<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
  #<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
or<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
  # // some comment<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
is valid in C++ and should just be ignored (and it is actually present<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
in qglobal.h in Qt versions past 4.8.6).</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Support for lines like those already worked in some cases, by only by<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
accident:</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">- The parser code currently contains several global objects that are<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
  either IndexedStrings or data types created by a function that creates<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
  IndexedStrings (this on its own is wrong and dangerous, but a fix<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
  requires a lot more work and is a broader issue than the one at hand).<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
- The initialization order of those global objects spread across<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
  different files is undefined: in some cases, createIndicesForTokens()<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
  would be called first, while in others the preprocessor directives in<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
  pp-engine.cpp would be the ones created first.<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
- An IndexedString with index 0 can mean either the first string in the<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
  list of strings in the index or a string with length 0, with is never<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
  indexed.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">So when a null directive is found, skip_identifier() does not have<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
anything to skip over, creates an empty IndexedString and returns its<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
index (0). If createIndicesForTokens() is called first when globals are<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
being initialized, the first string in the index is "K_DCOP", which does<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
not match any directive in handle_directive() and allows the parsing to<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
continue (there does not seem to be any bad effects caused by the wrong<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
match).</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">However, if the preprocessor directives are the first globals to be<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
initialized, the string corresponding to #if would be the string with<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
index 0 in IndexedString. handle_directive() gets this directive with<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
index 0, assume it corresponds to an #if and parsing would fail.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">We now properly recognize null directives by verifying if<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
skip_identifier() managed to advance in its input stream or not, since<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
this is the difference between its return value meaning an empty string<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
or the first string in the index. If it returned an empty string, there<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
was no directive in the line, we then assume it is a null directive and<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
just move on to the next line.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">(KDeveloper's version of the parser is not affected by the bug fixed<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
here; the copies have diverged too much for it to be feasible to easily<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
sync from KDevelop again though)</p></pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Building smokeqt with Qt past df35604ff944e935bd07c8ca417ae24ed458908b works</p></pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>parser/rpp/pp-engine.cpp <span style="color: grey">(e8c3b965ea42f098ce9519a213beb0d3360636ca)</span></li>

</ul>

<p><a href="https://git.reviewboard.kde.org/r/119500/diff/" style="margin-left: 3em;">View Diff</a></p>






  </td>
 </tr>
</table>




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