cmd: Rename a parameter in WCMD_fgets.
This commit is contained in:
parent
63e11558b6
commit
d25f614c51
|
@ -176,17 +176,17 @@ WCHAR *WCMD_parameter (WCHAR *s, int n, WCHAR **where, WCHAR **end) {
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* WCMD_fgets
|
* WCMD_fgets
|
||||||
*
|
*
|
||||||
* Gets one line from a file/console and puts it into buffer s
|
* Gets one line from a file/console and puts it into buffer buf
|
||||||
* Pre: s has size noChars
|
* Pre: buf has size noChars
|
||||||
* 1 <= noChars <= MAXSTRING
|
* 1 <= noChars <= MAXSTRING
|
||||||
* Post: s is filled with at most noChars-1 characters, and gets nul-terminated
|
* Post: buf is filled with at most noChars-1 characters, and gets nul-terminated
|
||||||
s does not include EOL terminator
|
buf does not include EOL terminator
|
||||||
* Returns:
|
* Returns:
|
||||||
* s on success
|
* buf on success
|
||||||
* NULL on error or EOF
|
* NULL on error or EOF
|
||||||
*/
|
*/
|
||||||
|
|
||||||
WCHAR *WCMD_fgets(WCHAR *s, int noChars, HANDLE h, BOOL is_console_handle)
|
WCHAR *WCMD_fgets(WCHAR *buf, int noChars, HANDLE h, const BOOL is_console_handle)
|
||||||
{
|
{
|
||||||
DWORD bytes, charsRead;
|
DWORD bytes, charsRead;
|
||||||
BOOL status;
|
BOOL status;
|
||||||
|
@ -195,29 +195,29 @@ WCHAR *WCMD_fgets(WCHAR *s, int noChars, HANDLE h, BOOL is_console_handle)
|
||||||
/* We can't use the native f* functions because of the filename syntax differences
|
/* We can't use the native f* functions because of the filename syntax differences
|
||||||
between DOS and Unix. Also need to lose the LF (or CRLF) from the line. */
|
between DOS and Unix. Also need to lose the LF (or CRLF) from the line. */
|
||||||
|
|
||||||
p = s;
|
p = buf;
|
||||||
if (is_console_handle) {
|
if (is_console_handle) {
|
||||||
status = ReadConsoleW(h, s, noChars, &charsRead, NULL);
|
status = ReadConsoleW(h, buf, noChars, &charsRead, NULL);
|
||||||
if (!status) return NULL;
|
if (!status) return NULL;
|
||||||
if (s[charsRead-2] == '\r')
|
if (buf[charsRead-2] == '\r')
|
||||||
s[charsRead-2] = '\0'; /* Strip \r\n */
|
buf[charsRead-2] = '\0'; /* Strip \r\n */
|
||||||
else {
|
else {
|
||||||
/* Truncate */
|
/* Truncate */
|
||||||
s[noChars-1] = '\0';
|
buf[noChars-1] = '\0';
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: More intelligent buffering for reading lines from files */
|
/* TODO: More intelligent buffering for reading lines from files */
|
||||||
do {
|
do {
|
||||||
status = WCMD_ReadFile(h, s, 1, &bytes);
|
status = WCMD_ReadFile(h, buf, 1, &bytes);
|
||||||
if ((status == 0) || ((bytes == 0) && (s == p))) return NULL;
|
if ((status == 0) || ((bytes == 0) && (buf == p))) return NULL;
|
||||||
if (*s == '\n') bytes = 0;
|
if (*buf == '\n') bytes = 0;
|
||||||
else if (*s != '\r') {
|
else if (*buf != '\r') {
|
||||||
s++;
|
buf++;
|
||||||
noChars--;
|
noChars--;
|
||||||
}
|
}
|
||||||
*s = '\0';
|
*buf = '\0';
|
||||||
} while ((bytes == 1) && (noChars > 1));
|
} while ((bytes == 1) && (noChars > 1));
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ void WCMD_verify (const WCHAR *command);
|
||||||
void WCMD_version (void);
|
void WCMD_version (void);
|
||||||
int WCMD_volume (BOOL set_label, const WCHAR *command);
|
int WCMD_volume (BOOL set_label, const WCHAR *command);
|
||||||
|
|
||||||
WCHAR *WCMD_fgets (WCHAR *s, int n, HANDLE stream, const BOOL is_console_handle);
|
WCHAR *WCMD_fgets (WCHAR *buf, int n, HANDLE stream, const BOOL is_console_handle);
|
||||||
WCHAR *WCMD_parameter (WCHAR *s, int n, WCHAR **where, WCHAR **end);
|
WCHAR *WCMD_parameter (WCHAR *s, int n, WCHAR **where, WCHAR **end);
|
||||||
WCHAR *WCMD_skip_leading_spaces (WCHAR *string);
|
WCHAR *WCMD_skip_leading_spaces (WCHAR *string);
|
||||||
BOOL WCMD_keyword_ws_found(const WCHAR *keyword, int len, const WCHAR *ptr);
|
BOOL WCMD_keyword_ws_found(const WCHAR *keyword, int len, const WCHAR *ptr);
|
||||||
|
|
Loading…
Reference in New Issue