diff options
author | Robin Watts <Robin.Watts@artifex.com> | 2012-03-15 17:26:58 +0000 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2012-03-15 17:26:58 +0000 |
commit | 22bbb6e6d3bcd01b164e91ecf500dc9d7305269e (patch) | |
tree | cde6173a254405701e712612300521a8f93f9a21 | |
parent | 789c740e33c0cc381e8f23327c7745cbdaa4c860 (diff) | |
download | mupdf-22bbb6e6d3bcd01b164e91ecf500dc9d7305269e.tar.xz |
Bug 692866: Do not add a final newline when cutting/pasting.
Previously MuPDF would add a newline at the end of every line.
As requested in the bug, we here avoid adding a final newline.
Unlike the suggested patch, we avoid adding one, rather than
removing one.
-rw-r--r-- | apps/pdfapp.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/apps/pdfapp.c b/apps/pdfapp.c index 556368ec..ad7764ee 100644 --- a/apps/pdfapp.c +++ b/apps/pdfapp.c @@ -1109,7 +1109,7 @@ void pdfapp_oncopy(pdfapp_t *app, unsigned short *ucsbuf, int ucslen) fz_text_line *line; fz_text_span *span; int c, i, p; - int seen; + int seen = 0; int x0 = app->selr.x0; int x1 = app->selr.x1; @@ -1126,6 +1126,16 @@ void pdfapp_oncopy(pdfapp_t *app, unsigned short *ucsbuf, int ucslen) { for (span = line->spans; span < line->spans + line->len; span++) { + if (seen) + { +#ifdef _WIN32 + if (p < ucslen - 1) + ucsbuf[p++] = '\r'; +#endif + if (p < ucslen - 1) + ucsbuf[p++] = '\n'; + } + seen = 0; for (i = 0; i < span->len; i++) @@ -1143,15 +1153,7 @@ void pdfapp_oncopy(pdfapp_t *app, unsigned short *ucsbuf, int ucslen) } } - if (seen && span + 1 == line->spans + line->len) - { -#ifdef _WIN32 - if (p < ucslen - 1) - ucsbuf[p++] = '\r'; -#endif - if (p < ucslen - 1) - ucsbuf[p++] = '\n'; - } + seen = (seen && span + 1 == line->spans + line->len); } } } |