Commits

Greg Ward  committed b59180a

fossil: fix style: wrap comments, whitespace, line breaks.

  • Participants
  • Parent commits 36b4612

Comments (0)

Files changed (1)

File src/fossil.c

     return isfile("_FOSSIL_");
 }
 
-char *get_till_eol(char *dest, const char *src, int n) {
+char *
+get_till_eol(char *dest, const char *src, int n)
+{
     char *last = strchr(src, '\n');
     if (last) {
-        int m = (last-src < n ? last-src : n);
+        int m = (last - src < n ? last - src : n);
         strncpy(dest, src, m);
-        dest[m]='\0';
+        dest[m] = '\0';
         return dest;
     }
     else {
     int tab_len = 14;
     char buf2[81];
 
-    /* Since fossil stores info in sqlite databases,
-     * we're going to read the output of 'fossil status'
-     * command and analyze it.
-     * We need enough to cover all the usual fields
-     * (note that 'comment:' can be several lines long)
-     * plus eventual output indicating changes in the repo.
-     */
-    if (!(stream = popen("fossil status","r"))) {
+    // Since fossil stores info in SQLite databases, we're going to read
+    // the output of 'fossil status' command and analyze it.  We need
+    // enough to cover all the usual fields (note that 'comment:' can be
+    // several lines long) plus eventual output indicating changes in
+    // the repo.
+    if (!(stream = popen("fossil status", "r"))) {
         debug("Unable to read output of 'fossil status'");
         return NULL;
     }
     else {
-        fread(buf,sizeof(char),2048,stream);
+        fread(buf, sizeof(char), 2048, stream);
         pclose(stream);
 
         if (context->options->show_branch) {
-            if ((t = strstr(buf,"\ntags:"))) {
-                /* This in fact shows also other tags than
-                 * just the propagating ones (=branches).
-                 * So either we show all of them (as now),
-                 * or we can show only the first one (which
-                 * should be the branch name); or we use
-                 * one more 'system' call to read the output
-                 * of 'fossil branch'.
-                 */
-                get_till_eol(buf2,t+tab_len+1,80);
+            if ((t = strstr(buf, "\ntags:"))) {
+                // This in fact shows also other tags than just the
+                // propagating ones (=branches).  So either we show all
+                // of them (as now), or we can show only the first one
+                // (which should be the branch name); or we use one more
+                // 'system' call to read the output of 'fossil branch'.
+                get_till_eol(buf2, t + tab_len + 1, 80);
                 debug("found tag line: '%s'", buf2);
                 result_set_branch(result, buf2);
             }
             }
         }
         if (context->options->show_revision) {
-            if ((t = strstr(buf,"\ncheckout:"))) {
-                get_till_eol(buf2,t+tab_len+1,80);
+            if ((t = strstr(buf, "\ncheckout:"))) {
+                get_till_eol(buf2, t + tab_len + 1, 80);
                 debug("found revision line: '%s'", buf2);
                 result_set_revision(result, buf2, 12);
             }
             }
         }
         if (context->options->show_modified) {
-            /* This can be also done by 'test -n'ing 'fossil changes',
-             * but we save a system call this way.
-             */
-            if ( strstr(buf,"\nEDITED") || strstr(buf,"\nADDED")
-                || strstr(buf,"\nDELETED") || strstr(buf,"\nMISSING")
-                || strstr(buf,"\nRENAMED") || strstr(buf,"\nNOT_A_FILE")
-                || strstr(buf,"\nUPDATED") || strstr(buf,"\nMERGED") )
+            // This can be also done by 'test -n'ing 'fossil changes',
+            // but we save a system call this way.
+            if ( strstr(buf, "\nEDITED") || strstr(buf, "\nADDED")
+                || strstr(buf, "\nDELETED") || strstr(buf, "\nMISSING")
+                || strstr(buf, "\nRENAMED") || strstr(buf, "\nNOT_A_FILE")
+                || strstr(buf, "\nUPDATED") || strstr(buf, "\nMERGED") )
                 result->modified = 1;
         }
         if (context->options->show_unknown) {
-            /* This can't be read from 'fossil status' output */
+            // This can't be read from 'fossil status' output
             int status = system("test -n \"$(fossil extra)\"");
             if (WEXITSTATUS(status) == 0)
                 result->unknown = 1;