Move reused GRES parsing logic to a shared function. (Corrected author; was previously mis-committed as 433257c6.) Bug 5743.