Apply clang-format to source tree
[alexxy/gromacs.git] / src / gromacs / topology / symtab.cpp
index f51e2a6ba5e76533ba6588ecd934f8a2dccde80a..ff3d3109d00be0a6081796cb4119eb82750b6ed9 100644 (file)
@@ -52,7 +52,7 @@
 constexpr int c_trimSize   = 1024;
 constexpr int c_maxBufSize = 5;
 
-static char *trim_string(const char *s, char *out, int maxlen)
+static char* trim_string(const char* s, char* out, int maxlen)
 /*
  * Returns a pointer to a static area which contains a copy
  * of s without leading or trailing spaces. Strings are
@@ -64,26 +64,22 @@ static char *trim_string(const char *s, char *out, int maxlen)
 {
     int len, i;
 
-    if (strlen(s) > static_cast<size_t>(maxlen-1))
+    if (strlen(s) > static_cast<size_t>(maxlen - 1))
     {
-        gmx_fatal(FARGS, "String '%s' (%zu) is longer than buffer (%d).\n",
-                  s, strlen(s), maxlen-1);
+        gmx_fatal(FARGS, "String '%s' (%zu) is longer than buffer (%d).\n", s, strlen(s), maxlen - 1);
     }
 
-    for (; (*s) == ' '; s++)
-    {
-        ;
-    }
+    for (; (*s) == ' '; s++) {}
     for (len = strlen(s); (len > 0); len--)
     {
-        if (s[len-1] != ' ')
+        if (s[len - 1] != ' ')
         {
             break;
         }
     }
     if (len >= c_trimSize)
     {
-        len = c_trimSize-1;
+        len = c_trimSize - 1;
     }
     for (i = 0; i < len; i++)
     {
@@ -93,32 +89,32 @@ static char *trim_string(const char *s, char *out, int maxlen)
     return out;
 }
 
-int lookup_symtab(t_symtab *symtab, char **name)
+int lookup_symtab(t_symtab* symtab, char** name)
 {
     int       base;
-    t_symbuf *symbuf;
+    t_symbufsymbuf;
 
     base   = 0;
     symbuf = symtab->symbuf;
     while (symbuf != nullptr)
     {
-        const int index = name-symbuf->buf;
-        if ( ( index >= 0 ) && ( index < symbuf->bufsize ) )
+        const int index = name - symbuf->buf;
+        if ((index >= 0) && (index < symbuf->bufsize))
         {
-            return index+base;
+            return index + base;
         }
         else
         {
-            base  += symbuf->bufsize;
+            base += symbuf->bufsize;
             symbuf = symbuf->next;
         }
     }
     gmx_fatal(FARGS, "symtab lookup \"%s\" not found", *name);
 }
 
-char **get_symtab_handle(t_symtab *symtab, int name)
+char** get_symtab_handle(t_symtab* symtab, int name)
 {
-    t_symbuf *symbuf;
+    t_symbufsymbuf;
 
     symbuf = symtab->symbuf;
     while (symbuf != nullptr)
@@ -129,16 +125,16 @@ char **get_symtab_handle(t_symtab *symtab, int name)
         }
         else
         {
-            name  -= symbuf->bufsize;
+            name -= symbuf->bufsize;
             symbuf = symbuf->next;
         }
     }
     gmx_fatal(FARGS, "symtab get_symtab_handle %d not found", name);
 }
 
-static t_symbuf *new_symbuf()
+static t_symbufnew_symbuf()
 {
-    t_symbuf *symbuf;
+    t_symbufsymbuf;
 
     snew(symbuf, 1);
     symbuf->bufsize = c_maxBufSize;
@@ -148,11 +144,11 @@ static t_symbuf *new_symbuf()
     return symbuf;
 }
 
-static char **enter_buf(t_symtab *symtab, char *name)
+static char** enter_buf(t_symtab* symtab, char* name)
 {
-    int          i;
-    t_symbuf    *symbuf;
-    gmx_bool     bCont;
+    int       i;
+    t_symbufsymbuf;
+    gmx_bool  bCont;
 
     if (symtab->symbuf == nullptr)
     {
@@ -184,8 +180,7 @@ static char **enter_buf(t_symtab *symtab, char *name)
         {
             bCont = FALSE;
         }
-    }
-    while (bCont);
+    } while (bCont);
 
     symbuf->next = new_symbuf();
     symbuf       = symbuf->next;
@@ -195,36 +190,34 @@ static char **enter_buf(t_symtab *symtab, char *name)
     return &(symbuf->buf[0]);
 }
 
-char **put_symtab(t_symtab *symtab, const char *name)
+char** put_symtab(t_symtab* symtab, const char* name)
 {
     char buf[1024];
 
     return enter_buf(symtab, trim_string(name, buf, 1023));
 }
 
-void open_symtab(t_symtab *symtab)
+void open_symtab(t_symtabsymtab)
 {
     symtab->nr     = 0;
     symtab->symbuf = nullptr;
 }
 
-void close_symtab(t_symtab gmx_unused *symtab)
-{
-}
+void close_symtab(t_symtab gmx_unused* symtab) {}
 
 // TODO this will go away when we use a
 // std::list<std::vector<std::string>>> for t_symtab.
-t_symtab *duplicateSymtab(const t_symtab *symtab)
+t_symtab* duplicateSymtab(const t_symtab* symtab)
 {
-    t_symtab *copySymtab;
+    t_symtabcopySymtab;
     snew(copySymtab, 1);
     open_symtab(copySymtab);
-    t_symbuf *symbuf = symtab->symbuf;
+    t_symbufsymbuf = symtab->symbuf;
     if (symbuf != nullptr)
     {
         snew(copySymtab->symbuf, 1);
     }
-    t_symbuf *copySymbuf = copySymtab->symbuf;
+    t_symbufcopySymbuf = copySymtab->symbuf;
     while (symbuf != nullptr)
     {
         snew(copySymbuf->buf, symbuf->bufsize);
@@ -247,7 +240,7 @@ t_symtab *duplicateSymtab(const t_symtab *symtab)
     return copySymtab;
 }
 
-void done_symtab(t_symtab *symtab)
+void done_symtab(t_symtabsymtab)
 {
     int       i;
     t_symbuf *symbuf, *freeptr;
@@ -273,7 +266,7 @@ void done_symtab(t_symtab *symtab)
     }
 }
 
-void free_symtab(t_symtab *symtab)
+void free_symtab(t_symtabsymtab)
 {
     t_symbuf *symbuf, *freeptr;
 
@@ -282,8 +275,8 @@ void free_symtab(t_symtab *symtab)
     while (symbuf != nullptr)
     {
         symtab->nr -= std::min(symbuf->bufsize, symtab->nr);
-        freeptr     = symbuf;
-        symbuf      = symbuf->next;
+        freeptr = symbuf;
+        symbuf  = symbuf->next;
         sfree(freeptr);
     }
     symtab->symbuf = nullptr;
@@ -293,10 +286,10 @@ void free_symtab(t_symtab *symtab)
     }
 }
 
-void pr_symtab(FILE *fp, int indent, const char *title, t_symtab *symtab)
+void pr_symtab(FILE* fp, int indent, const char* title, t_symtab* symtab)
 {
     int       i, j, nr;
-    t_symbuf *symbuf;
+    t_symbufsymbuf;
 
     if (available(fp, symtab, indent, title))
     {
@@ -309,9 +302,9 @@ void pr_symtab(FILE *fp, int indent, const char *title, t_symtab *symtab)
             for (j = 0; (j < symbuf->bufsize) && (j < nr); j++)
             {
                 pr_indent(fp, indent);
-                (void) fprintf(fp, "%s[%d]=\"%s\"\n", title, i++, symbuf->buf[j]);
+                (void)fprintf(fp, "%s[%d]=\"%s\"\n", title, i++, symbuf->buf[j]);
             }
-            nr    -= j;
+            nr -= j;
             symbuf = symbuf->next;
         }
         if (nr != 0)