Fix detecting newer version of pkgng
repo: Fix missing package path when multiple versions of a package exist

Fixes:	#524
Remove typo
O_TTY_INIT is posix so not having it is a strangeness of dragonfly

Reported by:	jilles
Fix potential deferencement of null pointer
Fix potential dereferencement of NULL pointer
Plug a memory leak
Fix typo

Reported by:	matthew, marino
Fix in _pkg_available() for zsh completion

Fixes:		#526
Reported by:	Marwan Burelle