Greg Ward avatar Greg Ward committed 9cbf272

Style consistency: format pointers like the rest of the C universe.
Instead of "type* name", use "type *name".

Comments (0)

Files changed (13)

 }
 
 void
-free_result(result_t* result)
+free_result(result_t *result)
 {
     free(result->revision);
     free(result->branch);
 static options_t* _options = NULL;
 
 void
-set_options(options_t* options)
+set_options(options_t *options)
 {
     _options = options;
 }
 }
 
 int
-result_set_revision(result_t* result, const char *revision, int len)
+result_set_revision(result_t *result, const char *revision, int len)
 {
     if (result->revision)
         free(result->revision);
 }
 
 int
-result_set_branch(result_t* result, const char *branch)
+result_set_branch(result_t *result, const char *branch)
 {
     if (result->branch)
         free(result->branch);
 
 vccontext_t*
 init_context(const char *name,
-             options_t* options,
+             options_t *options,
              int (*probe)(vccontext_t*),
              result_t* (*get_info)(vccontext_t*))
 {
-    vccontext_t* context = (vccontext_t*) calloc(1, sizeof(vccontext_t));
+    vccontext_t *context = (vccontext_t*) calloc(1, sizeof(vccontext_t));
     context->options = options;
     context->name = name;
     context->probe = probe;
 }
 
 void
-free_context(vccontext_t* context)
+free_context(vccontext_t *context)
 {
     free(context);
 }
 
 void
-debug(char* fmt, ...)
+debug(char *fmt, ...)
 {
     va_list args;
 
 }
 
 static int
-_testmode(char* name, mode_t bits, char what[])
+_testmode(char *name, mode_t bits, char what[])
 {
     struct stat statbuf;
     if (stat(name, &statbuf) < 0) {
 }
 
 int
-isdir(char* name)
+isdir(char *name)
 {
     return _testmode(name, S_IFDIR, "directory");
 }
 
 int
-isfile(char* name)
+isfile(char *name)
 {
     return _testmode(name, S_IFREG, "regular file");
 }
 
 int
-read_first_line(char* filename, char* buf, int size)
+read_first_line(char *filename, char *buf, int size)
 {
-    FILE* file;
+    FILE *file;
 
     file = fopen(filename, "r");
     if (file == NULL) {
 }
 
 int
-read_last_line(char* filename, char* buf, int size)
+read_last_line(char *filename, char *buf, int size)
 {
-    FILE* file;
+    FILE *file;
 
     file = fopen(filename, "r");
     if (file == NULL) {
 }
 
 int
-read_file(const char* filename, char* buf, int size)
+read_file(const char *filename, char *buf, int size)
 {
-    FILE* file;
+    FILE *file;
     int readsize;
 
     file = fopen(filename, "r");
 }
 
 void
-chop_newline(char* buf)
+chop_newline(char *buf)
 {
     int len = strlen(buf);
     if (buf[len-1] == '\n')
 }
 
 void
-dump_hex(const char* data, char* buf, int datasize)
+dump_hex(const char *data, char *buf, int datasize)
 {
     const char HEXSTR[16] = {'0', '1', '2', '3', '4', '5', '6', '7',
                              '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
  */
 typedef struct {
     int debug;
-    char* format;                       /* e.g. "[%b%u%m]" */
+    char *format;                       /* e.g. "[%b%u%m]" */
     int show_branch;                    /* show current branch? */
     int show_revision;                  /* show current revision? */
     int show_unknown;                   /* show ? if unknown files? */
     int show_modified;                  /* show + if local changes? */
-    unsigned int timeout;               /* timeout in milliseconds*/
+    unsigned int timeout;               /* timeout in milliseconds */
 } options_t;
 
 /* What we figured out by analyzing the working dir: info that
  * the user's prompt.
  */
 typedef struct {
-    char* branch;                       /* name of current branch */
-    char* revision;                     /* current revision */
+    char *branch;                       /* name of current branch */
+    char *revision;                     /* current revision */
     int unknown;                        /* any unknown files? */
     int modified;                       /* any local changes? */
 } result_t;
 
-int result_set_revision(result_t* result, const char *revision, int len);
-int result_set_branch(result_t* result, const char *branch);
+int result_set_revision(result_t *result, const char *revision, int len);
+int result_set_branch(result_t *result, const char *branch);
 
 typedef struct vccontext_t vccontext_t;
 struct vccontext_t {
     const char *name;                   /* name of the VC system */
-    options_t* options;
+    options_t *options;
 
     /* context methods */
     int (*probe)(vccontext_t*);
 
 vccontext_t*
 init_context(const char *name,
-             options_t* options,
+             options_t *options,
              int (*probe)(vccontext_t*),
              result_t* (*get_info)(vccontext_t*));
 
 void
-free_context(vccontext_t* context);
+free_context(vccontext_t *context);
 
 result_t*
 init_result();
  * debug mode is on (e.g. from the command line -d).
  */
 void
-debug(char* fmt, ...);
+debug(char *fmt, ...);
 
 /* stat() the specified file and return true if it is a directory, false
  * if stat() failed or it is not a directory.
  */
 int
-isdir(char* name);
+isdir(char *name);
 
 /* stat() the specified file and return true if it is a regular file,
  * false if stat() failed or it is not a regular file.
  */
 int
-isfile(char* name);
+isfile(char *name);
 
 /* Open the specified file, read the first line (up to size-1 chars) to
  * buf, and close the file.  buf will not contain a newline.  Caller
  * i.e. only visible if running in debug mode.
  */
 int
-read_first_line(char* filename, char* buf, int size);
+read_first_line(char *filename, char *buf, int size);
 
 /* Open the specified file, reading and discarding every line except the
  * last.  The last line is written to buf (up to size-1 chars) without
  * Return value and error handling: same as read_first_line().
  */
 int
-read_last_line(char* filename, char* buf, int size);
+read_last_line(char *filename, char *buf, int size);
 
 /* Open and read the specified file to buf (up to size chars).  Caller
  * must allocate at least size chars for buf.  buf is assumed to be
  * handling: same as read_first_line().
  */
 int
-read_file(const char* filename, char* buf, int size);
+read_file(const char *filename, char *buf, int size);
 
 /* If the last char of buf is '\n', replace it with '\0', i.e. terminate
  * the string one char earlier.
  */
 void
-chop_newline(char* buf);
+chop_newline(char *buf);
 
 /* Encode datasize bytes of binary data to hex chars in buf.  Caller
  * must allocate at least datasize*2 + 1 chars for buf.
  */
 void
-dump_hex(const char* data, char* buf, int datasize);
+dump_hex(const char *data, char *buf, int datasize);
 
 /* Copy up to nchars chars from src to dest, stopping at the first
  * newline and terminating dest with a NUL char.  On return, it is
 #include "cvs.h"
 
 static int
-cvs_probe(vccontext_t* context)
+cvs_probe(vccontext_t *context)
 {
     return isfile("CVS/Entries");
 }
 
 static result_t*
-cvs_get_info(vccontext_t* context)
+cvs_get_info(vccontext_t *context)
 {
-    result_t* result = init_result();
+    result_t *result = init_result();
     char buf[1024];
 
     if (!read_first_line("CVS/Tag", buf, 1024)) {
             result_set_branch(result, buf + 1);
         }
         else {
-            /* non-branch sticky tag or sticky date */            
-           result_set_branch(result, "(unknown)");
+            /* non-branch sticky tag or sticky date */
+            result_set_branch(result, "(unknown)");
         }
     }
     return result;
 }
 
 vccontext_t*
-get_cvs_context(options_t* options)
+get_cvs_context(options_t *options)
 {
     return init_context("cvs", options, cvs_probe, cvs_get_info);
 }
 
 #include "common.h"
 
-vccontext_t*
-get_cvs_context(options_t* options);
+vccontext_t *
+get_cvs_context(options_t *options);
 
 #endif
 #include "capture.h"
 
 static int
-fossil_probe(vccontext_t* context)
+fossil_probe(vccontext_t *context)
 {
     return isfile("_FOSSIL_") || isfile(".fslckout");
 }
 
 static result_t*
-fossil_get_info(vccontext_t* context)
+fossil_get_info(vccontext_t *context)
 {
-    result_t* result = init_result();
+    result_t *result = init_result();
     char *t;
     int tab_len = 14;
     char buf2[81];
 }
 
 vccontext_t*
-get_fossil_context(options_t* options)
+get_fossil_context(options_t *options)
 {
     return init_context("fossil", options, fossil_probe, fossil_get_info);
 }
 
 #include "common.h"
 
-vccontext_t*
-get_fossil_context(options_t* options);
+vccontext_t *
+get_fossil_context(options_t *options);
 
 #endif
 
 
 static int
-git_probe(vccontext_t* context)
+git_probe(vccontext_t *context)
 {
     return isdir(".git");
 }
 
 static result_t*
-git_get_info(vccontext_t* context)
+git_get_info(vccontext_t *context)
 {
-    result_t* result = init_result();
+    result_t *result = init_result();
     char buf[1024];
 
     if (!read_first_line(".git/HEAD", buf, 1024)) {
         return NULL;
     }
     else {
-        char* prefix = "ref: refs/heads/";
+        char *prefix = "ref: refs/heads/";
         int prefixlen = strlen(prefix);
 
         if (context->options->show_branch || context->options->show_revision) {
 }
 
 vccontext_t*
-get_git_context(options_t* options)
+get_git_context(options_t *options)
 {
     return init_context("git", options, git_probe, git_get_info);
 }
 
 #include "common.h"
 
-vccontext_t*
-get_git_context(options_t* options);
+vccontext_t *
+get_git_context(options_t *options);
 
 #endif
 #define NODEID_LEN 20
 
 static int
-hg_probe(vccontext_t* context)
+hg_probe(vccontext_t *context)
 {
     return isdir(".hg");
 }
 
 static int
-sum_bytes(const unsigned char* data, int size)
+sum_bytes(const unsigned char *data, int size)
 {
     int i, sum = 0;
     for (i = 0; i < size; ++i) {
 
 //! get changeset info for the specified nodeid
 static csinfo_t
-get_csinfo(const char* nodeid)
+get_csinfo(const char *nodeid)
 {
     // only supports RevlogNG. See mercurial/parsers.c for details.
-    const char* REVLOG_FILENAME = ".hg/store/00changelog.i";
+    const char *REVLOG_FILENAME = ".hg/store/00changelog.i";
     const size_t ENTRY_LEN = 64, COMP_LEN_OFS = 8, NODEID_OFS = 32;
 
     char buf[ENTRY_LEN];
-    FILE* f;
+    FILE *f;
     int inlined;
     csinfo_t csinfo = {"", -1, 0};
     int i;
 }
 
 static size_t
-get_mq_patchname(char* str, const char* nodeid, size_t n)
+get_mq_patchname(char *str, const char *nodeid, size_t n)
 {
     char buf[1024];
     char status_filename[512] = ".hg/patches/status";
 }
 
 static size_t
-put_nodeid(char* str, const char* nodeid)
+put_nodeid(char *str, const char *nodeid)
 {
     const size_t SHORT_NODEID_LEN = 6;  // size in binary repr
     char buf[512], *p = str;
 }
 
 static void
-read_parents(vccontext_t* context, result_t* result)
+read_parents(vccontext_t *context, result_t *result)
 {
     char buf[NODEID_LEN * 2];
     size_t readsize;
     readsize = read_file(".hg/dirstate", buf, NODEID_LEN * 2);
     if (readsize == NODEID_LEN * 2) {
         char destbuf[1024] = {'\0'};
-        char* p = destbuf;
+        char *p = destbuf;
         debug("read nodeids from .hg/dirstate");
 
         // first parent
 }
 
 static result_t*
-hg_get_info(vccontext_t* context)
+hg_get_info(vccontext_t *context)
 {
-    result_t* result = init_result();
+    result_t *result = init_result();
     char buf[1024];
 
     // prefer bookmark because it tends to be more informative
 }
 
 vccontext_t*
-get_hg_context(options_t* options)
+get_hg_context(options_t *options)
 {
     return init_context("hg", options, hg_probe, hg_get_info);
 }
 
 #include "common.h"
 
-vccontext_t*
-get_hg_context(options_t* options);
+vccontext_t *
+get_hg_context(options_t *options);
 
 #endif
 #include <ctype.h>
 
 static int
-svn_probe(vccontext_t* context)
+svn_probe(vccontext_t *context)
 {
     return isdir(".svn");
 }
 
 static result_t*
-svn_get_info(vccontext_t* context)
+svn_get_info(vccontext_t *context)
 {
-    result_t* result = init_result();
+    result_t *result = init_result();
     char buf[1024];
 
     if (!read_first_line(".svn/entries", buf, 1024)) {
             else {
                 // XML file format (working copy created by svn < 1.4)
                 char rev[100];
-                char* marker = "revision=";
-                char* p = NULL;
+                char *marker = "revision=";
+                char *p = NULL;
                 while (fgets(line, sizeof(line), fp))
                     if ((p = strstr(line, marker)) != NULL)
                         break;
 }
 
 vccontext_t*
-get_svn_context(options_t* options)
+get_svn_context(options_t *options)
 {
     return init_context("svn", options, svn_probe, svn_get_info);
 }
 
 #include "common.h"
 
-vccontext_t*
-get_svn_context(options_t* options);
+vccontext_t *
+get_svn_context(options_t *options);
 
 #endif
 #define DEFAULT_FORMAT "[%n:%b%m%u] "
 
 void
-parse_args(int argc, char** argv, options_t* options)
+parse_args(int argc, char** argv, options_t *options)
 {
     int opt;
     while ((opt = getopt(argc, argv, "hf:dt:")) != -1) {
 }
 
 void
-parse_format(options_t* options)
+parse_format(options_t *options)
 {
     size_t i;
 
     options->show_unknown = 0;
     options->show_modified = 0;
 
-    char* format = options->format;
+    char *format = options->format;
     size_t len = strlen(format);
     for (i = 0; i < len; i++) {
         if (format[i] == '%') {
 }
 
 void
-print_result(vccontext_t* context, options_t* options, result_t* result)
+print_result(vccontext_t *context, options_t *options, result_t *result)
 {
     size_t i;
-    char* format = options->format;
+    char *format = options->format;
     size_t len = strlen(format);
 
     for (i = 0; i < len; i++) {
 {
     int idx;
     for (idx = 0; idx < num_contexts; idx++) {
-        vccontext_t* ctx = contexts[idx];
+        vccontext_t *ctx = contexts[idx];
         if (ctx->probe(ctx)) {
             return ctx;
         }
 vccontext_t*
 probe_parents(vccontext_t** contexts, int num_contexts)
 {
-    vccontext_t* context;
+    vccontext_t *context;
     struct stat rootdir;
     struct stat curdir;
 
     /* Establish a handler for SIGALRM signals.  */
     signal(SIGALRM, exit_on_alarm);
 
-    char* format = getenv("VCPROMPT_FORMAT");
+    char *format = getenv("VCPROMPT_FORMAT");
     if (format == NULL)
         format = DEFAULT_FORMAT;
     options_t options = {
         debug("will never timeout");
     }
 
-    vccontext_t* contexts[] = {
+    vccontext_t *contexts[] = {
         get_cvs_context(&options),
         get_git_context(&options),
         get_hg_context(&options),
     };
     int num_contexts = sizeof(contexts) / sizeof(vccontext_t*);
 
-    result_t* result = NULL;
-    vccontext_t* context = NULL;
+    result_t *result = NULL;
+    vccontext_t *context = NULL;
 
     /* Starting in the current dir, walk up the directory tree until
        someone claims that this is a working copy. */
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.