diff options
author | Colin Watson <cjwatson@debian.org> | 2002-04-28 22:50:11 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2002-04-28 22:50:11 +0000 |
commit | 789bf0a723d79ddcfe05cd771a97450d557ca260 (patch) | |
tree | bd1bc164cf181a12b19c5a2f84587eaf79967fde /src/check_mandirs.c | |
parent | f304b0c08d96ecd4d7b91b20bf3d1dc19f3246e7 (diff) |
Pass through much of the code adding 'const' where appropriate. This should
help me avoid various memory management bugs.
Diffstat (limited to 'src/check_mandirs.c')
-rw-r--r-- | src/check_mandirs.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/check_mandirs.c b/src/check_mandirs.c index 359bcdad..eb680408 100644 --- a/src/check_mandirs.c +++ b/src/check_mandirs.c @@ -140,7 +140,10 @@ int splitline (char *raw_whatis, struct mandata *info, char *base_name) fprintf (stderr, "raw_whatis = %s\n", raw_whatis); info->whatis = strstr (raw_whatis, " - "); if (info->whatis) { - char *space = info->whatis; + /* Deliberate cast in order to modify the whatis. + * Don't change its length! + */ + char *space = (char *) info->whatis; while (*space == ' ') *space-- = '\0'; /* separate description */ info->whatis += 3; @@ -254,15 +257,18 @@ char *filename_info (char *file, struct mandata *info, const char *req_name) info->comp = NULL; #endif /* COMP_SRC */ - info->ext = strrchr (base_name, '.'); - if (!info->ext) { - /* no section extension */ - gripe_bogus_manpage (file); - free (manpage); - return NULL; + { + char *ext = strrchr (base_name, '.'); + if (!ext) { + /* no section extension */ + gripe_bogus_manpage (file); + free (manpage); + return NULL; + } + *ext++ = '\0'; /* set section ext */ + info->ext = ext; } - *(info->ext++) = '\0'; /* set section ext */ *(base_name - 1) = '\0'; /* strip '/base_name' */ info->sec = strrchr (manpage, '/') + 4; /* set section name */ |