g_get_current_dir(): consult PWD first

Check if the current directory is the same as $PWD.  This matches the
behaviour of the get_current_dir_name() function in glibc.

https://bugzilla.gnome.org/show_bug.cgi?id=705902