On Tue May 21 09:53:24 2024 +0000, eric pouech wrote:
> using strtol would be better and save you the str_is_number helper
I can switch to strtol, but how does it save the `str_is_number` helper? It returns 0, which is a valid (if useless) timeout value for the native program.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/5691#note_71016
On Tue May 21 12:09:30 2024 +0000, eric pouech wrote:
> I'd rather see this outside the do/while loop (and moreover, the second
> count down shall be printed after this message)
Yes, but it only overrides the "Waiting for %s seconds" part, which mostly matches Windows' behavior (from the cursor position). The only difference is that Windows will end at "Waiting for N". While it's possible to replicate this, I believe it may cause issues with translations.
I can move it outside the do/while loop though.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/5691#note_71014
On Tue May 21 10:23:40 2024 +0000, eric pouech wrote:
> why do you need float operations here? (int)(ticks_remaining / 1000)
> should do
It needs to be rounded because otherwise it will start with printing "Waiting for N-1 seconds" due to one or more ticks having elapsed (at least on my machine). But yes, I could do an int roundup instead (`(ticks_remaining + 500) / 1000`).
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/5691#note_71013
eric pouech (@epo) commented about programs/timeout/timeout_main.c:
> +
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include <conio.h>
> +#include <math.h>
> +
> +#include <windows.h>
> +
> +#include "resources.h"
> +
> +#include <wine/debug.h>
> +
> +WINE_DEFAULT_DEBUG_CHANNEL(timeout);
> +
> +static char* get_string(int which)
a couple of remarks here (about the helpers for printing):
- returning ASCII strings could lose some bits in conversion, so you'd be safer keeping unicode string
- also usage of (w)printf can lack flexibility in translations (it assumes all parameters have the same order whatever the translation). FormatMessage brings more flexibility as you can change the order of parameters in output.
- and likely RPRINTF_VA could be rewritten as a function and not a macro
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/5691#note_71012
On Tue May 21 09:53:24 2024 +0000, eric pouech wrote:
> to be pedantic, native only allows one timeout value and prints error
> when two are given
using strtol would be better and save you the str_is_number helper
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/5691#note_71008