[2/4] cmd: Rename a parameter in WCMD_fgets (try 2)

Frédéric Delanoy frederic.delanoy at gmail.com
Tue Oct 4 07:41:02 CDT 2011


buf is more descriptive than s, although that can be trivially inferred from the context.
---
 programs/cmd/batch.c |   32 ++++++++++++++++----------------
 programs/cmd/wcmd.h  |    2 +-
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/programs/cmd/batch.c b/programs/cmd/batch.c
index e13ecaa..0afca4a 100644
--- a/programs/cmd/batch.c
+++ b/programs/cmd/batch.c
@@ -176,17 +176,17 @@ WCHAR *WCMD_parameter (WCHAR *s, int n, WCHAR **where, WCHAR **end) {
 /****************************************************************************
  * WCMD_fgets
  *
- * Gets one line from a file/console and puts it into buffer s
- * Pre:  s has size noChars
+ * Gets one line from a file/console and puts it into buffer buf
+ * Pre:  buf has size noChars
  *       1 <= noChars <= MAXSTRING
- * Post: s is filled with at most noChars-1 characters, and gets nul-terminated
-         s does not include EOL terminator
+ * Post: buf is filled with at most noChars-1 characters, and gets nul-terminated
+         buf does not include EOL terminator
  * Returns:
- *       s on success
+ *       buf on success
  *       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;
   BOOL status;
@@ -195,15 +195,15 @@ 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
      between DOS and Unix. Also need to lose the LF (or CRLF) from the line. */
 
-  p = s;
+  p = buf;
   if (is_console_handle) {
-    status = ReadConsoleW(h, s, noChars, &charsRead, NULL);
+    status = ReadConsoleW(h, buf, noChars, &charsRead, NULL);
     if (!status) return NULL;
-    if (s[charsRead-2] == '\r')
-      s[charsRead-2] = '\0'; /* Strip \r\n */
+    if (buf[charsRead-2] == '\r')
+      buf[charsRead-2] = '\0'; /* Strip \r\n */
     else {
       /* Truncate */
-      s[noChars-1] = '\0';
+      buf[noChars-1] = '\0';
     }
     return p;
   }
@@ -211,13 +211,13 @@ WCHAR *WCMD_fgets(WCHAR *s, int noChars, HANDLE h, BOOL is_console_handle)
   /* TODO: More intelligent buffering for reading lines from files */
   do {
     status = WCMD_ReadFile(h, s, 1, &bytes, CMD_HT_FILE);
-    if ((status == 0) || ((bytes == 0) && (s == p))) return NULL;
-    if (*s == '\n') bytes = 0;
-    else if (*s != '\r') {
-      s++;
+    if ((status == 0) || ((bytes == 0) && (buf == p))) return NULL;
+    if (*buf == '\n') bytes = 0;
+    else if (*buf != '\r') {
+      buf++;
       noChars--;
     }
-    *s = '\0';
+    *buf = '\0';
   } while ((bytes == 1) && (noChars > 1));
   return p;
 }
diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h
index 8eb7b03..3dbadcd 100644
--- a/programs/cmd/wcmd.h
+++ b/programs/cmd/wcmd.h
@@ -105,7 +105,7 @@ void WCMD_verify (const WCHAR *command);
 void WCMD_version (void);
 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_skip_leading_spaces (WCHAR *string);
 BOOL WCMD_keyword_ws_found(const WCHAR *keyword, int len, const WCHAR *ptr);
-- 
1.7.7




More information about the wine-patches mailing list