Hi Bram!

On Sa, 02 Nov 2013, Bram Moolenaar wrote:

> !         if (*s != NUL)
> !             ++s;

Isn't that worth a macro?

regards,
Christian
-- 

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
diff --git a/src/buffer.c b/src/buffer.c
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -4062,8 +4062,7 @@
 		item[curitem].minwid = -syn_namen2id(t, (int)(s - t));
 		curitem++;
 	    }
-	    if (*s != NUL)
-		s++;
+	    INCREMENT_PTR(s)
 	    continue;
 	}
 
diff --git a/src/dosinst.c b/src/dosinst.c
--- a/src/dosinst.c
+++ b/src/dosinst.c
@@ -962,8 +962,7 @@
 	    }
 	    ++count;
 	    p = s;
-	    if (*p != NUL)
-		++p;
+	    INCREMENT_PTR(p)
 	}
 	if (names != NULL)
 	    break;
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -3970,8 +3970,7 @@
 	    if (p == NULL)
 		p = eap->nextcmd + STRLEN(eap->nextcmd);
 	    theline = vim_strnsave(eap->nextcmd, (int)(p - eap->nextcmd));
-	    if (*p != NUL)
-		++p;
+	    INCREMENT_PTR(p)
 	    eap->nextcmd = p;
 	}
 	else
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -4042,8 +4042,7 @@
 	    if (*cmd == NUL && ctx != NULL)
 		*ctx = EXPAND_NOTHING;
 	}
-	if (*cmd != NUL)
-	    ++cmd;
+	INCREMENT_PTR(cmd)
     }
 
     /* Skip ":" and white space. */
diff --git a/src/ex_getln.c b/src/ex_getln.c
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -4923,8 +4923,7 @@
 		vim_free(*file);
 	    }
 	}
-	if (*e != NUL)
-	    ++e;
+	INCREMENT_PTR(e)
     }
     *file = ga.ga_data;
     *num_file = ga.ga_len;
@@ -5023,8 +5022,7 @@
 	if (xp->xp_pattern[0] && vim_regexec(regmatch, s, (colnr_T)0) == 0)
 	{
 	    *e = keep;
-	    if (*e != NUL)
-		++e;
+	    INCREMENT_PTR(e)
 	    continue;
 	}
 
@@ -5035,8 +5033,7 @@
 	++ga.ga_len;
 
 	*e = keep;
-	if (*e != NUL)
-	    ++e;
+	INCREMENT_PTR(e)
     }
     vim_free(retstr);
     *file = ga.ga_data;
@@ -5138,8 +5135,7 @@
 					    vim_strnsave(s, (int)(e - s - 4));
 		++ga.ga_len;
 	    }
-	    if (*e != NUL)
-		++e;
+	    INCREMENT_PTR(e)
 	}
 	vim_free(matches);
     }
diff --git a/src/macros.h b/src/macros.h
--- a/src/macros.h
+++ b/src/macros.h
@@ -303,3 +303,7 @@
 #  endif
 # endif
 #endif
+
+/* increment pointer, if it isn't NUL */
+#define INCREMENT_PTR(a) if (*a != NUL) \
+				   ++a;
diff --git a/src/message.c b/src/message.c
--- a/src/message.c
+++ b/src/message.c
@@ -4811,8 +4811,8 @@
 		break;
 	    }
 
-	    if (*p != NUL)
-		p++;     /* step over the just processed conversion specifier */
+	    /* step over the just processed conversion specifier */
+	    INCREMENT_PTR(p)
 
 	    /* insert padding to the left as requested by min_field_width;
 	     * this does not include the zero padding in case of numerical
diff --git a/src/misc1.c b/src/misc1.c
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -6228,8 +6228,7 @@
 		p = line + i;
 	    }
 	}
-	if (*p != NUL)
-	    ++p;
+	INCREMENT_PTR(p)
     }
     return FALSE;
 }
@@ -6299,8 +6298,7 @@
 	    if (*s == '{' || *s == '}'
 		    || (*s == ';' && cin_nocode(s + 1)))
 		break;
-	    if (*s != NUL)
-		++s;
+	    INCREMENT_PTR(s)
 	}
 	if (*s != NUL)
 	    break;
@@ -6459,8 +6457,7 @@
 	    if (cin_nocode(r))
 		return TRUE;
 	}
-	if (*p != NUL)
-	    ++p;
+	INCREMENT_PTR(p)
     }
     return FALSE;
 }
diff --git a/src/option.c b/src/option.c
--- a/src/option.c
+++ b/src/option.c
@@ -10608,8 +10608,7 @@
 	if (p[0] == 't' && p[1] == '_')
 	{
 	    p += 2;
-	    if (*p != NUL)
-		++p;
+	    INCREMENT_PTR(p)
 	    if (*p == NUL)
 		return;		/* expand option name */
 	    nextchar = *++p;
diff --git a/src/os_unix.c b/src/os_unix.c
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -5965,8 +5965,7 @@
 	{
 	    while (*p != '\n' && *p != NUL)
 		++p;
-	    if (*p != NUL)
-		++p;
+	    INCREMENT_PTR(p)
 	    p = skipwhite(p);		/* skip leading white space */
 	}
     }
diff --git a/src/tag.c b/src/tag.c
--- a/src/tag.c
+++ b/src/tag.c
@@ -2831,8 +2831,7 @@
 #ifdef FEAT_TAG_ANYWHITE
 	p = skipwhite(p);
 #else
-	if (*p != NUL)
-	    ++p;
+	INCREMENT_PTR(p)
 #endif
 	tagp->fname = p;
 #ifdef FEAT_TAG_ANYWHITE
@@ -2848,8 +2847,7 @@
 #ifdef FEAT_TAG_ANYWHITE
 	p = skipwhite(p);
 #else
-	if (*p != NUL)
-	    ++p;
+	INCREMENT_PTR(p)
 #endif
 	if (*p == NUL)
 	    return FAIL;

Raspunde prin e-mail lui