From 015ff084e31a4202513d202c7a2362a4d6c59f1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Fri, 25 Aug 2023 11:23:41 +0200 Subject: [PATCH] core: add microseconds precision in function util_parse_delay --- po/cs.po | 8 ++-- po/de.po | 47 +++++++++++++++++-- po/es.po | 8 ++-- po/fr.po | 16 ++++--- po/hu.po | 8 ++-- po/it.po | 8 ++-- po/ja.po | 47 +++++++++++++++++-- po/pl.po | 47 +++++++++++++++++-- po/pt.po | 8 ++-- po/pt_BR.po | 8 ++-- po/ru.po | 8 ++-- po/sr.po | 47 +++++++++++++++++-- po/tr.po | 47 +++++++++++++++++-- po/weechat.pot | 8 ++-- src/core/wee-command.c | 19 +++++--- src/core/wee-util.c | 42 +++++++++-------- src/core/wee-util.h | 3 +- tests/unit/core/test-core-util.cpp | 75 +++++++++++++++++------------- 18 files changed, 350 insertions(+), 104 deletions(-) diff --git a/po/cs.po b/po/cs.po index 7f5f7b19d..99f53ad98 100644 --- a/po/cs.po +++ b/po/cs.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-08-24 18:16+0200\n" +"POT-Creation-Date: 2023-08-25 11:16+0200\n" "PO-Revision-Date: 2023-06-26 21:34+0200\n" "Last-Translator: Ondřej Súkup \n" "Language-Team: weechat-dev \n" @@ -2418,8 +2418,9 @@ msgstr "[-interval ] " #, fuzzy msgid "" -" delay: delay between execution of commands\n" +" delay: delay between execution of commands (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" @@ -2806,8 +2807,9 @@ msgstr "<číslo>[] " #, fuzzy msgid "" -" number: amount of time to wait (integer number)\n" +" number: amount of time to wait (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" diff --git a/po/de.po b/po/de.po index 80b208c2a..c13f247c6 100644 --- a/po/de.po +++ b/po/de.po @@ -26,7 +26,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-08-24 18:16+0200\n" +"POT-Creation-Date: 2023-08-25 11:16+0200\n" "PO-Revision-Date: 2023-08-24 13:36+0200\n" "Last-Translator: Nils Görs \n" "Language-Team: German \n" @@ -3118,9 +3118,28 @@ msgstr "führt einen Befehl mehrfach aus" msgid "[-interval []] " msgstr "[-interval []] " +#, fuzzy +#| msgid "" +#| " delay: delay between execution of commands\n" +#| " unit: optional, values are:\n" +#| " ms: milliseconds\n" +#| " s: seconds (default)\n" +#| " m: minutes\n" +#| " h: hours\n" +#| " count: number of times to execute command\n" +#| "command: command to execute (or text to send to buffer if command does " +#| "not start with '/')\n" +#| "\n" +#| "Note: the command is executed on buffer where /repeat was executed (if " +#| "the buffer does not exist any more, the command is not executed).\n" +#| "\n" +#| "Example:\n" +#| " scroll 2 pages up:\n" +#| " /repeat 2 /window page_up" msgid "" -" delay: delay between execution of commands\n" +" delay: delay between execution of commands (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" @@ -3645,9 +3664,31 @@ msgstr "Terminiere einen Befehl der ausgeführt werden soll" msgid "[] " msgstr "[] " +#, fuzzy +#| msgid "" +#| " number: amount of time to wait (integer number)\n" +#| " unit: optional, values are:\n" +#| " ms: milliseconds\n" +#| " s: seconds (default)\n" +#| " m: minutes\n" +#| " h: hours\n" +#| "command: command to execute (or text to send to buffer if command does " +#| "not start with '/')\n" +#| "\n" +#| "Note: the command is executed on buffer where /wait was executed (if the " +#| "buffer does not exist any more, the command is not executed).\n" +#| "\n" +#| "Examples:\n" +#| " join channel in 10 seconds:\n" +#| " /wait 10 /join #test\n" +#| " set away in 15 minutes:\n" +#| " /wait 15m /away -all I'm away\n" +#| " say 'hello' in 2 minutes:\n" +#| " /wait 2m hello" msgid "" -" number: amount of time to wait (integer number)\n" +" number: amount of time to wait (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" diff --git a/po/es.po b/po/es.po index d5d5b1ec8..16a756334 100644 --- a/po/es.po +++ b/po/es.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-08-24 18:16+0200\n" +"POT-Creation-Date: 2023-08-25 11:16+0200\n" "PO-Revision-Date: 2023-06-26 21:34+0200\n" "Last-Translator: Santiago Forero \n" "Language-Team: weechat-dev \n" @@ -2964,8 +2964,9 @@ msgstr "[-interval ] " #, fuzzy msgid "" -" delay: delay between execution of commands\n" +" delay: delay between execution of commands (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" @@ -3351,8 +3352,9 @@ msgstr "[] " #, fuzzy msgid "" -" number: amount of time to wait (integer number)\n" +" number: amount of time to wait (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" diff --git a/po/fr.po b/po/fr.po index 6a5fd61a1..ed9c32aa7 100644 --- a/po/fr.po +++ b/po/fr.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-08-24 18:16+0200\n" -"PO-Revision-Date: 2023-08-24 18:18+0200\n" +"POT-Creation-Date: 2023-08-25 11:16+0200\n" +"PO-Revision-Date: 2023-08-25 11:18+0200\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" "Language: fr\n" @@ -3045,8 +3045,9 @@ msgid "[-interval []] " msgstr "[-interval []] " msgid "" -" delay: delay between execution of commands\n" +" delay: delay between execution of commands (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" @@ -3062,8 +3063,9 @@ msgid "" " scroll 2 pages up:\n" " /repeat 2 /window page_up" msgstr "" -" délai : délai entre l'exécution des commandes\n" +" délai : délai entre l'exécution des commandes (minimum : 1 milliseconde)\n" " unité : optionnelle, valeurs possibles :\n" +" us : microsecondes\n" " ms : millisecondes\n" " s : secondes (par défaut)\n" " m : minutes\n" @@ -3559,8 +3561,9 @@ msgid "[] " msgstr "[] " msgid "" -" number: amount of time to wait (integer number)\n" +" number: amount of time to wait (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" @@ -3579,8 +3582,9 @@ msgid "" " say 'hello' in 2 minutes:\n" " /wait 2m hello" msgstr "" -" nombre : temps à attendre (nombre entier)\n" +" nombre : temps à attendre (minimum : 1 milliseconde)\n" " unité : optionnelle, valeurs possibles :\n" +" us : microsecondes\n" " ms : millisecondes\n" " s : secondes (par défaut)\n" " m : minutes\n" diff --git a/po/hu.po b/po/hu.po index 8409a5d07..fd17b7a81 100644 --- a/po/hu.po +++ b/po/hu.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-08-24 18:16+0200\n" +"POT-Creation-Date: 2023-08-25 11:16+0200\n" "PO-Revision-Date: 2023-06-17 11:47+0200\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -2185,8 +2185,9 @@ msgstr "Modul parancsok:\n" #, fuzzy msgid "" -" delay: delay between execution of commands\n" +" delay: delay between execution of commands (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" @@ -2488,8 +2489,9 @@ msgstr "" #, fuzzy msgid "" -" number: amount of time to wait (integer number)\n" +" number: amount of time to wait (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" diff --git a/po/it.po b/po/it.po index 6bbb64895..a8adf4369 100644 --- a/po/it.po +++ b/po/it.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-08-24 18:16+0200\n" +"POT-Creation-Date: 2023-08-25 11:16+0200\n" "PO-Revision-Date: 2023-06-26 21:34+0200\n" "Last-Translator: Esteban I. Ruiz Moreno \n" "Language-Team: weechat-dev \n" @@ -2562,8 +2562,9 @@ msgstr "[-interval ] " #, fuzzy msgid "" -" delay: delay between execution of commands\n" +" delay: delay between execution of commands (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" @@ -2948,8 +2949,9 @@ msgstr "[] " #, fuzzy msgid "" -" number: amount of time to wait (integer number)\n" +" number: amount of time to wait (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" diff --git a/po/ja.po b/po/ja.po index a8ea7c0a2..c0ecf14ee 100644 --- a/po/ja.po +++ b/po/ja.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-08-24 18:16+0200\n" +"POT-Creation-Date: 2023-08-25 11:16+0200\n" "PO-Revision-Date: 2023-08-08 07:13+0200\n" "Last-Translator: AYANOKOUZI, Ryuunosuke \n" "Language-Team: Japanese []] " msgstr "[-interval []] " +#, fuzzy +#| msgid "" +#| " delay: delay between execution of commands\n" +#| " unit: optional, values are:\n" +#| " ms: milliseconds\n" +#| " s: seconds (default)\n" +#| " m: minutes\n" +#| " h: hours\n" +#| " count: number of times to execute command\n" +#| "command: command to execute (or text to send to buffer if command does " +#| "not start with '/')\n" +#| "\n" +#| "Note: the command is executed on buffer where /repeat was executed (if " +#| "the buffer does not exist any more, the command is not executed).\n" +#| "\n" +#| "Example:\n" +#| " scroll 2 pages up:\n" +#| " /repeat 2 /window page_up" msgid "" -" delay: delay between execution of commands\n" +" delay: delay between execution of commands (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" @@ -3502,9 +3521,31 @@ msgstr "コマンドの実行を予約" msgid "[] " msgstr "[] " +#, fuzzy +#| msgid "" +#| " number: amount of time to wait (integer number)\n" +#| " unit: optional, values are:\n" +#| " ms: milliseconds\n" +#| " s: seconds (default)\n" +#| " m: minutes\n" +#| " h: hours\n" +#| "command: command to execute (or text to send to buffer if command does " +#| "not start with '/')\n" +#| "\n" +#| "Note: the command is executed on buffer where /wait was executed (if the " +#| "buffer does not exist any more, the command is not executed).\n" +#| "\n" +#| "Examples:\n" +#| " join channel in 10 seconds:\n" +#| " /wait 10 /join #test\n" +#| " set away in 15 minutes:\n" +#| " /wait 15m /away -all I'm away\n" +#| " say 'hello' in 2 minutes:\n" +#| " /wait 2m hello" msgid "" -" number: amount of time to wait (integer number)\n" +" number: amount of time to wait (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" diff --git a/po/pl.po b/po/pl.po index 301ca138a..5c197bf4a 100644 --- a/po/pl.po +++ b/po/pl.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-08-24 18:16+0200\n" +"POT-Creation-Date: 2023-08-25 11:16+0200\n" "PO-Revision-Date: 2023-08-08 07:13+0200\n" "Last-Translator: Krzysztof Korościk \n" "Language-Team: Polish \n" @@ -3487,9 +3487,28 @@ msgstr "wykonuje komendę kilka razy" msgid "[-interval []] " msgstr "[-interval []] " +#, fuzzy +#| msgid "" +#| " delay: delay between execution of commands\n" +#| " unit: optional, values are:\n" +#| " ms: milliseconds\n" +#| " s: seconds (default)\n" +#| " m: minutes\n" +#| " h: hours\n" +#| " count: number of times to execute command\n" +#| "command: command to execute (or text to send to buffer if command does " +#| "not start with '/')\n" +#| "\n" +#| "Note: the command is executed on buffer where /repeat was executed (if " +#| "the buffer does not exist any more, the command is not executed).\n" +#| "\n" +#| "Example:\n" +#| " scroll 2 pages up:\n" +#| " /repeat 2 /window page_up" msgid "" -" delay: delay between execution of commands\n" +" delay: delay between execution of commands (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" @@ -4007,9 +4026,31 @@ msgstr "planuje komendę do wykonania w przyszłości" msgid "[] " msgstr "[] " +#, fuzzy +#| msgid "" +#| " number: amount of time to wait (integer number)\n" +#| " unit: optional, values are:\n" +#| " ms: milliseconds\n" +#| " s: seconds (default)\n" +#| " m: minutes\n" +#| " h: hours\n" +#| "command: command to execute (or text to send to buffer if command does " +#| "not start with '/')\n" +#| "\n" +#| "Note: the command is executed on buffer where /wait was executed (if the " +#| "buffer does not exist any more, the command is not executed).\n" +#| "\n" +#| "Examples:\n" +#| " join channel in 10 seconds:\n" +#| " /wait 10 /join #test\n" +#| " set away in 15 minutes:\n" +#| " /wait 15m /away -all I'm away\n" +#| " say 'hello' in 2 minutes:\n" +#| " /wait 2m hello" msgid "" -" number: amount of time to wait (integer number)\n" +" number: amount of time to wait (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" diff --git a/po/pt.po b/po/pt.po index 4e0b4686e..0551615c5 100644 --- a/po/pt.po +++ b/po/pt.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-08-24 18:16+0200\n" +"POT-Creation-Date: 2023-08-25 11:16+0200\n" "PO-Revision-Date: 2023-06-26 21:34+0200\n" "Last-Translator: Vasco Almeida \n" "Language-Team: Portuguese <>\n" @@ -3018,8 +3018,9 @@ msgstr "[-interval ] " #, fuzzy msgid "" -" delay: delay between execution of commands\n" +" delay: delay between execution of commands (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" @@ -3493,8 +3494,9 @@ msgstr "[] " #, fuzzy msgid "" -" number: amount of time to wait (integer number)\n" +" number: amount of time to wait (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" diff --git a/po/pt_BR.po b/po/pt_BR.po index 0ad2eedaa..ef5029b89 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-08-24 18:16+0200\n" +"POT-Creation-Date: 2023-08-25 11:16+0200\n" "PO-Revision-Date: 2023-06-26 21:34+0200\n" "Last-Translator: Érico Nogueira \n" "Language-Team: weechat-dev \n" @@ -2627,8 +2627,9 @@ msgstr "[-interval ] " #, fuzzy msgid "" -" delay: delay between execution of commands\n" +" delay: delay between execution of commands (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" @@ -3037,8 +3038,9 @@ msgstr "[] " #, fuzzy msgid "" -" number: amount of time to wait (integer number)\n" +" number: amount of time to wait (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" diff --git a/po/ru.po b/po/ru.po index 64830f8cf..e53add418 100644 --- a/po/ru.po +++ b/po/ru.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-08-24 18:16+0200\n" +"POT-Creation-Date: 2023-08-25 11:16+0200\n" "PO-Revision-Date: 2023-06-17 11:47+0200\n" "Last-Translator: Aleksey V Zapparov AKA ixti \n" "Language-Team: weechat-dev \n" @@ -2207,8 +2207,9 @@ msgstr "Команды Plugin'ов:\n" #, fuzzy msgid "" -" delay: delay between execution of commands\n" +" delay: delay between execution of commands (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" @@ -2510,8 +2511,9 @@ msgstr "" #, fuzzy msgid "" -" number: amount of time to wait (integer number)\n" +" number: amount of time to wait (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" diff --git a/po/sr.po b/po/sr.po index 920e1bd04..bc25f60e1 100644 --- a/po/sr.po +++ b/po/sr.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-08-24 18:16+0200\n" +"POT-Creation-Date: 2023-08-25 11:16+0200\n" "PO-Revision-Date: 2023-08-08 07:14+0200\n" "Last-Translator: Ivan Pešić \n" "Language-Team: weechat-dev \n" @@ -3083,9 +3083,28 @@ msgstr "извршавање команде неколико пута" msgid "[-interval []] " msgstr "[-interval <кашњење>[<јединица>]] <број> <команда>" +#, fuzzy +#| msgid "" +#| " delay: delay between execution of commands\n" +#| " unit: optional, values are:\n" +#| " ms: milliseconds\n" +#| " s: seconds (default)\n" +#| " m: minutes\n" +#| " h: hours\n" +#| " count: number of times to execute command\n" +#| "command: command to execute (or text to send to buffer if command does " +#| "not start with '/')\n" +#| "\n" +#| "Note: the command is executed on buffer where /repeat was executed (if " +#| "the buffer does not exist any more, the command is not executed).\n" +#| "\n" +#| "Example:\n" +#| " scroll 2 pages up:\n" +#| " /repeat 2 /window page_up" msgid "" -" delay: delay between execution of commands\n" +" delay: delay between execution of commands (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" @@ -3582,9 +3601,31 @@ msgstr "планирање извршавања команде у будућно msgid "[] " msgstr "<број>[<јединица>] <команда>" +#, fuzzy +#| msgid "" +#| " number: amount of time to wait (integer number)\n" +#| " unit: optional, values are:\n" +#| " ms: milliseconds\n" +#| " s: seconds (default)\n" +#| " m: minutes\n" +#| " h: hours\n" +#| "command: command to execute (or text to send to buffer if command does " +#| "not start with '/')\n" +#| "\n" +#| "Note: the command is executed on buffer where /wait was executed (if the " +#| "buffer does not exist any more, the command is not executed).\n" +#| "\n" +#| "Examples:\n" +#| " join channel in 10 seconds:\n" +#| " /wait 10 /join #test\n" +#| " set away in 15 minutes:\n" +#| " /wait 15m /away -all I'm away\n" +#| " say 'hello' in 2 minutes:\n" +#| " /wait 2m hello" msgid "" -" number: amount of time to wait (integer number)\n" +" number: amount of time to wait (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" diff --git a/po/tr.po b/po/tr.po index 61806995b..735986fc7 100644 --- a/po/tr.po +++ b/po/tr.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-08-24 18:16+0200\n" +"POT-Creation-Date: 2023-08-25 11:16+0200\n" "PO-Revision-Date: 2023-08-08 07:14+0200\n" "Last-Translator: Emir SARI \n" "Language-Team: weechat-dev \n" @@ -3100,9 +3100,28 @@ msgstr "bir komutu birden çok kez yürüt" msgid "[-interval []] " msgstr "[-interval []] " +#, fuzzy +#| msgid "" +#| " delay: delay between execution of commands\n" +#| " unit: optional, values are:\n" +#| " ms: milliseconds\n" +#| " s: seconds (default)\n" +#| " m: minutes\n" +#| " h: hours\n" +#| " count: number of times to execute command\n" +#| "command: command to execute (or text to send to buffer if command does " +#| "not start with '/')\n" +#| "\n" +#| "Note: the command is executed on buffer where /repeat was executed (if " +#| "the buffer does not exist any more, the command is not executed).\n" +#| "\n" +#| "Example:\n" +#| " scroll 2 pages up:\n" +#| " /repeat 2 /window page_up" msgid "" -" delay: delay between execution of commands\n" +" delay: delay between execution of commands (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" @@ -3606,9 +3625,31 @@ msgstr "gelecekte yürütülmek üzere bir komut zamanla" msgid "[] " msgstr "[] " +#, fuzzy +#| msgid "" +#| " number: amount of time to wait (integer number)\n" +#| " unit: optional, values are:\n" +#| " ms: milliseconds\n" +#| " s: seconds (default)\n" +#| " m: minutes\n" +#| " h: hours\n" +#| "command: command to execute (or text to send to buffer if command does " +#| "not start with '/')\n" +#| "\n" +#| "Note: the command is executed on buffer where /wait was executed (if the " +#| "buffer does not exist any more, the command is not executed).\n" +#| "\n" +#| "Examples:\n" +#| " join channel in 10 seconds:\n" +#| " /wait 10 /join #test\n" +#| " set away in 15 minutes:\n" +#| " /wait 15m /away -all I'm away\n" +#| " say 'hello' in 2 minutes:\n" +#| " /wait 2m hello" msgid "" -" number: amount of time to wait (integer number)\n" +" number: amount of time to wait (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" diff --git a/po/weechat.pot b/po/weechat.pot index 52120c5ad..20fad7670 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-08-24 18:16+0200\n" +"POT-Creation-Date: 2023-08-25 11:16+0200\n" "PO-Revision-Date: 2014-08-16 10:27+0200\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" @@ -2025,8 +2025,9 @@ msgid "[-interval []] " msgstr "" msgid "" -" delay: delay between execution of commands\n" +" delay: delay between execution of commands (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" @@ -2311,8 +2312,9 @@ msgid "[] " msgstr "" msgid "" -" number: amount of time to wait (integer number)\n" +" number: amount of time to wait (minimum: 1 millisecond)\n" " unit: optional, values are:\n" +" us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 54209d505..09e1b0001 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -5743,7 +5743,7 @@ command_repeat_timer_cb (const void *pointer, void *data, int remaining_calls) COMMAND_CALLBACK(repeat) { int arg_count, count, i; - long interval; + long long interval; char *error, **repeat_args; /* make C compiler happy */ @@ -5757,9 +5757,10 @@ COMMAND_CALLBACK(repeat) if ((argc >= 5) && (string_strcmp (argv[1], "-interval") == 0)) { - interval = util_parse_delay (argv[2], 1000); - if (interval < 1) + interval = util_parse_delay (argv[2], 1000000); + if (interval < 0) interval = 0; + interval /= 1000; arg_count = 3; } @@ -7256,7 +7257,7 @@ COMMAND_CALLBACK(version) COMMAND_CALLBACK(wait) { - long delay; + long long delay; /* make C compiler happy */ (void) pointer; @@ -7264,10 +7265,12 @@ COMMAND_CALLBACK(wait) COMMAND_MIN_ARGS(3, ""); - delay = util_parse_delay (argv[1], 1000); + delay = util_parse_delay (argv[1], 1000000); if (delay < 1) COMMAND_ERROR; + delay /= 1000; + if (input_data_delayed (buffer, argv_eol[2], NULL, 0, delay) != WEECHAT_RC_OK) COMMAND_ERROR; @@ -8886,8 +8889,9 @@ command_init () NULL, "repeat", N_("execute a command several times"), N_("[-interval []] "), - N_(" delay: delay between execution of commands\n" + N_(" delay: delay between execution of commands (minimum: 1 millisecond)\n" " unit: optional, values are:\n" + " us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" @@ -9172,8 +9176,9 @@ command_init () NULL, "wait", N_("schedule a command execution in future"), N_("[] "), - N_(" number: amount of time to wait (integer number)\n" + N_(" number: amount of time to wait (minimum: 1 millisecond)\n" " unit: optional, values are:\n" + " us: microseconds\n" " ms: milliseconds\n" " s: seconds (default)\n" " m: minutes\n" diff --git a/src/core/wee-util.c b/src/core/wee-util.c index 8d791acfa..0e70aee4a 100644 --- a/src/core/wee-util.c +++ b/src/core/wee-util.c @@ -339,32 +339,34 @@ util_get_time_diff (time_t time1, time_t time2, /* * Parses a string with a delay and optional unit, returns the delay in - * milliseconds. + * microseconds. * * The delay is a number followed by a unit which can be: + * - "us": microseconds * - "ms": milliseconds * - "s": seconds * - "m": minutes * - "h": hours * * The default factor sets the default unit: - * - 1: milliseconds - * - 1000: seconds - * - 60000: minutes - * - 3600000: hours + * - 1: microseconds + * - 1000: milliseconds + * - 1000000: seconds + * - 60000000: minutes + * - 3600000000: hours * - * Returns the delay in milliseconds, -1 if error. + * Returns the delay in microseconds, -1 if error. */ -long -util_parse_delay (const char *string_delay, long default_factor) +long long +util_parse_delay (const char *string_delay, long long default_factor) { const char *pos; char *str_number, *error; - long factor, delay; + long long factor, delay; if (!string_delay || !string_delay[0] || (default_factor < 1)) - return -1; + return -1LL; factor = default_factor; @@ -377,16 +379,18 @@ util_parse_delay (const char *string_delay, long default_factor) if ((pos > string_delay) && pos[0]) { str_number = string_strndup (string_delay, pos - string_delay); - if (strcmp (pos, "ms") == 0) - factor = 1; + if (strcmp (pos, "us") == 0) + factor = 1LL; + else if (strcmp (pos, "ms") == 0) + factor = 1000LL; else if (strcmp (pos, "s") == 0) - factor = 1000; + factor = 1000LL * 1000LL; else if (strcmp (pos, "m") == 0) - factor = 1000 * 60; + factor = 1000LL * 1000LL * 60LL; else if (strcmp (pos, "h") == 0) - factor = 1000 * 60 * 60; + factor = 1000LL * 1000LL * 60LL * 60LL; else - return -1; + return -1LL; } else { @@ -394,14 +398,14 @@ util_parse_delay (const char *string_delay, long default_factor) } if (!str_number) - return -1; + return -1LL; error = NULL; - delay = strtol (str_number, &error, 10); + delay = strtoll (str_number, &error, 10); if (!error || error[0] || (delay < 0)) { free (str_number); - return -1; + return -1LL; } free (str_number); diff --git a/src/core/wee-util.h b/src/core/wee-util.h index 8811047c2..1acb9a76d 100644 --- a/src/core/wee-util.h +++ b/src/core/wee-util.h @@ -48,7 +48,8 @@ extern void util_get_time_diff (time_t time1, time_t time2, /* delay */ -extern long util_parse_delay (const char *string_delay, long default_factor); +extern long long util_parse_delay (const char *string_delay, + long long default_factor); /* version */ extern int util_version_number (const char *version); diff --git a/tests/unit/core/test-core-util.cpp b/tests/unit/core/test-core-util.cpp index 0e40fef67..04aaa0554 100644 --- a/tests/unit/core/test-core-util.cpp +++ b/tests/unit/core/test-core-util.cpp @@ -178,48 +178,59 @@ TEST(CoreUtil, GetTimeDiff) TEST(CoreUtil, ParseDelay) { /* error: no string */ - LONGS_EQUAL(-1, util_parse_delay (NULL, -1)); - LONGS_EQUAL(-1, util_parse_delay (NULL, 0)); - LONGS_EQUAL(-1, util_parse_delay (NULL, 1)); - LONGS_EQUAL(-1, util_parse_delay ("", -1)); - LONGS_EQUAL(-1, util_parse_delay ("", 0)); - LONGS_EQUAL(-1, util_parse_delay ("", 1)); + LONGS_EQUAL(-1LL, util_parse_delay (NULL, -1LL)); + LONGS_EQUAL(-1LL, util_parse_delay (NULL, 0LL)); + LONGS_EQUAL(-1LL, util_parse_delay (NULL, 1LL)); + LONGS_EQUAL(-1LL, util_parse_delay ("", -1LL)); + LONGS_EQUAL(-1LL, util_parse_delay ("", 0LL)); + LONGS_EQUAL(-1LL, util_parse_delay ("", 1LL)); /* error: bad default_factor */ - LONGS_EQUAL(-1, util_parse_delay ("abcd", -1)); - LONGS_EQUAL(-1, util_parse_delay ("abcd", 0)); - LONGS_EQUAL(-1, util_parse_delay ("123", -1)); - LONGS_EQUAL(-1, util_parse_delay ("123", 0)); + LONGS_EQUAL(-1LL, util_parse_delay ("abcd", -1LL)); + LONGS_EQUAL(-1LL, util_parse_delay ("abcd", 0LL)); + LONGS_EQUAL(-1LL, util_parse_delay ("123", -1LL)); + LONGS_EQUAL(-1LL, util_parse_delay ("123", 0LL)); /* error: bad unit */ - LONGS_EQUAL(-1, util_parse_delay ("123a", 1)); - LONGS_EQUAL(-1, util_parse_delay ("123ss", 1)); - LONGS_EQUAL(-1, util_parse_delay ("123mss", 1)); + LONGS_EQUAL(-1LL, util_parse_delay ("123a", 1LL)); + LONGS_EQUAL(-1LL, util_parse_delay ("123ss", 1LL)); + LONGS_EQUAL(-1LL, util_parse_delay ("123mss", 1LL)); + LONGS_EQUAL(-1LL, util_parse_delay ("123uss", 1LL)); /* error: bad number */ - LONGS_EQUAL(-1, util_parse_delay ("abcd", 1)); + LONGS_EQUAL(-1LL, util_parse_delay ("abcd", 1LL)); /* tests with delay == 0 */ - LONGS_EQUAL(0, util_parse_delay ("0", 1)); - LONGS_EQUAL(0, util_parse_delay ("0ms", 1)); - LONGS_EQUAL(0, util_parse_delay ("0s", 1)); - LONGS_EQUAL(0, util_parse_delay ("0m", 1)); - LONGS_EQUAL(0, util_parse_delay ("0h", 1)); + LONGS_EQUAL(0LL, util_parse_delay ("0", 1LL)); + LONGS_EQUAL(0LL, util_parse_delay ("0us", 1LL)); + LONGS_EQUAL(0LL, util_parse_delay ("0ms", 1LL)); + LONGS_EQUAL(0LL, util_parse_delay ("0s", 1LL)); + LONGS_EQUAL(0LL, util_parse_delay ("0m", 1LL)); + LONGS_EQUAL(0LL, util_parse_delay ("0h", 1LL)); - /* tests with delay == 123, default_factor = 1 */ - LONGS_EQUAL(123, util_parse_delay ("123", 1)); - LONGS_EQUAL(123, util_parse_delay ("123", 1)); - LONGS_EQUAL(123, util_parse_delay ("123ms", 1)); - LONGS_EQUAL(123 * 1000, util_parse_delay ("123s", 1)); - LONGS_EQUAL(123 * 1000 * 60, util_parse_delay ("123m", 1)); - LONGS_EQUAL(123 * 1000 * 60 * 60, util_parse_delay ("123h", 1)); + /* tests with delay == 123, default_factor = 1 (1 microsecond) */ + LONGS_EQUAL(123LL, util_parse_delay ("123", 1LL)); + LONGS_EQUAL(123LL, util_parse_delay ("123us", 1LL)); + LONGS_EQUAL(123LL * 1000LL, util_parse_delay ("123ms", 1LL)); + LONGS_EQUAL(123LL * 1000LL * 1000LL, util_parse_delay ("123s", 1LL)); + LONGS_EQUAL(123LL * 1000LL * 1000LL * 60LL, util_parse_delay ("123m", 1LL)); + LONGS_EQUAL(123LL * 1000LL * 1000LL * 60LL * 60LL, util_parse_delay ("123h", 1LL)); - /* tests with delay == 123, default_factor = 1000 */ - LONGS_EQUAL(123 * 1000, util_parse_delay ("123", 1000)); - LONGS_EQUAL(123, util_parse_delay ("123ms", 1000)); - LONGS_EQUAL(123 * 1000, util_parse_delay ("123s", 1000)); - LONGS_EQUAL(123 * 1000 * 60, util_parse_delay ("123m", 1000)); - LONGS_EQUAL(123 * 1000 * 60 * 60, util_parse_delay ("123h", 1000)); + /* tests with delay == 123, default_factor = 1000 (1 millisecond) */ + LONGS_EQUAL(123LL * 1000LL, util_parse_delay ("123", 1000LL)); + LONGS_EQUAL(123LL, util_parse_delay ("123us", 1000LL)); + LONGS_EQUAL(123LL * 1000LL, util_parse_delay ("123ms", 1000LL)); + LONGS_EQUAL(123LL * 1000LL * 1000LL, util_parse_delay ("123s", 1000LL)); + LONGS_EQUAL(123LL * 1000LL * 1000LL * 60LL, util_parse_delay ("123m", 1000LL)); + LONGS_EQUAL(123LL * 1000LL * 1000LL * 60LL * 60LL, util_parse_delay ("123h", 1000LL)); + + /* tests with delay == 123, default_factor = 1000000 (1 second) */ + LONGS_EQUAL(123LL * 1000LL * 1000LL, util_parse_delay ("123", 1000000LL)); + LONGS_EQUAL(123LL, util_parse_delay ("123us", 1000000LL)); + LONGS_EQUAL(123LL * 1000LL, util_parse_delay ("123ms", 1000000LL)); + LONGS_EQUAL(123LL * 1000LL * 1000LL, util_parse_delay ("123s", 1000000LL)); + LONGS_EQUAL(123LL * 1000LL * 1000LL * 60LL, util_parse_delay ("123m", 1000000LL)); + LONGS_EQUAL(123LL * 1000LL * 1000LL * 60LL * 60LL, util_parse_delay ("123h", 1000000LL)); } /*