summaryrefslogtreecommitdiff
path: root/popthelp.c
diff options
context:
space:
mode:
authorjbj <jbj>2008-03-27 17:35:33 +0000
committerjbj <jbj>2008-03-27 17:35:33 +0000
commit47b761dc58499b00a24306d66cf25fe7cb439529 (patch)
tree4029fcc05b1229d3c4a2f008788f6185b6411a24 /popthelp.c
parentd4b59476b4d749b7972e1adeca979d5a3c4e86e0 (diff)
downloadlibpopt-47b761dc58499b00a24306d66cf25fe7cb439529.tar.gz
- jbj: use stpcpy 2 more places (Wayne Davison<wayned@samba.org>).
Diffstat (limited to 'popthelp.c')
-rw-r--r--popthelp.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/popthelp.c b/popthelp.c
index 258cd76..39dd8b7 100644
--- a/popthelp.c
+++ b/popthelp.c
@@ -271,12 +271,12 @@ singleOptionDefaultValue(size_t lineLength,
if (s == NULL)
le = stpcpy(le, "null");
else {
- size_t slen = 4*lineLength - (le - l) - sizeof("\"...\")");
+ size_t limit = 4*lineLength - (le - l) - sizeof("\"\")");
+ size_t slen;
*le++ = '"';
- strncpy(le, s, slen); le[slen] = '\0'; le += strlen(le);
- if (slen < strlen(s)) {
- strcpy(le, "..."); le += strlen(le);
- }
+ strncpy(le, s, limit); le[limit] = '\0'; le += (slen = strlen(le));
+ if (slen == limit && s[limit])
+ le[-1] = le[-2] = le[-3] = '.';
*le++ = '"';
}
} break;
@@ -363,7 +363,6 @@ static void singleOptionHelp(FILE * fp, columns_t columns,
strlen(defs) + sizeof(" "));
if (t) {
char * te = t;
- *te = '\0';
if (help)
te = stpcpy(te, help);
*te++ = ' ';
@@ -417,24 +416,22 @@ static void singleOptionHelp(FILE * fp, columns_t columns,
case POPT_ARG_DOUBLE:
case POPT_ARG_STRING:
*le++ = (opt->longName != NULL ? '=' : ' ');
- strcpy(le, argDescrip); le += strlen(le);
+ le = stpcpy(le, argDescrip);
break;
default:
break;
}
} else {
- size_t lelen;
+ char *leo;
/* XXX argDescrip[0] determines "--foo=bar" or "--foo bar". */
if (!strchr(" =(", argDescrip[0]))
*le++ = ((poptArgType(opt) == POPT_ARG_MAINCALL) ? ' ' :
(poptArgType(opt) == POPT_ARG_ARGV) ? ' ' : '=');
- strcpy(le, argDescrip);
- lelen = strlen(le);
- le += lelen;
+ le = stpcpy(leo = le, argDescrip);
/* Adjust for (possible) wide characters. */
- displaypad = (int)(lelen - stringDisplayWidth(argDescrip));
+ displaypad = (int)((le - leo) - stringDisplayWidth(argDescrip));
}
if (F_ISSET(opt, OPTIONAL))
*le++ = ']';