# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1332863856 0 # Node ID 0e8c80209c4b76e5c80184ea22945fd774578d82 # Parent 32b5fba0b00a058cff94cb2c3351b14df6933726 Rewrite of _get_logfont on Windows to use library functions and not overrun the buffer in Unicode mode. Also use _strdup() instead of strdup(). diff -r 32b5fba0b00a -r 0e8c80209c4b win/dw.c --- a/win/dw.c Tue Mar 27 15:09:52 2012 +0000 +++ b/win/dw.c Tue Mar 27 15:57:36 2012 +0000 @@ -2820,7 +2820,7 @@ val = (long)SendMessage(cinfo->buddy, UDM_GETPOS32, 0, 0); - _stprintf(tmpbuf, TEXT("%ld"), val); + _sntprintf(tmpbuf, 99, TEXT("%ld"), val); SetWindowText(hWnd, tmpbuf); } } @@ -4396,21 +4396,6 @@ } } -int instring(char *text, char *buffer) -{ - int z, len = (int)strlen(text), buflen = (int)strlen(buffer); - - if(buflen > len) - { - for(z=0;z<=(buflen-len);z++) - { - if(memcmp(text, &buffer[z], len) == 0) - return z; - } - } - return 0; -} - /* * Changes a window's parent to newparent. * Parameters: @@ -4424,20 +4409,19 @@ LOGFONT _get_logfont(HDC hdc, char *fontname) { - int z, size = 9, len = (int)strlen(fontname); - int Italic, Bold; - char *myFontName; + char *Italic, *Bold, *myFontName = strchr(fontname, '.'); + int size = atoi(fontname); LOGFONT lf = {0}; - for(z=0;z