On 12/09/13 15:27, Philip Martin wrote:
Martin Furter<mfur...@bluewin.ch>  writes:

Wouldn't last_dot[1] be more readable than (*(last_dot + 1) ?

Probably. I approve a patch if you want to commit.

A quick grep shows 21 of those constructs in the following files:

./subversion/libsvn_subr/path.c
./subversion/libsvn_subr/dirent_uri.c
./subversion/libsvn_subr/string.c
./subversion/libsvn_ra_svn/marshal.c
./subversion/libsvn_diff/diff_memory.c
./subversion/libsvn_diff/parse-diff.c
./subversion/libsvn_client/patch.c

A grep for "foo[N]" where N is >0 finds more than 900 lines. And lines containing "char foo[N]" are already subtracted.

I guess we should make all these 21 cases consistent with the rest of the code.

[[[
Replace 21 occurrences of *(foo+N) by the more readable foo[N] syntax.

* subversion/libsvn_client/patch.c
  (readline_prop): Replace *(foo+N) by foo[N].
* subversion/libsvn_diff/diff_memory.c
  (fill_source_tokens): Ditto.
* subversion/libsvn_diff/parse-diff.c
  (git_start): Ditto.
* subversion/libsvn_ra_svn/marshal.c
  (vwrite_tuple): Ditto.
* subversion/libsvn_subr/dirent_uri.c
  (canonicalize,svn_uri_is_canonical): Ditto.
* subversion/libsvn_subr/path.c
  (svn_path_splitext): Ditto.
* subversion/libsvn_subr/string.c
  (svn_cstring_count_newlines): Ditto.
]]]

Trying to get it to compile and test but Schwurblix always decides to not install the important packages. I'm working on it...

