Commits

Greg Ward committed 605e46d

capture: do not use 'stdout' and 'stderr' as struct members

They are defined as macros by C89 and C99; with glibc I got away with
the sloppiness, but not on Darwin. Build fails on OS X. This fixes it.

Comments (0)

Files changed (4)

     capture_t *result = malloc(sizeof(capture_t));
     if (result == NULL)
         goto err;
-    init_dynbuf(&result->stdout, bufsize);
-    if (result->stdout.buf == NULL)
+    init_dynbuf(&result->childout, bufsize);
+    if (result->childout.buf == NULL)
         goto err;
 
-    init_dynbuf(&result->stderr, bufsize);
-    if (result->stderr.buf == NULL)
+    init_dynbuf(&result->childerr, bufsize);
+    if (result->childerr.buf == NULL)
         goto err;
 
     return result;
 free_capture(capture_t *result)
 {
     if (result != NULL) {
-        if (result->stdout.buf != NULL)
-            free(result->stdout.buf);
-        if (result->stderr.buf != NULL)
-            free(result->stderr.buf);
+        if (result->childout.buf != NULL)
+            free(result->childout.buf);
+        if (result->childerr.buf != NULL)
+            free(result->childerr.buf);
         free(result);
     }
 }
         int maxfd = -1;
         fd_set child_fds;
         FD_ZERO(&child_fds);
-        if (!result->stdout.eof) {
+        if (!result->childout.eof) {
             FD_SET(cstdout, &child_fds);
             maxfd = cstdout;
         }
-        if (!result->stderr.eof) {
+        if (!result->childerr.eof) {
             FD_SET(cstderr, &child_fds);
             maxfd = cstderr;
         }
             break;
 
         if (FD_ISSET(cstdout, &child_fds)) {
-            if (read_dynbuf(cstdout, &result->stdout) < 0)
+            if (read_dynbuf(cstdout, &result->childout) < 0)
                 goto err;
         }
         if (FD_ISSET(cstderr, &child_fds)) {
-            if (read_dynbuf(cstderr, &result->stderr) < 0)
+            if (read_dynbuf(cstderr, &result->childerr) < 0)
                 goto err;
         }
-        done = result->stdout.eof && result->stderr.eof;
+        done = result->childout.eof && result->childerr.eof;
     }
 
     int status;
     if (result->signal != 0)
         debug("child process %s killed by signal %d",
               file, result->signal);
-    if (result->stderr.len > 0)
+    if (result->childerr.len > 0)
         debug("child process %s wrote to stderr:\n%s",
-              file, result->stderr.buf);
+              file, result->childerr.buf);
 
     return result;
  err:
         return 1;
     }
     printf("read %ld bytes from child stdout: >%s<\n",
-           result->stdout.len, result->stdout.buf);
+           result->childout.len, result->childout.buf);
     printf("read %ld bytes from child stderr: >%s<\n",
-           result->stderr.len, result->stderr.buf);
+           result->childerr.len, result->childerr.buf);
     status = result->status;
     printf("child status = %d, signal =%d\n", status, result->signal);
     free_capture(result);
 } dynbuf;
 
 typedef struct {
-    dynbuf stdout;
-    dynbuf stderr;
+    dynbuf childout;
+    dynbuf childerr;
     int status;                 /* exit status that child passed (if any) */
     int signal;                 /* signal that killed the child (if any) */
 } capture_t;
  * be file (unless you are playing funny games) and the last element
  * of argv must be NULL.
  *
- * On return, capture->stdout.buf will be the child's stdout, and
- * capture->stdout.len the number of bytes read. capture->stdout.buf
+ * On return, capture->childout.buf will be the child's stdout, and
+ * capture->childout.len the number of bytes read. capture->childout.buf
  * is null terminated, so as long as the child's output is textual,
  * you can use it as a string. Similarly, child's stderr is in
- * capture->stderr.buf and capture->stderr.len. Caller is responsible
+ * capture->childerr.buf and capture->childerr.len. Caller is responsible
  * for freeing the result with free_capture().
  */
 capture_t *
         debug("unable to execute 'fossil status'");
         return NULL;
     }
-    char *cstdout = capture->stdout.buf;
+    char *cstdout = capture->childout.buf;
 
     if (context->options->show_branch) {
         if ((t = strstr(cstdout, "\ntags:"))) {
             debug("unable to execute 'fossil extra'");
             return NULL;
         }
-        result->unknown = (capture->stdout.len > 0);
+        result->unknown = (capture->childout.len > 0);
         free_capture(capture);
     }
 
         char *argv[] = {
             "git", "ls-files", "--others", "--exclude-standard", NULL};
         capture_t *capture = capture_child("git", argv);
-        result->unknown = (capture != NULL && capture->stdout.len > 0);
+        result->unknown = (capture != NULL && capture->childout.len > 0);
 
         /* again, ignore other errors and assume no unknown files */
         free_capture(capture);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.