Centralize single quote escaping in src/port/quotes.c

For code-reuse in upcoming functionality in pg_basebackup.

Zoltan Boszormenyi