From 4511e43245942c904bc7e9a7cf45db59ff17e63e Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 26 Feb 2021 07:02:55 +0100 Subject: [PATCH] style: formatting changes * src/files.c, src/files.h: Save horizontal space. Prefer `res` for returned values. Put the doc into the header. --- src/files.c | 19 +++++++++---------- src/files.h | 3 +++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/files.c b/src/files.c index c0d5d1ca..72652f42 100644 --- a/src/files.c +++ b/src/files.c @@ -201,12 +201,12 @@ map_file_name (char const *filename) size_t oldprefix_len = strlen (p->oldprefix); size_t newprefix_len = strlen (p->newprefix); - char *s = xmalloc (newprefix_len + strlen (filename) - oldprefix_len + 1); + char *res = xmalloc (newprefix_len + strlen (filename) - oldprefix_len + 1); - char *end = stpcpy (s, p->newprefix); + char *end = stpcpy (res, p->newprefix); stpcpy (end, filename + oldprefix_len); - return s; + return res; } static void @@ -217,17 +217,16 @@ prefix_map_free (struct prefix_map *p) free (p); } -/* Adds a new file prefix mapping. If a file path starts with oldprefix, it - will be replaced with newprefix */ void add_prefix_map (char const *oldprefix, char const *newprefix) { if (!prefix_maps) - prefix_maps = gl_list_create_empty (GL_ARRAY_LIST, - /* equals */ NULL, - /* hashcode */ NULL, - (gl_listelement_dispose_fn) prefix_map_free, - true); + prefix_maps + = gl_list_create_empty (GL_ARRAY_LIST, + /* equals */ NULL, + /* hashcode */ NULL, + (gl_listelement_dispose_fn) prefix_map_free, + true); struct prefix_map *p = xmalloc (sizeof (*p)); p->oldprefix = xstrdup (oldprefix); diff --git a/src/files.h b/src/files.h index e8449711..d49847ab 100644 --- a/src/files.h +++ b/src/files.h @@ -95,6 +95,9 @@ void xfclose (FILE *ptr); FILE *xfdopen (int fd, char const *mode); char *map_file_name (char const *filename); + +/* Add a new file prefix mapping. If a file path starts with + oldprefix, it will be replaced with newprefix. */ void add_prefix_map (char const *oldprefix, char const *newprefix); #endif /* !FILES_H_ */