Commit graph

157 commits

Author SHA1 Message Date
Stanislav Motylkov 72bdbdd4fa
[TRANSLATION] More Russian (ru-RU) translation fixes
Addendum to 3f411c5d.
2022-09-29 12:00:04 +03:00
Hermès Bélusca-Maïto 38870875ba
[CMD] Fix build. Addendum to 67ac583b5. 2022-09-25 23:59:18 +02:00
Hermès Bélusca-Maïto 67ac583b5b
[CMD] COPY: Always remove the read-only attribute, for MS-DOS backwards-compatibility.
Tested and compared with MS CMD.EXE when copying files within the
same directory, across directories and across drives.
This is not done for the MOVE, REN and REPLACE commands however.

CORE-18090
2022-09-25 23:55:27 +02:00
Artyom Ovsyannikov 3f411c5da7
[REACTOS] Various Russian (ru-RU) translation fixes (#4696)
Reviewed-by: Stanislav Motylkov <binarymaster@mail.ru>
2022-09-15 18:46:03 +03:00
Luke Luo de972e2bc2
[TRANSLATION] Improve Simplified Chinese (zh-CN) translation (#4513)
- Changed some wording according to the translation requirements.
- Fixed some mistakes.
- Changed my name.

Reviewed-by: He Yang <1160386205@qq.com>
Reviewed-by: Stanislav Motylkov <x86corez@gmail.com>
2022-05-20 15:38:24 +03:00
Serge Gautherie 03422451b3 [REACTOS] Add '\n' to debug logs
on TRACE, WARN, FIXME and ERR calls.

Plus a few nit picks.
2022-05-04 03:28:38 +03:00
Wu Haotian 0c42866e64
[TRANSLATION] Review & update Simplified Chinese (zh-CN) translation (#3933)
Reviewed all Chinese Simplified translation files and updated those
inappropriate or outdated ones.

Co-authored-by: Liu Wenyuan <15816141883@163.com>
Reviewed-by: Chan Chilung <eason066@gmail.com>
Reviewed-by: He Yang <1160386205@qq.com>
Reviewed-by: Zheng Jianping <robsean@126.com>
Reviewed-by: Luo Yufan <njlyf2011@hotmail.com>
Reviewed-by: Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Reviewed-by: Stanislav Motylkov <x86corez@gmail.com>
2022-03-31 20:30:52 +03:00
Joachim Henze c3f4c11af1 [REACTOS] de-DE.rc in all modules: DIE! EINGABETASTE! DIE! CORE-18077
harmonize the mixed usage of EINGABETASTE and ENTER
in favor of ENTER.

Allows us even to omit a linebreak in the format utility and
therefore get closer to en-US.rc
2022-03-05 21:25:30 +01:00
Süleyman Poyraz 05c39d8d62
[TRANSLATION] Update Turkish (tr-TR) translations (#3958)
Reviewed-by: Can Taşan <ctasan99@hotmail.com>
Signed-off-by: Süleyman Poyraz <zaryob.dev@gmail.com>
2021-10-10 16:00:12 +03:00
Chan Chilung 463784c5f1
[TRANSLATION] Chinese Traditional (zh-TW) translation update (#3954)
Also sync LOCALMON/UI translation with Wine.
2021-10-10 15:00:44 +03:00
Hermès Bélusca-Maïto 9393fc320e
[FORMATTING] Remove trailing whitespace. Addendum to 34593d93.
Excluded: 3rd-party code (incl. wine) and most of the win32ss.
2021-09-13 03:52:22 +02:00
Hermès Bélusca-Maïto bbabe2489e
[FORMATTING][TRANSLATION] Remove trailing whitespace. Addendum to 34593d93.
Excluded: 3rd-party code (incl. wine).
2021-09-13 03:52:21 +02:00
Hermès Bélusca-Maïto 290e5c9933
[TRANSLATION] Fix instances of strings with trailing whitespace before newlines. 2021-09-13 03:52:20 +02:00
Joachim Henze 984c7da24d [CMD] tr-TR.rc Fix compiler warning CORE-17763
GCC8.4.0 dbg warned about:
[675/1849] Building RC object base/shell/cmd/CMakeFiles/cmd.dir/cmd.rc.obj
In file included from C:/ros/reactos/base/shell/cmd/cmd.rc:87:
C:/ros/reactos/base/shell/cmd/lang/tr-TR.rc:349:61: warning: backslash and newline separated by space

I guess somebody made the checks more strict recently,
because that bug was existing for longer already without
generating any warning for me.
2021-09-12 16:17:35 +02:00
Süleyman Poyraz 53221834c5
[TRANSLATION] Add and improve Turkish (tr-TR) translation (#3561)
Reviewed-by: Can Taşan <ctasan99@hotmail.com>
Reviewed-by: Ercan Ersoy <ercanersoy@ercanersoy.net>
Signed-off-by: Süleyman Poyraz <zaryob.dev@gmail.com>
2021-09-12 00:34:11 +03:00
Julen Urizar Compains ea6e774050
[TRANSLATION] Fix minor typos and untranslated dialogs in Spanish (#3890)
- usetup: New bootsector page.
- shell32: Copy and paste, and moving elements.
  Also, some strings related to the shutdown and logoff.
- Minor Spanish grammar fix - some female words and minor latin american typos.
- First revision of the .inf, that includes the translation of the Services,
  audio, processors and other drivers and minor things.
2021-09-04 17:22:41 +03:00
Timo Kreuzer 5d8e834897 [REACTOS] Fix a number of MSVC warnings 2021-07-23 22:03:48 +02:00
Jérôme Gardou aae161d061 [CMD] Do not use an intermediate buffer when reading lines from batch files
This is easier on the heap and improves cmd:batch winetest nicely
2021-06-24 15:03:36 +02:00
Jérôme Gardou 5ca83e516c [CMD] Improve performance a bit
Do not use custom alloc/free functions by default.
Do not free resources at process exit.
 - You're doing it brick by brick while the OS  & CRT do that with a bulldozer better than you do.
2021-06-24 15:03:36 +02:00
Jérôme Gardou 521d330d04 [CMD] Use GetFullPathName instead of copying buffers when resolving executable names
This properly strips spaces & dots at the end of the file.

Fixes the infinite loop with CreateProcess calling cmd over and over with e.g. 'cmd /c "some_script.bat   "'
Uncovered by recent ShellExecuteEx tests
Dedicated to Katayama for the trigger & Hermès for the tests
2021-06-09 11:23:39 +02:00
Hermès Bélusca-Maïto 53bd132cec
[CMD] Reset the current thread UI language at startup, and when updating the local code page cache.
CORE-17601
2021-05-26 01:42:12 +02:00
Hermès Bélusca-Maïto 35f499e52f
[CONUTILS][CMD] Add and use a helper ConStdStreamsSetCacheCodePage() macro instead of repeatedly calling ConStreamSetCacheCodePage() on the standard streams. 2021-05-26 01:42:09 +02:00
Serge Gautherie d3fc345730 [CMD] de-DE: Fix 'Paramater' typo 2021-04-11 09:30:28 +03:00
Reinhart Previano Koentjoro 9c8ed68544
[CMD] Improve Indonesian (id-ID) translation (#3417) 2021-01-12 13:14:08 +03:00
Joachim Henze ab45955a5a [CMD] Consume only one line for the version header CORE-17420
Necessary because our version string got longer during 0.4.15-dev'ing.
We added the target platform.
2021-01-06 01:34:54 +01:00
Tibor Lajos Füzi 82f0061ddc
[TRANSLATION] Hungarian (hu-HU) translation update (#3388)
For mspaint, notepad, wordpad, cmd, cmdutils/help, appwiz, devmgr, newdev

Co-authored-by: Stanislav Motylkov <x86corez@gmail.com>
2020-12-31 01:42:34 +03:00
He Yang 02c566b524
[TRANSLATION][CMD] Update zh-CN translation (partially) (#3330) 2020-11-21 18:05:22 +01:00
Jose Carlos Jesus a012c3d507
[CMD] Add new portuguese (PT) translation (#3260) 2020-11-07 17:27:52 +01:00
Hermès Bélusca-Maïto 3c722e35b1
[CMD][SERVMAN][SHELL32][WINSPOOL][ROSAPPS][NTOS:PNP] Fix my build. 2020-11-06 01:06:11 +01:00
chirsz a91a709a8d
[CMD] Fix a typo in filename completion (#3293)
Fix filename completion that could cause a incorrect result when the path
contains "dots". (See also HBelusca@d12169b.)
See CORE-8623 and CORE-1901 (bug introduced in r25896 / 54cf74f).

For example:

- The current directory is `C:\Documents and Settings\Administrator\`, and you
  input `".` and press TAB. The completion result would be `".Administrator"`,
  which even does not exist.

- You input "some(file).ext", and you remove the final quote (or the quote
  and "ext") and you attempt to complete the file name.

- Import two additional fixes from HBelusca@a826730: Fix the search ordering
  in the comparisons between szSearch1, szSearch2 and szSearch3.

Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
2020-10-11 21:57:08 +02:00
Hermès Bélusca-Maïto f5ba9de2ee
[CMD] Fix substring-substitute regression from commit cdc8e45b (use signed offsets). 2020-09-28 00:41:17 +02:00
Hermès Bélusca-Maïto 895dccd4ac
[CMD] Cleanup all batch contexts if the execution loop stopped due to EXIT. 2020-09-27 20:26:36 +02:00
Hermès Bélusca-Maïto f0fccb752f
[CMD] Fix batch/CALL arguments initialization.
- Move initialization of bc->raw_params also in BatchParams().

- The bc->raw_params, i.e. the unparsed batch/CALL parameters obtained
  with %*, has any leading and trailing whitespace trimmed
  (since Windows 2000+).
2020-09-27 19:06:10 +02:00
Hermès Bélusca-Maïto 37bda06eed
[CMD] CALL: Fix the implementation of the CALL command, make it more compatible with Windows' CMD.
- Fail if no parameter is provided.

- The "CALL :label args..." syntax is available only when command extensions
  are enabled. Fail if this syntax is used outside of a batch context.

- Reparse the CALL command parameter with the command parser, in order
  to accurately parse and interpret it as a possible command (including
  escape carets, etc...) and not duplicate the logic.
  ** CURRENT Windows' CMD-compatibility LIMITATION ** (may be lifted in
  a "ROS-specific" running mode of CMD): only allow standard commands to
  be specified as parameter of the CALL command.

  This reparsing behaviour can be observed in Windows' CMD, by dumping
  the interpreted commands after enabling the cmd!fDumpParse flag from
  a debugger (using public symbols).

- When reparsing, we should tell the parser to NOT ignore lines that
  start with a colon, because in this situation these are to be
  considered as valid "commands" (for parsing "CALL :label").

  * For Windows' CMD-compatibility, the remaining escape carets need to
    be doubled again so that, after the new parser step, they are escaped
    back to their original form. But then we also need to do it the "buggy"
    way à la Windows, where carets in quotes are doubled either! However
    when being re-parsed, since they are in quotes they remain doubled!!
    (see "Phase 6" in https://stackoverflow.com/a/4095133/13530036 ).

  * A MSCMD_CALL_QUIRKS define allows to disable this buggy behaviour,
    and instead tell the parser to not not interpret the escape carets.

- When initializing a new batch context when the "CALL :label" syntax is
  used, ensure that we reuse the same batch file position pointer as its
  parent, so as to have correct call label ordering behaviour.

  That is,

  :label
  ECHO hi
  CALL :label
  :label
  ECHO bye

  should display:

  hi
  bye
  bye

  i.e., the CALL calls the second label instead of the first one (and
  thus entering into an infinite loop).

  Finally, the "CALL :label" syntax strips the first ':' away, so, as a
  side-effect, the command "CALL :EOF" fails (otherwise it would perform
  a "GOTO :EOF" and succeeds), while "CALL ::EOF" succeeds.

Fixes some cmd_winetests.
2020-09-27 19:05:23 +02:00
Hermès Bélusca-Maïto d029a626e9
[CMD] Make the command-line parser more compatible with Windows' CMD one.
All these modifications have been verified with Windows' CMD, either
by using written cmd_rostests and the existing cmd_winetests, or
manually by enabling the flags cmd!fDumpTokens and cmd!fDumpParse
(available in the public symbols) and analyzing how the tokens are
being parsed, as well as the generated command tree.

See also the following links for more details (but remember that these
observations have to be double-checked in Windows' CMD!):

* Parser rules: https://stackoverflow.com/a/4095133/13530036
* Discussion: https://www.dostips.com/forum/viewtopic.php?f=3&t=8355
* Numbers parsing: https://www.dostips.com/forum/viewtopic.php?t=3758
* Label names vs. GOTO and CALL: https://www.dostips.com/forum/viewtopic.php?f=3&t=3803
  and: https://www.dostips.com/forum/viewtopic.php?f=3&t=3803&p=55405#p55405

- Fix REM command parsing. A C_COMMAND-like structure should still
  be built, so that it can show up during batch command echo. However
  some specific handling needs to be done, so use instead a new C_REM
  command type.
  Escape carets are parsed differently than usual: they are explicitly
  kept in the command line and don't participate in line continuations.
  Also, the Windows' CMD behaviour is to discards everything before the
  last line continuation.

- Prefix operator '@' (the "silent" operator) is parsed as a separate
  command. Thus, the command @@foo@bar is parsed as: '@', '@', 'foo@bar'.

- Improve the checks for numbered redirection.
  For this purpose, we check whether this is a number, that is in first
  position in the current parsing buffer or is preceded by a whitespace-
  like separator, including standard command operators (excepting '@' !)
  and double-quotes.

- Empty command blocks, i.e. "( )", standing by themselves, or present
  in IF or FOR commands, are considered invalid. (The closing parenthesis
  is considered "unexpected".)

- Ignore single closing parenthesis when being outside of command blocks,
  thus interpreting it as a command, and ignore explicitly everything
  following on the same line, including line continuations.
  This very specific situation can happen e.g. while running in batch mode,
  when jumping to a label present inside a command block.
  See the code for a thorough explanation.

- Detect whether a parenthesized block is not terminated at the end
  of a command stream (getting a NUL character instead of a newline),
  and if so, bail out early instead of entering into an infinite loop.

- Perform a similar check for the parenthesized list in FOR commands.

- Initialize the static 'InsideBlock' value to a known value.

- The '&' operator (multi-commmand) is allowed to have an empty RHS.
  When such situation occurs, turn the CurrentTokenType to TOK_END
  so as to avoid a parse error later on.

- The main body of a IF statement, or its 'else' clause, as well as
  the main body of a FOR statement, must not be empty, otherwise this
  is considered a syntax error. If so, call ParseError() that sets
  the 'bParseError' flag, and forcing all batch execution to stop.
2020-09-27 02:27:15 +02:00
Hermès Bélusca-Maïto 17e094cd34
[CMD] SET: Diverse fixes for the arithmetic-expression parser (/A option).
- Detect whether a division by zero is done, and fail if so.

- Detect whether an invalid number is provided:
  * If _tcstol() fails with errno == ERANGE, we've got an overflow or
    underflow.
  * If the next character where _tcstol() is not a whitespace but is a
    character compatible with the first character of an identifier, the
    number is invalid.

- Add + to the list of existing unary operators (!,~,-), and parse them
  where many of these are present. Indeed, expressions like: +3, -+-+3,
  !!-+3 (or with other unary ops, etc.) are valid.

- Operators constituted of more than one characters, can contain
  whitespace separating their constituting characters.
  Thus, "a + = 3" is equivalent to "a += 3" (and the same for -=, *=,
  /=, %=, &=, |= and ^=), and "a < < 3" is equivalent to "a << 3" (and
  the same for >>, <<= and >>=).

- After evaluating everything, if unparsed data remains, fail and bail out.

- Return Windows' CMD-compatible errorlevels.

See https://ss64.com/nt/set.html for more details.

Fixes some cmd_winetests.
2020-09-23 00:22:48 +02:00
Hermès Bélusca-Maïto 87a5403318
[CMD] Add a MSCMD_BATCH_ECHO define for enabling Windows' CMD.EXE way of preserving/restoring the echo flag across batch calls.
Observation shows that this is done only when the top-level batch file
is being run (and then terminates); the echo flag is not restored to its
previous state when a child batch file terminates and gives main back to
its parent batch.
2020-09-23 00:22:47 +02:00
Hermès Bélusca-Maïto 141378cfc8
[CMD] ASSOC: Simplify the code and make it more robust; fix returned ERRORLEVEL values.
- Make sure that non-administrator users can list associations, and
  display appropriate error messages when e.g. they don't have sufficient
  privileges to perform an operation.

- Make the helper functions all return Win32 values, used as the
  ERRORVALUE, except when a specific extension association fails to be
  displayed, in which case the ERRORVALUE is normalized to 1.

- Since the 'param' is a modifiable string (that can be modified by the
  command, independently of the way it's called), just use it to isolate
  the extension by zeroing out the equls-sign separator.
2020-09-23 00:22:47 +02:00
Hermès Bélusca-Maïto 63316df520
[CMD] Change ERRORLEVEL behaviour for commands ASSOC, PATH, PROMPT and SET.
Commands APPEND/DPATH and FTYPE are also concerned by this; however
we do not implement them in our CMD.EXE yet.

These commands set the ERRORLEVEL differently, whether or not they are
run manually from the command-line/from a .BAT file, or from a .CMD file:

- From command-line/.BAT file, these commands set the ERRORLEVEL only if
  an error occurs. So, if two commands are run consecutively and the first
  one fails, the ERRORLEVEL will remain set even if the second command
  succeeds.

- However, when being run from a .CMD file, these command will always
  set the ERRORLEVEL. In the example case described above, the second
  command that succeeds will reset the ERRORLEVEL to 0.

This behaviour is determined from the top-level batch/script file being
run. This means that, if a .BAT file is first started, then starts a
.CMD file, the commands will still behave the .BAT way; on the opposite,
if a .CMD file is first started, then starts a .BAT file, these commands
will still behave the .CMD way.

To implement this we introduce one global BATCH_TYPE enum variable that
is initialized to the corresponding batch/script file type when the
top-level script is loaded. It is reset to "none" when that script
terminates.

See https://ss64.com/nt/errorlevel.html for more details,
section "Old style .bat Batch files vs .cmd Batch scripts",
and https://groups.google.com/forum/#!msg/microsoft.public.win2000.cmdprompt.admin/XHeUq8oe2wk/LIEViGNmkK0J
(comment by Mark Zbikowski).
2020-09-23 00:22:46 +02:00
Hermès Bélusca-Maïto a5d7a2cd61
[CMD] Code style and formatting fixes for assoc.c and path.c 2020-09-23 00:22:45 +02:00
Hermès Bélusca-Maïto 0695ecbfd6
[CMD] FOR: Additional Windows' CMD compatibility "fixes" for FOR /F token parsing command.
This compatibility behaviour implements the buggy behaviour of FOR /F
token parsing that can be observed in Windows' CMD, and that is tested
by the cmd_winetests.
It can be disabled at compile time via the MSCMD_FOR_QUIRKS define.

It fixes additional cmd_winetests, in concert with commit cb2a9c31.

Explanation of the implemented buggy behaviour
==============================================

In principle, the "tokens=x,y,m-n[*]" option describes a list of token
numbers (must be between 1 and 31) that will be assigned into variables.
Theoretically this option does not cumulate: only the latest 'tokens='
specification should be taken into account.

However things are not that simple in practice. First, not all of the
"tokens=" option state is reset when more than one specification is
provided. Second, when specifying a token range, e.g. "1-5", Windows'
CMD just ignores without error ranges that are not specified in
increasing order. Thus for example, a range "5-1" is ignored without
error. Then, token numbers strictly greater than 31 are just ignored,
and if they appear in a range, the whole range is ignored.

Another bug is the following one: suppose that the 'tokens'
specification reads:
  "tokens=1-5,1-30" , or: "tokens=1-5,3" ,
i.e. more than one range, that overlap partially. Then the actual total
number of variables will not be of the larger range size, but will be
the sum, instead.
Thus, in the first example, a total of 5 + 30 == 35 variables (> 31) is
allocated, while in the second example, a total of 5 + 1 == 6 variables
is allocated, even if they won't all store data !!
In the first example, only the first 30 FOR variables will be used, and
the 5 others will contain an empty string. In the second example, only
the first 5 FOR variables will be used, and the other one will be empty.

We also see that due to that, the "Variables" buffer of fixed size
cannot always be used (since it can contain at most 32 variables).

Last but not least, when more than one "tokens=" specification is
provided, for example:
  "tokens=1-31 tokens=1-20"
a total number of 31 FOR variables (because 31 is the max of 31 and 20)
is allocated, **but** only 20 are actually used, and the 11 others
return an empty string.

And in the specification: "tokens=1-31,* tokens=1-20", a total of
31 + 1 + 20 = 52 variables is initialized, but only the first 20 will
be used, and no "remaining-line" token (the '*' one) is used.
2020-09-21 03:31:01 +02:00
Hermès Bélusca-Maïto e904471023
[CMD] IF: Fix x64 warning C4267. 2020-09-21 03:31:01 +02:00
Hermès Bélusca-Maïto 5d5a1a455c
[CMD] FOR: Fix a bug when parsing the "delims=" option in FOR loops.
Suppose the following FOR-loop command, to be run from the command-line
(if using a batch file, double each percent '%' sign):

  FOR %l IN ("a,b,c,d,e" "f,g,h,i,j") DO (
    FOR /F "delims=, tokens=1-3*" %a IN (%l) DO @echo %a-%b-%c-%d
  )

The outermost FOR-loop enumerates the two strings "a,b,c,d,e" and
"f,g,h,i,j" (placed in %l), and parse each of these in turn, splitting
them at each specified delimiter (here only one character) ',' and storing
the results in consecutive tokens %a, %b, %c, %d, with the last token %d
containing all the remaining string (non-split).
The expected result is:

  a-b-c-d,e
  f-g-h-i,j

However, due to the way the delimiters string specified by the "delims="
option is stored (no stack/heap duplication of the FOR-option substring,
but reading from it directly), during the first run of the innermost
FOR-loop, the option string "delims=, tokens=1-3*" was truncated to just
after the ',' due to the erroneous "delims=" parsing, so that when this
FOR-loop ran for a second time (to deal with the second string), the option
string was already erroneously truncated, without the "tokens=..." part,
so that the parsing results were not stored in the tokens and resulting in:

  a-b-c-d,e
  f-%b-%c-%d

instead. The solution is to save where the "delims=" string needs to be
cut, but wait until running the actual FOR-loop to terminate it (and
saving the original character too), run the FOR-loop body, and then
restore the original character where termination took place. This allows
having the FOR-loop option string valid for the next execution of the
FOR-loop.
2020-09-19 19:44:56 +02:00
Hermès Bélusca-Maïto 5cf0517be1
[CMD] Code formatting in SubstituteVar(). 2020-09-19 19:44:55 +02:00
Hermès Bélusca-Maïto cdc8e45b48
[CMD] Fix delayed expansion of variables.
CORE-13682

- Split SubstituteVars() into its main loop and a helper SubstituteVar()
  that just substitutes only one variable.

- Use this new helper as the basis of the proper implementation of the
  delayed expansion of variables.

- Fix a bug introduced in commit 495c82cc, when GetBatchVar() fails.
2020-09-19 19:44:55 +02:00
Hermès Bélusca-Maïto cb2a9c31a6
[CMD] Some fixes for getting the enhanced '%~XXX' batch/FOR variables.
CORE-11857 CORE-13736

It will be followed with a separate fix for the FOR-loop code.
Fixes some cmd_winetests.

A NULL pointer can be returned for a valid existing batch/FOR variable,
in which case the enhanced-variable getter should return an empty string.
This situation can happen e.g. when forcing a FOR-loop to tokenize a
text line with not enough tokens in it.
2020-09-19 19:44:54 +02:00
Kyle Katarn ac2b2ef8c7
[CMD] HISTORY: Fix command output (missing linefeed) (#3205)
CORE-12603

Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
2020-09-18 00:17:08 +02:00
Hermès Bélusca-Maïto c58a601602
[CMD] Document the two extra file attributes the enhanced batch/FOR variables %~aX could handle on Windows >= 8.
They are currently specified for documentation purposes (i.e. what
Windows 8+ CMD.EXE can report) but not used yet, since ReactOS does not
support them.
2020-09-13 22:50:11 +02:00
Hermès Bélusca-Maïto 95466904db
[CMD] SHIFT: Use _istdigit(). 2020-09-13 22:50:10 +02:00
Hermès Bélusca-Maïto 00ce3c48fe
[CMD] Use pointers to const strings in error functions, where applicable. 2020-09-13 22:50:09 +02:00