diff options
author | Ken Sharp <ken.sharp@artifex.com> | 2009-05-08 13:13:26 +0000 |
---|---|---|
committer | Ken Sharp <ken.sharp@artifex.com> | 2009-05-08 13:13:26 +0000 |
commit | bd4727138d1796cd63779400a05102adb37791b3 (patch) | |
tree | a4dd31b9ccb352c4d86a36667f3e4266641134cb | |
parent | 29c5c08972992c510faedd4858a679c2eb0bfcec (diff) | |
download | ghostpdl-bd4727138d1796cd63779400a05102adb37791b3.tar.gz |
Fix : Windows drag&drop has a fixed path limit of 80 characters.
Details
Bug #690461 "ghostscript can't handle files with long name-paths"
The real issue is that the drag-and-drop interface had a fixed buffer of 80
characters, and was unable to process files beyond that limit.
It looks like the original code was from some boiler plate sample. Updated the code
to use the DragQeryFiles API call to find the length of the full path specification
and then malloc a buffer to hold it. Although we would never normally use the system
malloc call, this should not be a problem in the Windows-specific code.
Expected Differences
None
git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@9731 a1074d23-0009-0410-80fe-cf8c14f379e6
-rw-r--r-- | gs/psi/dwimg.c | 30 | ||||
-rw-r--r-- | gs/psi/dwtext.c | 30 |
2 files changed, 38 insertions, 22 deletions
diff --git a/gs/psi/dwimg.c b/gs/psi/dwimg.c index 4c84e5727..31e1f5070 100644 --- a/gs/psi/dwimg.c +++ b/gs/psi/dwimg.c @@ -1437,25 +1437,33 @@ WndImg2Proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if (img->hwndtext) SendMessage(img->hwndtext, message, wParam, lParam); else { - char szFile[256]; + char *szFile; int i, cFiles; + unsigned int Len, error; const char *p; const char *szDragPre = "\r("; const char *szDragPost = ") run\r"; HDROP hdrop = (HDROP)wParam; cFiles = DragQueryFile(hdrop, (UINT)(-1), (LPSTR)NULL, 0); for (i=0; i<cFiles; i++) { - DragQueryFile(hdrop, i, szFile, 80); - for (p=szDragPre; *p; p++) - SendMessage(hwnd,WM_CHAR,*p,1L); - for (p=szFile; *p; p++) { - if (*p == '\\') - SendMessage(hwnd,WM_CHAR,'/',1L); - else - SendMessage(hwnd,WM_CHAR,*p,1L); + Len = DragQueryFile(hdrop, i, NULL, 0); + szFile = malloc(Len+1); + if (szFile != 0) { + error = DragQueryFile(hdrop, i, szFile, Len+1); + if (error != 0) { + for (p=szDragPre; *p; p++) + SendMessage(hwnd,WM_CHAR,*p,1L); + for (p=szFile; *p; p++) { + if (*p == '\\') + SendMessage(hwnd,WM_CHAR,'/',1L); + else + SendMessage(hwnd,WM_CHAR,*p,1L); + } + for (p=szDragPost; *p; p++) + SendMessage(hwnd,WM_CHAR,*p,1L); + } + free(szFile); } - for (p=szDragPost; *p; p++) - SendMessage(hwnd,WM_CHAR,*p,1L); } DragFinish(hdrop); } diff --git a/gs/psi/dwtext.c b/gs/psi/dwtext.c index 58224eb2a..5572a3592 100644 --- a/gs/psi/dwtext.c +++ b/gs/psi/dwtext.c @@ -652,25 +652,33 @@ int ch; void text_drag_drop(TW *tw, HDROP hdrop) { - char szFile[256]; + char *szFile; int i, cFiles; + unsigned int Len, error; const char *p; if ( (tw->DragPre==NULL) || (tw->DragPost==NULL) ) return; cFiles = DragQueryFile(hdrop, (UINT)(-1), (LPSTR)NULL, 0); for (i=0; i<cFiles; i++) { - DragQueryFile(hdrop, i, szFile, 80); - for (p=tw->DragPre; *p; p++) - SendMessage(tw->hwnd,WM_CHAR,*p,1L); - for (p=szFile; *p; p++) { - if (*p == '\\') - SendMessage(tw->hwnd,WM_CHAR,'/',1L); - else - SendMessage(tw->hwnd,WM_CHAR,*p,1L); + Len = DragQueryFile(hdrop, i, NULL, 0); + szFile = (char *)malloc(Len+1); + if (szFile != 0) { + error = DragQueryFile(hdrop, i, szFile, Len+1); + if (error != 0) { + for (p=tw->DragPre; *p; p++) + SendMessage(tw->hwnd,WM_CHAR,*p,1L); + for (p=szFile; *p; p++) { + if (*p == '\\') + SendMessage(tw->hwnd,WM_CHAR,'/',1L); + else + SendMessage(tw->hwnd,WM_CHAR,*p,1L); + } + for (p=tw->DragPost; *p; p++) + SendMessage(tw->hwnd,WM_CHAR,*p,1L); + } + free(szFile); } - for (p=tw->DragPost; *p; p++) - SendMessage(tw->hwnd,WM_CHAR,*p,1L); } DragFinish(hdrop); } |