diff options
author | Guillem Jover <guillem@debian.org> | 2018-07-12 03:22:37 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2018-08-30 03:14:08 +0200 |
commit | 05c5c373dad18117942ea59440f9867c2f0d6a73 (patch) | |
tree | e84541115887f41540d67ae81e7f1b9b784e66c4 /dselect | |
parent | fbed23421fe867d76e6123d2cf79ffafeed5aafd (diff) | |
download | dpkg-05c5c373dad18117942ea59440f9867c2f0d6a73.tar.gz |
Switch from strchr() + strlen() to strchrnul()
Diffstat (limited to 'dselect')
-rw-r--r-- | dselect/baselist.cc | 7 | ||||
-rw-r--r-- | dselect/pkginfo.cc | 6 |
2 files changed, 7 insertions, 6 deletions
diff --git a/dselect/baselist.cc b/dselect/baselist.cc index 05465fc92..6fd769239 100644 --- a/dselect/baselist.cc +++ b/dselect/baselist.cc @@ -410,8 +410,8 @@ void baselist::wordwrapinfo(int offset, const char *m) { for (;;) { int offleft=offset; while (*m == ' ' && offleft>0) { m++; offleft--; } - const char *p= strchr(m,'\n'); - int l= p ? (int)(p-m) : strlen(m); + const char *p = strchrnul(m, '\n'); + int l = (int)(p - m); while (l && c_isspace(m[l - 1])) l--; if (!l || (*m == '.' && l == 1)) { @@ -452,7 +452,8 @@ void baselist::wordwrapinfo(int offset, const char *m) { } wrapping = true; } - if (!p) break; + if (*p == '\0') + break; if (getcury(infopad) == (MAX_DISPLAY_INFO - 1)) { waddstr(infopad, "[The package description is too long and has been truncated...]"); diff --git a/dselect/pkginfo.cc b/dselect/pkginfo.cc index e11067fdf..31a45994f 100644 --- a/dselect/pkginfo.cc +++ b/dselect/pkginfo.cc @@ -114,14 +114,14 @@ void packagelist::itd_description() { m = table[cursorline]->pkg->installed.description; if (str_is_unset(m)) m = _("No description available."); - const char *p= strchr(m,'\n'); - int l= p ? (int)(p-m) : strlen(m); + const char *p = strchrnul(m, '\n'); + int l = (int)(p - m); wattrset(infopad, part_attr[info_head]); waddstr(infopad, table[cursorline]->pkg->set->name); waddstr(infopad," - "); waddnstr(infopad,m,l); wattrset(infopad, part_attr[info_body]); - if (p) { + if (*p) { waddstr(infopad,"\n\n"); wordwrapinfo(1,++p); } |