From 5a1c7338412a003a6bd0238be7bee84d040e3561 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 10 Feb 2017 20:37:05 -0500 Subject: [PATCH] Something is wrong with the Windows code... --- common/drawtext.c | 1 + windows/graphemes.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/common/drawtext.c b/common/drawtext.c index c55227f1..cbfe3ccb 100644 --- a/common/drawtext.c +++ b/common/drawtext.c @@ -2,6 +2,7 @@ #include "../ui.h" #include "uipriv.h" +// TODO figure out how to make this work on GTK+ void uiDrawCaret(uiDrawContext *c, double x, double y, uiDrawTextLayout *layout, size_t pos, int *line) { double xoff; diff --git a/windows/graphemes.cpp b/windows/graphemes.cpp index 2b93fab4..16f2fd82 100644 --- a/windows/graphemes.cpp +++ b/windows/graphemes.cpp @@ -21,12 +21,11 @@ static HRESULT itemize(WCHAR *s, size_t len, SCRIPT_ITEM **out, int *outn) int n; HRESULT hr; - // make sure these are zero-initialized to avoid mangling the text - ZeroMemory(&sc, sizeof (SCRIPT_CONTROL)); - ZeroMemory(&ss, sizeof (SCRIPT_STATE)); - maxItems = len + 2; for (;;) { + // make sure these are zero-initialized to avoid mangling the text + ZeroMemory(&sc, sizeof (SCRIPT_CONTROL)); + ZeroMemory(&ss, sizeof (SCRIPT_STATE)); items = new SCRIPT_ITEM[maxItems + 1]; hr = ScriptItemize(s, len, maxItems, @@ -101,8 +100,9 @@ struct graphemes *graphemes(void *s, size_t len) delete[] logattr; } // and handle the last item for the end of the string - *pGTP++ = items[nItems].iCharPos; - *pPTG++ = pGTP - g->graphemesToPoints; + *pGTP = items[nItems].iCharPos; + *pPTG = pGTP - g->graphemesToPoints; + // TODO is any of the above broken?... also for all platforms, are the last few bytes not covered? delete[] items; return g;