=?UTF-8?Q?J=C3=B6rg=20H=C3=B6hle=20?=: winmm: Parse MCI colon notation as in T:MM:SS:F.
Alexandre Julliard
julliard at winehq.org
Fri Jan 27 11:30:40 CST 2012
Module: wine
Branch: master
Commit: 644f539358e373cb55dd6cc2c2868d797a330cef
URL: http://source.winehq.org/git/wine.git/?a=commit;h=644f539358e373cb55dd6cc2c2868d797a330cef
Author: Jörg Höhle <hoehle at users.sourceforge.net>
Date: Sun Feb 20 18:50:47 2011 +0100
winmm: Parse MCI colon notation as in T:MM:SS:F.
---
dlls/winmm/mci.c | 49 +++++++++++++++++++++++++++++++++------------
dlls/winmm/tests/mci.c | 33 ++++++++++++++++++++++++++---
dlls/winmm/tests/mcicda.c | 2 +-
3 files changed, 66 insertions(+), 18 deletions(-)
diff --git a/dlls/winmm/mci.c b/dlls/winmm/mci.c
index 9f85bde..ba2fea6 100644
--- a/dlls/winmm/mci.c
+++ b/dlls/winmm/mci.c
@@ -974,23 +974,47 @@ static WORD MCI_GetMessage(LPCWSTR lpCmd)
/**************************************************************************
* MCI_GetDWord [internal]
+ *
+ * Accept 0 -1 255 255:0 255:255:255:255 :::1 1::: 2::3 ::4: 12345678
+ * Refuse -1:0 0:-1 :: 256:0 1:256 0::::1
*/
static BOOL MCI_GetDWord(DWORD* data, LPWSTR* ptr)
{
- DWORD val;
- LPWSTR ret;
-
- val = strtoulW(*ptr, &ret, 10);
+ LPWSTR ret = *ptr;
+ DWORD total = 0, shift = 0;
+ BOOL sign = FALSE, digits = FALSE;
+
+ while (*ret == ' ' || *ret == '\t') ret++;
+ if (*ret == '-') {
+ ret++;
+ sign = TRUE;
+ }
+ for(;;) {
+ DWORD val = 0;
+ while ('0' <= *ret && *ret <= '9') {
+ val = *ret++ - '0' + 10 * val;
+ digits = TRUE;
+ }
+ switch (*ret) {
+ case '\0': break;
+ case '\t':
+ case ' ': ret++; break;
+ default: return FALSE;
+ case ':':
+ if ((val >= 256) || (shift >= 24)) return FALSE;
+ total |= val << shift;
+ shift += 8;
+ ret++;
+ continue;
+ }
- switch (*ret) {
- case '\0': break;
- case ' ': ret++; break;
- default: return FALSE;
+ if (!digits) return FALSE;
+ if (shift && (val >= 256 || sign)) return FALSE;
+ total |= val << shift;
+ *data = sign ? -total : total;
+ *ptr = ret;
+ return TRUE;
}
-
- *data |= val;
- *ptr = ret;
- return TRUE;
}
/**************************************************************************
@@ -1116,7 +1140,6 @@ static DWORD MCI_ParseOptArgs(DWORD* data, int _offset, LPCWSTR lpCmd,
!MCI_GetDWord(&(data[offset+1]), &args) ||
!MCI_GetDWord(&(data[offset+2]), &args) ||
!MCI_GetDWord(&(data[offset+3]), &args)) {
- ERR("Bad rect %s\n", debugstr_w(args));
return MCIERR_BAD_INTEGER;
}
TRACE("flag=%08x for rectangle\n", flg);
diff --git a/dlls/winmm/tests/mci.c b/dlls/winmm/tests/mci.c
index 1cbcc68..5fbd2b8 100644
--- a/dlls/winmm/tests/mci.c
+++ b/dlls/winmm/tests/mci.c
@@ -241,7 +241,7 @@ static void test_mciParser(HWND hwnd)
ok(!buf[0], "status error buffer %s\n", buf);
err = mciSendString("status x track", buf, sizeof(buf), NULL);
- todo_wine ok(err==MCIERR_BAD_INTEGER,"status waveaudio no track: %s\n", dbg_mcierr(err));
+ ok(err==MCIERR_BAD_INTEGER,"status waveaudio no track: %s\n", dbg_mcierr(err));
err = mciSendString("status x track 3", buf, sizeof(buf), NULL);
ok(err==MCIERR_MISSING_PARAMETER,"status waveaudio track 3: %s\n", dbg_mcierr(err));
@@ -273,6 +273,21 @@ static void test_mciParser(HWND hwnd)
err = mciSendString("status x nsa", buf, sizeof(buf), hwnd);
todo_wine ok(err==MCIERR_BAD_CONSTANT,"status nsa: %s\n", dbg_mcierr(err));
+ err = mciSendString("seek x to 0:0:0:0:0", buf, sizeof(buf), NULL);
+ ok(err==MCIERR_BAD_INTEGER,"seek to 0:0:0:0:0 returned %s\n", dbg_mcierr(err));
+
+ err = mciSendString("seek x to 0:0:0:0:", buf, sizeof(buf), NULL);
+ ok(err==MCIERR_BAD_INTEGER,"seek to 0:0:0:0: returned %s\n", dbg_mcierr(err));
+
+ err = mciSendString("seek x to :0:0:0:0", buf, sizeof(buf), NULL);
+ ok(err==MCIERR_BAD_INTEGER,"seek to :0:0:0:0 returned %s\n", dbg_mcierr(err));
+
+ err = mciSendString("seek x to 256:0:0:0", buf, sizeof(buf), NULL);
+ ok(err==MCIERR_BAD_INTEGER,"seek to 256:0:0:0 returned %s\n", dbg_mcierr(err));
+
+ err = mciSendString("seek x to 0:256", buf, sizeof(buf), NULL);
+ ok(err==MCIERR_BAD_INTEGER,"seek to 0:256 returned %s\n", dbg_mcierr(err));
+
err = mciSendString("status all time format", buf, sizeof(buf), hwnd);
ok(err==MCIERR_CANNOT_USE_ALL,"status all: %s\n", dbg_mcierr(err));
@@ -296,7 +311,7 @@ static void test_mciParser(HWND hwnd)
if(!err) ok(!strcmp(buf,"1"), "sysinfo digitalvideo quantity open returned %s\n", buf);
err = mciSendString("put a window at 0 0", buf, sizeof(buf), NULL);
- todo_wine ok(err==MCIERR_BAD_INTEGER,"put incomplete rect: %s\n", dbg_mcierr(err));
+ ok(err==MCIERR_BAD_INTEGER,"put incomplete rect: %s\n", dbg_mcierr(err));
/*w9X-w2k report code from device last opened, newer versions compare them all
* and return the one error code or MCIERR_MULTIPLE if they differ. */
@@ -844,8 +859,8 @@ static void test_playWAVE(HWND hwnd)
/* No notification (checked below) sent if error */
/* A second play caused Wine<1.1.33 to hang */
- err = mciSendString("play mysound from 500 to 1500 wait", NULL, 0, NULL);
- ok(!err,"mci play from 500 to 1500 returned %s\n", dbg_mcierr(err));
+ err = mciSendString("play mysound from 500 to 220:5:0 wait", NULL, 0, NULL);
+ ok(!err,"mci play from 500 to 220:5:0 (=1500) returned %s\n", dbg_mcierr(err));
err = mciSendString("status mysound position", buf, sizeof(buf), hwnd);
ok(!err,"mci status position returned %s\n", dbg_mcierr(err));
@@ -880,6 +895,16 @@ static void test_playWAVE(HWND hwnd)
err = mciSendString("seek mysound to 0xfa", NULL, 0, NULL);
ok(err==MCIERR_BAD_INTEGER,"mci seek to 0xfa returned %s\n", dbg_mcierr(err));
+ /* MCI_INTEGER always accepts colon notation */
+ err = mciSendString("seek mysound to :1", NULL, 0, NULL);
+ ok(!err,"mci seek to :1 (=256) returned %s\n", dbg_mcierr(err));
+
+ err = mciSendString("seek mysound to 250::", NULL, 0, NULL);
+ ok(!err,"mci seek to 250:: returned %s\n", dbg_mcierr(err));
+
+ err = mciSendString("seek mysound to 250:0", NULL, 0, NULL);
+ ok(!err,"mci seek to 250:0 returned %s\n", dbg_mcierr(err));
+
err = mciSendString("status mysound position notify", buf, sizeof(buf), hwnd);
ok(!err,"mci status position notify returned %s\n", dbg_mcierr(err));
if(!err) ok(!strcmp(buf,"250"), "mci status position: %s\n", buf);
diff --git a/dlls/winmm/tests/mcicda.c b/dlls/winmm/tests/mcicda.c
index acd03f0..553679e 100644
--- a/dlls/winmm/tests/mcicda.c
+++ b/dlls/winmm/tests/mcicda.c
@@ -250,7 +250,7 @@ static void test_play(HWND hwnd)
test_notification(hwnd, "status 2flags", err ? 0 : MCI_NOTIFY_SUCCESSFUL);
err = mciSendString("play c from 00:02:00 to 00:01:00 notify", buf, sizeof(buf), hwnd);
- todo_wine ok(err == MCIERR_OUTOFRANGE, "play 2s to 1s: %s\n", dbg_mcierr(err));
+ ok(err == MCIERR_OUTOFRANGE, "play 2s to 1s: %s\n", dbg_mcierr(err));
test_notification(hwnd, "play 2s to 1s", err ? 0 : MCI_NOTIFY_SUCCESSFUL);
err = mciSendString("resume c", buf, sizeof(buf), hwnd);
More information about the wine-cvs
mailing list