Commit graph

5 commits

Author SHA1 Message Date
kwantam
16ed7284d5 fmt: updated tables for charwidth 2014-07-01 19:07:45 -04:00
kwantam
8be67f7d4d fmt Knuth-Plass implementation; unicode char_width
fmt:
- Implemented Knuth-Plass optimal linebreaking strategy.
- Added commandline switch -q for "quick" (greedy) split
  mode that does not use Knuth-Plass.
- Right now, Knuth-Plass runs about half as fast. It also
  uses more memory.
- Updated fmt to use char_width (see below) instead of
  assuming each character width is 1.
- Use i64 for demerits instead of int in K-P, since int is
  pointer sized and will only be 32 bits on some
  architectures.
- incremented version number
- Incorporated improvements suggested by huonw and Arcterus.
  - K-P uses indices of linebreaks vector instead of raw
    pointers. This gets rid of a lot of allocation of boxes
    and improves safety to boot.
- Added a support module for computing displayed widths of unicode
  strings based on Markus Kuhn's free implementation at
    http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
- This is in `charwidth.rs`, but this is a temporary measure
  until the Char trait implements .width(). I am submitting
  a PR for this soon, and the code in charwidth() is what's
  generated libcore.

closes #223
2014-06-30 19:09:22 -04:00
kwantam
c9ee0a3e4d fmt: correct tab support, better formatting
In brief:

- Lines no longer end with trailing whitespace.
- fixed length calculation when tabs are present
- word splitting gives more info to the line
  breaking process, which should be useful for K-P
- code cleanup here and there
- K-P is not implemented yet. That's next. There
  is some dead code in linebreak.rs that forms the
  basis for K-P.
- Performance has regressed somewhat; we're now about
  60% slower than GNU fmt (formerly about 20%), but we
  are basically on par with OpenBSD fmt.
- addressed comments from Arcterus on PR

This is a squash of the following local commits:

 1feceb0 - address comments from Arcterus on PR
 b36aa90 - use word_nchars rather than w.len() for first word
 f44a629 - proper tab handling
 4f57593 - added tab analysis info to WordInfo
 211f4a5 - pass WordInfo by ref
 80e14b9 - overhaul word splitting apparatus
 d29f2e6 - tidy up the breaking by passing arg struct pointer
 d8020df - lines blank save for prefix act as par separators
 8bd7f1e - fixed tab behavior in -u
 a2387f7 - cleaner prefix handling ; cleanup ; prep for K-P
2014-06-20 18:59:45 -04:00
kwantam
5d2a2b6a0b fmt: style modifications suggested by Arcterus 2014-06-18 23:09:22 -04:00
kwantam
ac216c3d77 initial release of working fmt
Note: for now, this version does not use Knuth-Plass,
but everything else is in place with "greedy" breaking.

All options (should) work, and performance is nearly
on par with GNU fmt.

Squashed commit of the following local commits:

commit ebc12f5e7d19d351ada9273ec0c42d66d3730431
commit 125fdabcb2a32de161c7a8b76c3e766a40ff9f76
commit dadd62acc093b5bd4bc94ad4f8a499d2663a7097
commit e436fdaade3876e92020c61a736eba54eb5ca0cf
commit bbc4f4f6ad749753efe9b2df871ddb257f33de4b
commit 12bc4ecb0c56c0d43515a111e9129a4bfaf36531
commit 2e693553ed9af59c53ee13026d19c9f82f2973fc
commit 9b15a130148d62dd6a1d2765848ddc4daf30c649
commit ea335eb2869afcc94709345118fab3fb2e612954
Merge: ee92573 23cc41d
commit 23cc41d188cb3134c04872fd77acb331d86a64ea
commit 2fa7c48133001d86da39feda04d870ff67e88400
commit eb71558ee46654b568adf167f194cb854bbf7056
commit c8baabc0b86d831b5741fa496c312134db652c55
commit ee4fab44b216c1d9c7dcdcdc29ca587c76284834
commit c5444416a531ae1341dddbfd528e4a3ee5f106bf
commit e1177d47941654b8834d18599c80065943a26159
commit c7fb30e2ff32313974f99d34ba4735be064b0cc5
commit 99a9406bc6fff33fc64c190356e48f443312a6c4
commit 3d244d62c9b60b579f2e5b723da6389a5dbc8805
commit 2d4f09cb2ff83664730edba209ec129abdcf1403
commit 947c32b72bff8d50e362555ec21a6b848d5fec9f
commit 8556d2a3467651ee7833ad800876af35a7dd5db7
commit a2e4bc3dc45e5f39b402e6fdd3e19edcea6d3c34
Merge: 0308884 439e65d
commit 03088844f1fd2faca6c3471230730136dd140f35
commit ac80d888649dd1311fdaa68400ea45d52b2e23ab
commit c1d6b36acb7038e14d5b3e1fb6a44614a3351f96
commit 6539b102593aa9d9570df8be99ca1a1bf01ea1f4
commit 439e65d3331936e00fa89a4b2f88c343b9e28c5b
commit fac27de7c4918bc5cf1a1ac1a43550236ba8af4d
commit 365989c5bbe5c2289648f6efbc3c9388388e30a0
commit 3dd71364cce9aaaa773fc88eb206aba31aa61390
2014-06-18 20:43:26 -04:00