shaper: add FriBidi error handling

It is unlikely, but FriBidi might not process a string correctly,
and we should handle that. Tested by making it fail always. This
should also fix some compiler warnings.
Merge pull request #102 from grigorig/fribidi-errorhandle

shaper: add FriBidi error handling
Add initial (very buggy) multithreading code

Conflicts:
	libass/ass_render.c
Well hopefully this is slightly better
It works!

Conflicts:
	libass/ass_render.c
Remove debug SHIT

Conflicts:
	libass/ass_render.c
Tweaks

Conflicts:
	libass/ass_render.c
Disable final fix_collisions() for now
Don't be a total idiot in qsort
Forgot an ifdef
Fix that edge case?
Remove unnecessary (no, really this time) check
Added configure option to disable pthreads

Conflicts:
	libass/ass_render.c
Use one free list per thread
Strip trailing whitespace

Conflicts:
	libass/ass_render.c
Hopefully avoid a hang
Race fix
Do that merge-caches thing zgreg suggested
Bunch of improvements/fixes to cache merging
Use atomics, since they're fast and all