[PATCH] Re: help fixing up SetConsoleCtrlHandler()
Peter Riocreux
par+wine_devel at silistix.com
Thu Apr 15 09:23:25 CDT 2004
"Dimitrie O. Paun" <dimi at intelliware.ca> writes:
> On Thu, 15 Apr 2004, Peter Riocreux wrote:
>
>> I don't know, I just had thought that Wine was attempting to be
>> bug-for-bug compatible, and assumed that part of that was honouring
>> all the restrictions on usage of functions and how these varied
>> between versions.
>
> We are not *that* compatible. it would lead to madness. Soon.
> In general, unless applications really depend on 9x specific
> functionality, we just follow the NT behaviour.
I can't see anyone relying on using something they know to be
wrong. *That* would also be madness....
>> I am not seeing this FIXME coming out, so I am not concerned with
>> leaving it in, but have no strong opinion.
>
> Yes, I think it should either go, or be made into a TRACE.
I have turned it into a trace.
Patch below.
Peter
Index: dlls/kernel/console.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/console.c,v
retrieving revision 1.30
diff -u -r1.30 console.c
--- dlls/kernel/console.c 13 Apr 2004 21:16:26 -0000 1.30
+++ dlls/kernel/console.c 15 Apr 2004 14:20:57 -0000
@@ -1448,17 +1448,20 @@
{
BOOL ret = TRUE;
- FIXME("(%p,%i) - no error checking or testing yet\n", func, add);
-
if (!func)
{
+ TRACE("(%p,%i) - first arg being NULL is not allowed in WinME, Win98 or Win95\n", func, add);
CONSOLE_IgnoreCtrlC = add;
}
else if (add)
{
struct ConsoleHandler* ch = HeapAlloc(GetProcessHeap(), 0, sizeof(struct ConsoleHandler));
- if (!ch) return FALSE;
+ if (!ch)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return FALSE;
+ }
ch->handler = func;
RtlEnterCriticalSection(&CONSOLE_CritSect);
ch->next = CONSOLE_Handlers;
@@ -1467,34 +1470,37 @@
}
else
{
- struct ConsoleHandler** ch;
RtlEnterCriticalSection(&CONSOLE_CritSect);
- for (ch = &CONSOLE_Handlers; *ch; *ch = (*ch)->next)
- {
- if ((*ch)->handler == func) break;
- }
- if (*ch)
- {
- struct ConsoleHandler* rch = *ch;
+ if (func == CONSOLE_DefaultHandler)
+ {
+ ERR("Attempt to remove default CtrlHandler %p\n", func);
+ SetLastError(ERROR_FUNCTION_FAILED);
+ ret = FALSE;
+ }
+ else
+ {
+ struct ConsoleHandler* ch, * prev ;
+ prev = NULL;
+ for (ch = CONSOLE_Handlers; ch; prev = ch, ch = ch->next)
+ {
+ if (ch->handler == func)
+ {
+ if (ch == CONSOLE_Handlers)
+ CONSOLE_Handlers = ch->next;
+ else
+ prev->next = ch->next;
+ HeapFree(GetProcessHeap(), 0, ch);
+ break;
+ }
+ }
- /* sanity check */
- if (rch == &CONSOLE_DefaultConsoleHandler)
- {
- ERR("Who's trying to remove default handler???\n");
- ret = FALSE;
- }
- else
- {
- rch = *ch;
- *ch = (*ch)->next;
- HeapFree(GetProcessHeap(), 0, rch);
- }
- }
- else
- {
- WARN("Attempt to remove non-installed CtrlHandler %p\n", func);
- ret = FALSE;
- }
+ if (! ch)
+ {
+ WARN("Attempt to remove non-installed CtrlHandler %p\n", func);
+ SetLastError(ERROR_INVALID_ADDRESS);
+ ret = FALSE;
+ }
+ }
RtlLeaveCriticalSection(&CONSOLE_CritSect);
}
return ret;
More information about the wine-devel
mailing list