- Martin
Index: subversion/libsvn_client/patch.c
===================================================================
--- subversion/libsvn_client/patch.c    (revision 1549528)
+++ subversion/libsvn_client/patch.c    (working copy)
@@ -568,7 +568,7 @@
       else if (*c == '\r')
         {
           *eol_str = "\r";
-          if (*(c + 1) == '\n')
+          if (c[1] == '\n')
             {
               *eol_str = "\r\n";
               b->offset++;
Index: subversion/libsvn_diff/diff_memory.c
===================================================================
--- subversion/libsvn_diff/diff_memory.c        (revision 1549528)
+++ subversion/libsvn_diff/diff_memory.c        (working copy)
@@ -229,7 +229,7 @@
   for (startp = curp = text->data, endp = curp + text->len;
        curp != endp; curp++)
     {
-      if (curp != endp && *curp == '\r' && *(curp + 1) == '\n')
+      if (curp != endp && *curp == '\r' && curp[1] == '\n')
         curp++;
 
       if (*curp == '\r' || *curp == '\n')
Index: subversion/libsvn_diff/parse-diff.c
===================================================================
--- subversion/libsvn_diff/parse-diff.c (revision 1549528)
+++ subversion/libsvn_diff/parse-diff.c (working copy)
@@ -883,7 +883,7 @@
       return SVN_NO_ERROR;
     }
 
-  if (! *(old_path_marker + 3))
+  if (! old_path_marker[3])
     {
       *new_state = state_start;
       return SVN_NO_ERROR;
@@ -897,7 +897,7 @@
       return SVN_NO_ERROR;
     }
 
-  if (! *(new_path_marker + 3))
+  if (! new_path_marker[3])
     {
       *new_state = state_start;
       return SVN_NO_ERROR;
Index: subversion/libsvn_ra_svn/marshal.c
===================================================================
--- subversion/libsvn_ra_svn/marshal.c  (revision 1549528)
+++ subversion/libsvn_ra_svn/marshal.c  (working copy)
@@ -910,7 +910,7 @@
         SVN_ERR(vwrite_tuple_number(conn, pool, ap));
       else if (*fmt == 'b' && !opt)
         SVN_ERR(vwrite_tuple_boolean(conn, pool, ap));
-      else if (*fmt == '!' && !*(fmt + 1))
+      else if (*fmt == '!' && !fmt[1])
         return SVN_NO_ERROR;
       else
         SVN_ERR_MALFUNCTION();
Index: subversion/libsvn_subr/dirent_uri.c
===================================================================
--- subversion/libsvn_subr/dirent_uri.c (revision 1549528)
+++ subversion/libsvn_subr/dirent_uri.c (working copy)
@@ -323,7 +323,7 @@
       while (*src && (*src != '/') && (*src != ':'))
         src++;
 
-      if (*src == ':' && *(src+1) == '/' && *(src+2) == '/')
+      if (*src == ':' && src[1] == '/' && src[2] == '/')
         {
           const char *seg;
 
@@ -567,8 +567,8 @@
               case '/':
                 break;
               case '%':
-                if (!svn_ctype_isxdigit(*(src+1)) ||
-                    !svn_ctype_isxdigit(*(src+2)))
+                if (!svn_ctype_isxdigit(src[1]) ||
+                    !svn_ctype_isxdigit(src[2]))
                   need_extra += 2;
                 else
                   src += 2;
@@ -604,8 +604,8 @@
                 *(dst++) = '/';
                 break;
               case '%':
-                if (!svn_ctype_isxdigit(*(src+1)) ||
-                    !svn_ctype_isxdigit(*(src+2)))
+                if (!svn_ctype_isxdigit(src[1]) ||
+                    !svn_ctype_isxdigit(src[2]))
                   {
                     *(dst++) = '%';
                     *(dst++) = '2';
@@ -1790,7 +1790,7 @@
     ptr++;
 
   /* No scheme?  No good. */
-  if (! (*ptr == ':' && *(ptr+1) == '/' && *(ptr+2) == '/'))
+  if (! (*ptr == ':' && ptr[1] == '/' && ptr[2] == '/'))
     return FALSE;
 
   /* Found a scheme, check that it's all lowercase. */
@@ -1878,8 +1878,8 @@
          file:///C:/path. Check that if we have such a URL the drive
          letter is in uppercase. */
       if (strncmp(uri, "file:", 5) == 0 &&
-          ! (*(ptr+1) >= 'A' && *(ptr+1) <= 'Z') &&
-          *(ptr+2) == ':')
+          ! (ptr[1] >= 'A' && ptr[1] <= 'Z') &&
+          ptr[2] == ':')
         return FALSE;
     }
 #endif /* SVN_USE_DOS_PATHS */
@@ -1895,7 +1895,7 @@
       if (seglen == 1 && *seg == '.')
         return FALSE;  /*  /./   */
 
-      if (*ptr == '/' && *(ptr+1) == '/')
+      if (*ptr == '/' && ptr[1] == '/')
         return FALSE;  /*  //    */
 
       if (! *ptr && *(ptr - 1) == '/' && ptr - 1 != uri)
@@ -1923,11 +1923,11 @@
 
           /* Can't usesvn_ctype_isxdigit() because lower case letters are
              not in our canonical format */
-          if (((*(ptr+1) < '0' || *(ptr+1) > '9'))
-              && (*(ptr+1) < 'A' || *(ptr+1) > 'F'))
+          if (((ptr[1] < '0' || ptr[1] > '9'))
+              && (ptr[1] < 'A' || ptr[1] > 'F'))
             return FALSE;
-          else if (((*(ptr+2) < '0' || *(ptr+2) > '9'))
-                   && (*(ptr+2) < 'A' || *(ptr+2) > 'F'))
+          else if (((ptr[2] < '0' || ptr[2] > '9'))
+                   && (ptr[2] < 'A' || ptr[2] > 'F'))
             return FALSE;
 
           digitz[0] = *(++ptr);
Index: subversion/libsvn_subr/path.c
===================================================================
--- subversion/libsvn_subr/path.c       (revision 1549528)
+++ subversion/libsvn_subr/path.c       (working copy)
@@ -1252,7 +1252,7 @@
      anything after it?  We look for the "rightmost" period in the
      string. */
   last_dot = strrchr(path, '.');
-  if (last_dot && (*(last_dot + 1) != '\0'))
+  if (last_dot && (last_dot[1] != '\0'))
     {
       /* If we have a period, we need to make sure it occurs in the
          final path component -- that there's no path separator
Index: subversion/libsvn_subr/string.c
===================================================================
--- subversion/libsvn_subr/string.c     (revision 1549528)
+++ subversion/libsvn_subr/string.c     (working copy)
@@ -908,13 +908,13 @@
       if (*p == '\n')
         {
           count++;
-          if (*(p + 1) == '\r')
+          if (p[1] == '\r')
             p++;
         }
       else if (*p == '\r')
         {
           count++;
-          if (*(p + 1) == '\n')
+          if (p[1] == '\n')
             p++;
         }
     }

Reply via email to