Don't redraw the console progress bar every time

Summary: lulululuul see D9361

Test Plan: derp derp derp

Reviewers: joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D9363
Fix lint when working on windows

Summary:
Fixes T4395.

Add quotes to ExecFuture strings on Windows to prevent `cmd.exe` from mucking up the command string.

Test Plan: Run `arc lint` on projects using `phpcs`. See everything working like it should.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Maniphest Tasks: T4592, T4395

Differential Revision: https://secure.phabricator.com/D9348
Allow triple backticks to be preceded by whitespace.

Summary: Fixes T5264. Allows triple backticks to be preceded by whitespace in a code block. This fixes the display of quoted code blocks, which are regular code blocks prefied with `> `.

Test Plan: Wrote and executed unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Maniphest Tasks: T5264

Differential Revision: https://secure.phabricator.com/D9388
Implementation of PhutilLexer for Python

Summary: This appears to be ~1.5-2.0x faster than pygments on my machine, which isn't as good as I was hoping for but will help. (This is ~330 ms for a 4400-line file I chose at random.)

Test Plan: Loaded a Python paste and saw highlights that approximately (or maybe exactly) match the pygments version.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9370
Fix bugs in python lexer

Summary:
Two things:

- The appearance of \\ or \' or \-followed-by-a-newline in a raw string would improperly end the string
- A disallowed newline in a string would cause an error instead of trying to continue anyway

Test Plan:
Ran it on a file that was failing for me that was something like:

    x = r'\\"'
    # hello there

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9404
Apply various linter fixes.

Summary: Applied various linter fixes.

Test Plan: Ran `arc unit` to verify things still worked.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9435
Allow `Makefile` files to contain tabs.

Summary: Add an entry to the `.editorconfig` file to allow `Makefile` files to contains tabs over spaces. Without this entry, my editor will automatically convert the tabs to spaces (which `make` does not like).

Test Plan: Opened `./support/xhpast/Makefile` and saved it. Verified that spaces weren't converted to tabs.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9436
Exclude some test data from being linted.

Summary: Currently, `arc lint --apply-patches` will patch some files which contain test data, consequently causing unit tests to file. We should either modify the tests so that they can pass linting and unit tests successfully (if possible), or just exclude them from being linted.

Test Plan: Ran `arc lint --apply-patches` and ensured that these files were not patched.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9437
Support interactive editing with Windows editors

Summary: Currently, output is generated with *nix newlines (`\n`) but this doesn't work in (for example) notepad. (and oh, Notepad blocks just fine)

Test Plan: run `arc diff` with and without the patch. See a mess before, and beauty after

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9504
Update xhpast.exe

Summary:
Fixes T4592. I think I got this working. Rough steps were:

  - Install mingw
  - Install git + git bash
  - Using mingw shell //only//, run build script
  - Oh you have to muck with PATH a lot
  - why is it hanging
  - I wish I could paste
  - this looks like a `.exe`

Test Plan: ???

Reviewers: richardvanvelzen

Reviewed By: richardvanvelzen

Subscribers: epriestley

Maniphest Tasks: T4592

Differential Revision: https://secure.phabricator.com/D9378
Update `.gitignore`.

Summary: See inline comments for reasoning.

Test Plan: N/A

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9530
Fix phutil_utf8_console_strlen() for combining characters

Summary:
See D9533. We currently count the length of combining characters incorrectly.

Instead, break the string into glyphs first, then only count the length of the base character in each glyph, ignoring combining characters.

Test Plan: Added some unit tests.

Reviewers: joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D9546
Reduce the amount of information leaked into stack traces

Summary:
Via HackerOne. We currently expose the daemon log in the web UI. The utility of doing this is large, but stack traces may occasionally contain too much information.

Instead of printing out function arguments in stack traces, just print out the types. This is at least as useful in most cases, and can't leak anything sensitive.

Also, when possible, canonicalize paths in stack traces relative to a known library. This makes them slightly more readable, and may reduce the number of researchers reporting full path disclosure via HackerOne.

Test Plan:
Ran something like this:

```
function f() {
  throw new Exception("ABCDEF");
}

f("a", 1, null, false, (object)array(), array(), new PhutilJSON());
```

...and got this stack trace:

```
>>> orbital ~/devtools/libphutil $ ./scripts/test/prompt.php
[2014-06-14 19:14:45] EXCEPTION: (Exception) ABCDEF at [<phutil>/scripts/test/prompt.php:8]
  #0 f(string, integer, NULL, boolean, stdClass, array, PhutilJSON) called at [<phutil>/scripts/test/prompt.php:11]
```

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D9540
Add a `PhutilConsoleTable` class for drawing tables.

Summary: Currently there is no easy way to draw a table. `PhabricatorDaemonManagementStatusWorkflow` draws a table in an ad-hoc way, but it would be useful to provide a more flexible mechanism to do so.

Test Plan:
```lang=php
$table = id(new PhutilConsoleTable())
  ->addColumn('foo', array('title' => 'Foo', 'align' => 'right'))
  ->addColumn('bar', array('title' => 'Foobar', 'align' => 'center'))
  ->addColumn('baz', array('title' => '日本語'))

  ->addRow(array('foo' => 12345, 'bar' => 'foo', 'baz' => 'baz'))
  ->addRow(array('foo' => '汉语漢語', 'bar' => '한국어조선말', 'baz' => 'ру́сский язы́к'))
  ->addRow(array('foo' => 'aaa', 'bar' => '✓✗', 'baz' => 'dddddddddddd'))
  ->addRow(array('foo' => '', 'bar' => '', 'baz' => ''));

$table->setBorders(false)->draw();
echo "\n";
$table->setBorders(true)->draw();
```

**Output**
{F166929}

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9533
Add a `addColumns` method to `PhutilConsoleTable`.

Summary: Allow columns to be added in one big hit. In some cases, this may be easier than adding columns individually.

Test Plan: Meh

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9553
Rebuild libphutil library map to remove `sprintf_escape` function

Summary: Minor, fix out-of-date build after D9533.

Test Plan: `arc liberate`

Reviewers: joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D9556
Move infrastructure tests up one directory.

Summary: Sometimes, the `PhutilInfrastructureTestCase` //would// fail, but we don't run it with `arc unit` because of the directory structure. See D9556 for an example.

Test Plan: Ran `arc unit --everything` and verified that `PhutilInfrastructureTestCase` was executed.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9557
Support ansicon for ANSI support on Windows

Summary: This gives more color. See: https://github.com/adoxa/ansicon

Test Plan: run `arc unit` amongst others and see spiffy colors

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9560
Rebuild `xhpast.exe` with static linkage

Summary:
Fixes T5372.

This thing is like 2.5MB but surely we will never regret checking multi-megabyte binaries into the VCS.

Test Plan:
  - Observed static flags being used during build.
  - Ran `xhpast.exe` with some PHP piped into it.
  - Saw large binary size.

Reviewers: richardvanvelzen

Reviewed By: richardvanvelzen

Subscribers: epriestley

Maniphest Tasks: T5372

Differential Revision: https://secure.phabricator.com/D9581
Fix the width of `PhutilConsoleTable` if the header row is wider than the data rows.

Summary:
Currently, the width of the header text is not taken into consideration when drawing the table. The width of the header text must be accounted for as if it were an ordinary row. Specifically, the following error occurs otherwise:

```
PHP Warning:  str_repeat(): Second argument has to be greater than or equal to 0 in /home/joshua/workspace/github.com/phacility/libphutil/src/console/PhutilConsoleTable.php on line 211
```

Test Plan: Drew a table with a really wide header column. verified that no warnings were raised and that the table rendered correctly.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9583