diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2013-11-13 17:52:18 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2013-11-13 17:52:18 -0800 |
commit | d672ac3c611453c624948ed8cc2ced65cadc3400 (patch) | |
tree | a5b52d6ff15caf0a755cc0729d29474a5ae4a6a3 | |
parent | ff6ec81d6dd564080d8407c0a0eae36461b3b75d (diff) |
Prefer tail calls.
* lib-src/ebrowse.c (xstrdup):
* lib-src/etags.c (savenstr):
* lwlib/lwlib.c (safe_strdup):
* src/xfns.c (xic_create_fontsetname):
* src/xrdb.c (gethomedir): Prefer tail calls.
* lib-src/etags.c (concat): Omit unnecessary assignment.
-rw-r--r-- | lib-src/ChangeLog | 6 | ||||
-rw-r--r-- | lib-src/ebrowse.c | 2 | ||||
-rw-r--r-- | lib-src/etags.c | 8 | ||||
-rw-r--r-- | lwlib/ChangeLog | 4 | ||||
-rw-r--r-- | lwlib/lwlib.c | 6 | ||||
-rw-r--r-- | src/ChangeLog | 5 | ||||
-rw-r--r-- | src/xfns.c | 2 | ||||
-rw-r--r-- | src/xrdb.c | 4 |
8 files changed, 21 insertions, 16 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 44d7260dea..2010444743 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,9 @@ +2013-11-14 Paul Eggert <eggert@cs.ucla.edu> + + * ebrowse.c (xstrdup): + * etags.c (savenstr): Prefer tail calls. + * etags.c (concat): Omit unnecessary assignment. + 2013-10-24 Glenn Morris <rgm@gnu.org> * Makefile.in ($(DESTDIR)${archlibdir}): diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c index 216865c380..971f74e7fe 100644 --- a/lib-src/ebrowse.c +++ b/lib-src/ebrowse.c @@ -514,7 +514,7 @@ static char * xstrdup (char *s) { if (s) - s = strcpy (xmalloc (strlen (s) + 1), s); + return strcpy (xmalloc (strlen (s) + 1), s); return s; } diff --git a/lib-src/etags.c b/lib-src/etags.c index aa8c773e35..21cf3654b9 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -6243,12 +6243,9 @@ savestr (const char *cp) static char * savenstr (const char *cp, int len) { - register char *dp; - - dp = xnew (len + 1, char); - memcpy (dp, cp, len); + char *dp = xnew (len + 1, char); dp[len] = '\0'; - return dp; + return memcpy (dp, cp, len); } /* @@ -6362,7 +6359,6 @@ concat (const char *s1, const char *s2, const char *s3) strcpy (result, s1); strcpy (result + len1, s2); strcpy (result + len1 + len2, s3); - result[len1 + len2 + len3] = '\0'; return result; } diff --git a/lwlib/ChangeLog b/lwlib/ChangeLog index dadb13514e..e4ab1a91ca 100644 --- a/lwlib/ChangeLog +++ b/lwlib/ChangeLog @@ -1,3 +1,7 @@ +2013-11-14 Paul Eggert <eggert@cs.ucla.edu> + + * lwlib.c (safe_strdup): Prefer tail calls. + 2013-11-02 Glenn Morris <rgm@gnu.org> Use relative filenames in TAGS files. diff --git a/lwlib/lwlib.c b/lwlib/lwlib.c index 7d9920e8bc..c8eba9cf35 100644 --- a/lwlib/lwlib.c +++ b/lwlib/lwlib.c @@ -103,11 +103,7 @@ static void show_one_widget_busy (Widget, Boolean); char * safe_strdup (const char *s) { - char *result; - if (! s) return 0; - result = (char *) xmalloc (strlen (s) + 1); - strcpy (result, s); - return result; + return s ? xstrdup (s) : 0; } static void diff --git a/src/ChangeLog b/src/ChangeLog index 08bbe9e69d..3861449cf5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2013-11-14 Paul Eggert <eggert@cs.ucla.edu> + + * xfns.c (xic_create_fontsetname): + * xrdb.c (gethomedir): Prefer tail calls. + 2013-11-12 Paul Eggert <eggert@cs.ucla.edu> * xterm.c (syms_of_xterm): staticpro Qmodifier_value, Qalt, Qhyper, diff --git a/src/xfns.c b/src/xfns.c index 42e7c2eeec..46f377042f 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -1750,7 +1750,7 @@ xic_create_fontsetname (const char *base_fontname, int motif) } } if (motif) - strcat (fontsetname, ":"); + return strcat (fontsetname, ":"); return fontsetname; } #endif /* HAVE_X_WINDOWS && USE_X_TOOLKIT */ diff --git a/src/xrdb.c b/src/xrdb.c index 52988f0818..ea823b2b31 100644 --- a/src/xrdb.c +++ b/src/xrdb.c @@ -234,9 +234,7 @@ gethomedir (void) copy = xmalloc (strlen (ptr) + 2); strcpy (copy, ptr); - strcat (copy, "/"); - - return copy; + return strcat (copy, "/"); } |