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

Frédéric Delanoy frederic.delanoy at gmail.com
Wed Oct 5 07:02:44 CDT 2011


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

diff --git a/programs/cmd/batch.c b/programs/cmd/batch.c
index 5f83c35..77a49c9 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,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
      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;
   }
 
   /* TODO: More intelligent buffering for reading lines from files */
   do {
-    status = WCMD_ReadFile(h, s, 1, &bytes);
-    if ((status == 0) || ((bytes == 0) && (s == p))) return NULL;
-    if (*s == '\n') bytes = 0;
-    else if (*s != '\r') {
-      s++;
+    status = WCMD_ReadFile(h, buf, 1, &bytes);
+    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 98e1246..af75a5d 100644
--- a/programs/cmd/wcmd.h
+++ b/programs/cmd/wcmd.h
@@ -97,7 +97,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