> On April 3, 2016, 4:21 p.m., Kevin Klues wrote:
> > support/mesos-style.py, line 43
> > <https://reviews.apache.org/r/45033/diff/5/?file=1322861#file1322861line43>
> >
> >     This will not work with `re.match()`. As is, this will only match if 
> > the non-ascii character is the first character on the line.  Instead, you 
> > should probably be using `re.search()`.
> >     
> >     Also, the variable `m` should probably be renamed `match` and spaces 
> > should be added around the `=`.
> 
> Kevin Klues wrote:
>     Also, I'm not sure if this is actually the correct match to be looking 
> for.  What we basically want is a check to see if the characters are 
> printable characters between 0-127. This will **not** exclude unicode 
> characters, nor characters in the rhange 0-127 which are not printable (e.g. 
> 'bell').

I've updated my the patch at 
https://github.com/klueska-mesosphere/mesos/commits/r/yongtang/non-ascii to 
reflect, what I think is probably a better method for determining the 
non-printable characters.

```
# If we find an error, add 1 to both the character and        
# the line offset to give them 1-based indexing               
# instead of 0 (as is common in most editors).                
char_errors = [offset + 1 for offset, char in enumerate(line) 
                   if char not in string.printable]           
if char_errors:                                               
    sys.stderr.write(                                         
        "Non printable characters found in {path} "           
         "(Line: {line_number}, Chars: {chars}): {line}".format( 
             path=path,                                        
             line_number=line_number + 1,                      
             chars=char_errors,                                
             line=line))   
```


- Kevin


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/45033/#review126733
-----------------------------------------------------------


On April 3, 2016, 7:46 p.m., Yong Tang wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/45033/
> -----------------------------------------------------------
> 
> (Updated April 3, 2016, 7:46 p.m.)
> 
> 
> Review request for mesos, Alexander Rukletsov, Benjamin Bannier, Bernd 
> Mathiske, haosdent huang, Kevin Klues, Neil Conway, Vinod Kone, and Deshi 
> Xiao.
> 
> 
> Bugs: MESOS-4033
>     https://issues.apache.org/jira/browse/MESOS-4033
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> This review request tries to add addition check in mesos-style.pl
> for checking non-ascii characters. It scans .cpp, .hpp, .cc, .h
> files and report error if non-ascii characters exists.
> 
> As part of this review request, two non-ascii characters are identified
> in versioning.md (one in Ln 85 and another in Ln 96) and are corrected
> accordingly.
> 
> Note: .md scan is skipped based on feedback from review request.
> 
> Note: This commit includes patches from Kevin Klues and haosdent.
> 
> 
> Diffs
> -----
> 
>   docs/versioning.md ecacd8433f0fa1643827b36d03154042538c1c6b 
>   support/mesos-style.py 13616065ebe07ca401b385716d9b723f65bb2162 
> 
> Diff: https://reviews.apache.org/r/45033/diff/
> 
> 
> Testing
> -------
> 
> Tested manually and found two non ascii characters in docs/versioning.md 
> (fixed as part of this review request).
> 
> 
> Thanks,
> 
> Yong Tang
> 
>

Reply via email to