diff --git a/programs/winetest/gui.c b/programs/winetest/gui.c index 357676d2e24..97e365d4d5e 100644 --- a/programs/winetest/gui.c +++ b/programs/winetest/gui.c @@ -41,6 +41,8 @@ double progressScale; */ int progressGroup; +WNDPROC DefEditProc; + char * renderString (va_list ap) { @@ -318,22 +320,36 @@ guiAsk (va_list ap) return ret; } +BOOL CALLBACK +EditTagProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) { + case WM_CHAR: + if (wParam == 8) break; /* backspace is OK */ + if (GetWindowTextLengthA (hwnd) == MAXTAGLEN || + !goodtagchar (wParam)) return TRUE; + break; + } + return CallWindowProcA (DefEditProc, hwnd, msg, wParam, lParam); +} + BOOL CALLBACK AskTagProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { int len; switch (msg) { + case WM_INITDIALOG: + DefEditProc = (WNDPROC)SetWindowLongPtr + (GetDlgItem (hwnd, IDC_TAG), GWLP_WNDPROC, (LONG_PTR)EditTagProc); + return TRUE; case WM_COMMAND: switch (LOWORD (wParam)) { case IDOK: len = GetWindowTextLengthA (GetDlgItem (hwnd, IDC_TAG)); - if (len <= MAXTAGLEN) { - tag = xmalloc (len+1); - GetDlgItemTextA (hwnd, IDC_TAG, tag, len+1); - if (!badtagchar (tag)) EndDialog (hwnd, IDOK); - else free (tag); - } + tag = xmalloc (len+1); + GetDlgItemTextA (hwnd, IDC_TAG, tag, len+1); + EndDialog (hwnd, IDOK); return TRUE; case IDABORT: EndDialog (hwnd, IDABORT); diff --git a/programs/winetest/main.c b/programs/winetest/main.c index 05eef4b180e..113cbd671cb 100644 --- a/programs/winetest/main.c +++ b/programs/winetest/main.c @@ -601,7 +601,7 @@ int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, if (strlen (tag) > MAXTAGLEN) report (R_FATAL, "tag is too long (maximum %d characters)", MAXTAGLEN); - cp = badtagchar (tag); + cp = findbadtagchar (tag); if (cp) { report (R_ERROR, "invalid char in tag: %c", *cp); usage (); diff --git a/programs/winetest/util.c b/programs/winetest/util.c index 0365d539f00..8392dec8001 100644 --- a/programs/winetest/util.c +++ b/programs/winetest/util.c @@ -104,15 +104,20 @@ void xprintf (const char *fmt, ...) free (buffer); } +int +goodtagchar (char c) +{ + return (('a'<=c && c<='z') || + ('A'<=c && c<='Z') || + ('0'<=c && c<='9') || + c=='-' || c=='.'); +} + const char * -badtagchar (const char *tag) +findbadtagchar (const char *tag) { while (*tag) - if (('a'<=*tag && *tag<='z') || - ('A'<=*tag && *tag<='Z') || - ('0'<=*tag && *tag<='9') || - *tag=='-' || *tag=='.') - tag++; + if (goodtagchar (*tag)) tag++; else return tag; return NULL; } diff --git a/programs/winetest/winetest.h b/programs/winetest/winetest.h index 79fd43e28f6..2f2c58a8cd8 100644 --- a/programs/winetest/winetest.h +++ b/programs/winetest/winetest.h @@ -33,7 +33,8 @@ void *xrealloc (void *op, size_t len); void xprintf (const char *fmt, ...); char *vstrmake (size_t *lenp, va_list ap); char *strmake (size_t *lenp, ...); -const char *badtagchar (const char *tag); +int goodtagchar (char c); +const char *findbadtagchar (const char *tag); int send_file (const char *name); diff --git a/programs/winetest/winetest.rc b/programs/winetest/winetest.rc index b2f16cd52c8..6846067b147 100644 --- a/programs/winetest/winetest.rc +++ b/programs/winetest/winetest.rc @@ -29,7 +29,7 @@ CAPTION "No tag supplied" BEGIN CTEXT "Please supply a tag for your report. You can use letters, digits, dashes and periods." IDC_STATIC, 10, 5, 130, 30 - EDITTEXT IDC_TAG, 35, 30, 80, 10 + EDITTEXT IDC_TAG, 35, 30, 80, 10, ES_AUTOHSCROLL DEFPUSHBUTTON "Start", IDOK, 25, 45, 40, 14 PUSHBUTTON "Abort", IDABORT, 85, 45, 40, 14 END