Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
5e3cb186
Commit
5e3cb186
authored
Oct 06, 2011
by
Frédéric Delanoy
Committed by
Alexandre Julliard
Oct 06, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd: Infer handle type from handle value in WCMD_fgets and WCMD_ReadAndParseLine.
parent
ea35386b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
24 deletions
+18
-24
batch.c
programs/cmd/batch.c
+3
-3
builtins.c
programs/cmd/builtins.c
+2
-2
wcmd.h
programs/cmd/wcmd.h
+6
-3
wcmdmain.c
programs/cmd/wcmdmain.c
+7
-16
No files found.
programs/cmd/batch.c
View file @
5e3cb186
...
...
@@ -89,7 +89,7 @@ void WCMD_batch (WCHAR *file, WCHAR *command, int called, WCHAR *startLabel, HAN
while
(
context
->
skip_rest
==
FALSE
)
{
CMD_LIST
*
toExecute
=
NULL
;
/* Commands left to be executed */
if
(
!
WCMD_ReadAndParseLine
(
NULL
,
&
toExecute
,
h
,
FALSE
))
if
(
!
WCMD_ReadAndParseLine
(
NULL
,
&
toExecute
,
h
))
break
;
WCMD_process_commands
(
toExecute
,
FALSE
,
NULL
,
NULL
);
WCMD_free_commands
(
toExecute
);
...
...
@@ -186,7 +186,7 @@ WCHAR *WCMD_parameter (WCHAR *s, int n, WCHAR **where, WCHAR **end) {
* NULL on error or EOF
*/
WCHAR
*
WCMD_fgets
(
WCHAR
*
buf
,
int
noChars
,
HANDLE
h
,
const
BOOL
is_console_handle
)
WCHAR
*
WCMD_fgets
(
WCHAR
*
buf
,
int
noChars
,
HANDLE
h
)
{
DWORD
bytes
,
charsRead
;
BOOL
status
;
...
...
@@ -196,7 +196,7 @@ WCHAR *WCMD_fgets(WCHAR *buf, int noChars, HANDLE h, const BOOL is_console_handl
between DOS and Unix. Also need to lose the LF (or CRLF) from the line. */
p
=
buf
;
if
(
is_console_handle
)
{
if
(
WCMD_is_console_handle
(
h
)
)
{
status
=
ReadConsoleW
(
h
,
buf
,
noChars
,
&
charsRead
,
NULL
);
if
(
!
status
)
return
NULL
;
if
(
buf
[
charsRead
-
2
]
==
'\r'
)
...
...
programs/cmd/builtins.c
View file @
5e3cb186
...
...
@@ -1133,7 +1133,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
WCHAR
buffer
[
MAXSTRING
]
=
{
'\0'
};
WCHAR
*
where
,
*
parm
;
while
(
WCMD_fgets
(
buffer
,
sizeof
(
buffer
)
/
sizeof
(
WCHAR
),
input
,
FALSE
))
{
while
(
WCMD_fgets
(
buffer
,
sizeof
(
buffer
)
/
sizeof
(
WCHAR
),
input
))
{
/* Skip blank lines*/
parm
=
WCMD_parameter
(
buffer
,
0
,
&
where
,
NULL
);
...
...
@@ -1393,7 +1393,7 @@ void WCMD_goto (CMD_LIST **cmdList) {
if
(
*
paramStart
==
':'
)
paramStart
++
;
SetFilePointer
(
context
->
h
,
0
,
NULL
,
FILE_BEGIN
);
while
(
WCMD_fgets
(
string
,
sizeof
(
string
)
/
sizeof
(
WCHAR
),
context
->
h
,
FALSE
))
{
while
(
WCMD_fgets
(
string
,
sizeof
(
string
)
/
sizeof
(
WCHAR
),
context
->
h
))
{
str
=
string
;
while
(
isspaceW
(
*
str
))
str
++
;
if
(
*
str
==
':'
)
{
...
...
programs/cmd/wcmd.h
View file @
5e3cb186
...
...
@@ -97,7 +97,11 @@ void WCMD_verify (const WCHAR *command);
void
WCMD_version
(
void
);
int
WCMD_volume
(
BOOL
set_label
,
const
WCHAR
*
command
);
WCHAR
*
WCMD_fgets
(
WCHAR
*
buf
,
int
n
,
HANDLE
stream
,
const
BOOL
is_console_handle
);
static
inline
BOOL
WCMD_is_console_handle
(
HANDLE
h
)
{
return
(((
DWORD_PTR
)
h
)
&
3
)
==
3
;
}
WCHAR
*
WCMD_fgets
(
WCHAR
*
buf
,
int
n
,
HANDLE
stream
);
WCHAR
*
WCMD_parameter
(
WCHAR
*
s
,
int
n
,
WCHAR
**
where
,
WCHAR
**
end
);
WCHAR
*
WCMD_skip_leading_spaces
(
WCHAR
*
string
);
BOOL
WCMD_keyword_ws_found
(
const
WCHAR
*
keyword
,
int
len
,
const
WCHAR
*
ptr
);
...
...
@@ -110,8 +114,7 @@ WCHAR *WCMD_strdupW(const WCHAR *input);
void
WCMD_strsubstW
(
WCHAR
*
start
,
const
WCHAR
*
next
,
const
WCHAR
*
insert
,
int
len
);
BOOL
WCMD_ReadFile
(
const
HANDLE
hIn
,
WCHAR
*
intoBuf
,
const
DWORD
maxChars
,
LPDWORD
charsRead
);
WCHAR
*
WCMD_ReadAndParseLine
(
const
WCHAR
*
initialcmd
,
CMD_LIST
**
output
,
HANDLE
readFrom
,
const
BOOL
is_console_handle
);
WCHAR
*
WCMD_ReadAndParseLine
(
const
WCHAR
*
initialcmd
,
CMD_LIST
**
output
,
HANDLE
readFrom
);
CMD_LIST
*
WCMD_process_commands
(
CMD_LIST
*
thisCmd
,
BOOL
oneBracket
,
const
WCHAR
*
var
,
const
WCHAR
*
val
);
void
WCMD_free_commands
(
CMD_LIST
*
cmds
);
...
...
programs/cmd/wcmdmain.c
View file @
5e3cb186
...
...
@@ -233,11 +233,6 @@ void WCMD_leave_paged_mode(void)
pagedMessage
=
NULL
;
}
static
inline
BOOL
is_console_handle
(
HANDLE
h
)
{
return
(((
DWORD_PTR
)
h
)
&
3
)
==
3
;
}
/***************************************************************************
* WCMD_Readfile
*
...
...
@@ -248,7 +243,7 @@ BOOL WCMD_ReadFile(const HANDLE hIn, WCHAR *intoBuf, const DWORD maxChars, LPDWO
DWORD
numRead
;
char
*
buffer
;
if
(
is_console_handle
(
hIn
))
if
(
WCMD_
is_console_handle
(
hIn
))
/* Try to read from console as Unicode */
return
ReadConsoleW
(
hIn
,
intoBuf
,
maxChars
,
charsRead
,
NULL
);
...
...
@@ -1781,8 +1776,7 @@ static BOOL WCMD_IsEndQuote(const WCHAR *quote, int quoteIndex)
* - Anything else gets put into the command string (including
* redirects)
*/
WCHAR
*
WCMD_ReadAndParseLine
(
const
WCHAR
*
optionalcmd
,
CMD_LIST
**
output
,
HANDLE
readFrom
,
const
BOOL
is_console_handle
)
WCHAR
*
WCMD_ReadAndParseLine
(
const
WCHAR
*
optionalcmd
,
CMD_LIST
**
output
,
HANDLE
readFrom
)
{
WCHAR
*
curPos
;
int
inQuotes
=
0
;
...
...
@@ -1827,7 +1821,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output,
}
else
if
(
readFrom
==
INVALID_HANDLE_VALUE
)
{
WINE_FIXME
(
"No command nor handle supplied
\n
"
);
}
else
{
if
(
!
WCMD_fgets
(
extraSpace
,
MAXSTRING
,
readFrom
,
is_console_handle
))
if
(
!
WCMD_fgets
(
extraSpace
,
MAXSTRING
,
readFrom
))
return
NULL
;
}
curPos
=
extraSpace
;
...
...
@@ -2188,7 +2182,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output,
/* Read more, skipping any blank lines */
while
(
*
extraSpace
==
0x00
)
{
if
(
!
context
)
WCMD_output_asis
(
WCMD_LoadMessage
(
WCMD_MOREPROMPT
));
if
(
!
WCMD_fgets
(
extraSpace
,
MAXSTRING
,
readFrom
,
is_console_handle
))
if
(
!
WCMD_fgets
(
extraSpace
,
MAXSTRING
,
readFrom
))
break
;
}
curPos
=
extraSpace
;
...
...
@@ -2280,8 +2274,6 @@ int wmain (int argc, WCHAR *argvW[])
WCHAR
string
[
1024
];
WCHAR
envvar
[
4
];
int
opt_q
;
BOOL
is_console
;
DWORD
dummy
;
int
opt_t
=
0
;
static
const
WCHAR
promptW
[]
=
{
'P'
,
'R'
,
'O'
,
'M'
,
'P'
,
'T'
,
'\0'
};
static
const
WCHAR
defaultpromptW
[]
=
{
'$'
,
'P'
,
'$'
,
'G'
,
'\0'
};
...
...
@@ -2497,7 +2489,7 @@ int wmain (int argc, WCHAR *argvW[])
*/
/* Parse the command string, without reading any more input */
WCMD_ReadAndParseLine
(
cmd
,
&
toExecute
,
INVALID_HANDLE_VALUE
,
FALSE
);
WCMD_ReadAndParseLine
(
cmd
,
&
toExecute
,
INVALID_HANDLE_VALUE
);
WCMD_process_commands
(
toExecute
,
FALSE
,
NULL
,
NULL
);
WCMD_free_commands
(
toExecute
);
toExecute
=
NULL
;
...
...
@@ -2593,7 +2585,7 @@ int wmain (int argc, WCHAR *argvW[])
if
(
opt_k
)
{
/* Parse the command string, without reading any more input */
WCMD_ReadAndParseLine
(
cmd
,
&
toExecute
,
INVALID_HANDLE_VALUE
,
FALSE
);
WCMD_ReadAndParseLine
(
cmd
,
&
toExecute
,
INVALID_HANDLE_VALUE
);
WCMD_process_commands
(
toExecute
,
FALSE
,
NULL
,
NULL
);
WCMD_free_commands
(
toExecute
);
toExecute
=
NULL
;
...
...
@@ -2606,13 +2598,12 @@ int wmain (int argc, WCHAR *argvW[])
SetEnvironmentVariableW
(
promptW
,
defaultpromptW
);
WCMD_version
();
is_console
=
!!
GetConsoleMode
(
GetStdHandle
(
STD_INPUT_HANDLE
),
&
dummy
);
while
(
TRUE
)
{
/* Read until EOF (which for std input is never, but if redirect
in place, may occur */
if
(
echo_mode
)
WCMD_show_prompt
();
if
(
!
WCMD_ReadAndParseLine
(
NULL
,
&
toExecute
,
GetStdHandle
(
STD_INPUT_HANDLE
)
,
is_console
))
if
(
!
WCMD_ReadAndParseLine
(
NULL
,
&
toExecute
,
GetStdHandle
(
STD_INPUT_HANDLE
)))
break
;
WCMD_process_commands
(
toExecute
,
FALSE
,
NULL
,
NULL
);
WCMD_free_commands
(
toExecute
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment