Tucking citation into the last line of quotation



I would like to automate the following format of the quotation environment:

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxx (Smith, 1992, p.5)

where the last line of the text is short enough to allow space for the
citation to be tucked into the last line, flush right. Where the last
line is too long, the citation should appear on the next line, flush right:

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxx
(Smith, 1992, p.5)

[You will need to be using a monospace font to see what I typed.]

This is similar to the plain TeX format Don uses on p.393 of the TeX
Book, and I'm sure I have seen it implemented in LaTeX, but I can't find
it anywhere, and I'm probably using the wrong search terms in the FAQ
and Google. Does anyone know where/if it has been implemented?

///Peter
.