]> granicus.if.org Git - graphviz/commitdiff
gvconfig.c: remove shadowing of 'path'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 3 Nov 2021 04:28:44 +0000 (21:28 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 9 Nov 2021 15:10:39 +0000 (07:10 -0800)
lib/gvc/gvconfig.c
lib/gvc/gvconfig.h

index de28d600f0774a9bfb3da876e8d5f69b13990959..bbd5673bcbb355577972803fee142ddecbab51a7 100644 (file)
@@ -92,10 +92,11 @@ extern Dt_t * textfont_dict_open(GVC_t *gvc);
 
  */
 
-static gvplugin_package_t * gvplugin_package_record(GVC_t * gvc, const char *path, const char *name)
-{
+static gvplugin_package_t * gvplugin_package_record(GVC_t * gvc,
+                                                    const char *package_path,
+                                                    const char *name) {
     gvplugin_package_t *package = gmalloc(sizeof(gvplugin_package_t));
-    package->path = (path) ? strdup(path) : NULL;
+    package->path = package_path ? strdup(package_path) : NULL;
     package->name = strdup(name);
     package->next = gvc->packages;
     gvc->packages = package;
@@ -170,7 +171,7 @@ static char *token(int *nest, char **tokens)
 
 static int gvconfig_plugin_install_from_config(GVC_t * gvc, char *s)
 {
-    char *path, *name, *api;
+    char *package_path, *name, *api;
     const char *type;
     api_t gv_api;
     int quality, rc;
@@ -179,12 +180,12 @@ static int gvconfig_plugin_install_from_config(GVC_t * gvc, char *s)
 
     separator(&nest, &s);
     while (*s) {
-       path = token(&nest, &s);
+       package_path = token(&nest, &s);
        if (nest == 0)
            name = token(&nest, &s);
         else
            name = "x";
-        package = gvplugin_package_record(gvc, path, name);
+        package = gvplugin_package_record(gvc, package_path, name);
        do {
            api = token(&nest, &s);
            gv_api = gvplugin_api(api);
@@ -198,7 +199,7 @@ static int gvconfig_plugin_install_from_config(GVC_t * gvc, char *s)
                    rc = gvplugin_install (gvc, gv_api,
                                    type, quality, package, NULL);
                    if (!rc) {
-                       agerr(AGERR, "config error: %s %s %s\n", path, api, type);
+                       agerr(AGERR, "config error: %s %s %s\n", package_path, api, type);
                        return 0;
                    }
                }
@@ -209,14 +210,14 @@ static int gvconfig_plugin_install_from_config(GVC_t * gvc, char *s)
 }
 #endif
 
-void gvconfig_plugin_install_from_library(GVC_t * gvc, char *path, gvplugin_library_t *library)
-{
+void gvconfig_plugin_install_from_library(GVC_t * gvc, char *package_path,
+                                          gvplugin_library_t *library) {
     gvplugin_api_t *apis;
     gvplugin_installed_t *types;
     gvplugin_package_t *package;
     int i;
 
-    package = gvplugin_package_record(gvc, path, library->packagename);
+    package = gvplugin_package_record(gvc, package_path, library->packagename);
     for (apis = library->apis; (types = apis->types); apis++) {
        for (i = 0; types[i].type; i++) {
            gvplugin_install(gvc, apis->api, types[i].type,
@@ -239,13 +240,14 @@ static void gvconfig_plugin_install_builtins(GVC_t * gvc)
 }
 
 #ifdef ENABLE_LTDL
-static void gvconfig_write_library_config(GVC_t *gvc, char *path, gvplugin_library_t *library, FILE *f)
-{
+static void gvconfig_write_library_config(GVC_t *gvc, char *lib_path,
+                                          gvplugin_library_t *library,
+                                          FILE *f) {
     gvplugin_api_t *apis;
     gvplugin_installed_t *types;
     int i;
 
-    fprintf(f, "%s %s {\n", path, library->packagename);
+    fprintf(f, "%s %s {\n", lib_path, library->packagename);
     for (apis = library->apis; (types = apis->types); apis++) {
         fprintf(f, "\t%s {\n", gvplugin_api_name(apis->api));
        for (i = 0; types[i].type; i++) {
@@ -266,14 +268,14 @@ static void gvconfig_write_library_config(GVC_t *gvc, char *path, gvplugin_libra
 #ifdef HAVE_DL_ITERATE_PHDR
 static int line_callback(struct dl_phdr_info *info, size_t size, void *line)
 {
-   const char *path = info->dlpi_name;
-   char *tmp = strstr(path, "/libgvc.");
+   const char *p = info->dlpi_name;
+   char *tmp = strstr(p, "/libgvc.");
    (void) size;
    if (tmp) {
         *tmp = 0;
         /* Check for real /lib dir. Don't accept pre-install /.libs */
-        if (strcmp(strrchr(path,'/'), DOTLIBS) != 0) {
-            memmove(line, path, strlen(path) + 1);  /* use line buffer for result */
+        if (strcmp(strrchr(p,'/'), DOTLIBS) != 0) {
+            memmove(line, p, strlen(p) + 1); // use line buffer for result
             strcat(line, "/graphviz");  /* plugins are in "graphviz" subdirectory */
             return 1;
         }
@@ -317,27 +319,26 @@ char * gvconfig_libdir(GVC_t * gvc)
 #ifdef __APPLE__
            uint32_t i, c = _dyld_image_count();
            size_t len, ind;
-           const char* path;
            for (i = 0; i < c; ++i) {
-               path = _dyld_get_image_name(i);
-               const char* tmp = strstr(path, "/libgvc.");
+               const char *p = _dyld_get_image_name(i);
+               const char* tmp = strstr(p, "/libgvc.");
                if (tmp) {
-                   if (tmp > path) {
+                   if (tmp > p) {
                        /* Check for real /lib dir. Don't accept pre-install /.libs */
                        const char *s = tmp - 1;
                        /* back up to previous slash (or head of string) */
-                       while ((*s != '/') && (s > path)) s--;
+                       while (*s != '/' && s > p) s--;
                        if (strncmp (s, DOTLIBS, STRLEN(DOTLIBS)) == 0)
                            continue;
                    }
 
-                   ind = tmp - path;  /* byte offset */
+                   ind = tmp - p; // byte offset
                    len = ind + sizeof("/graphviz");
                    if (len < BSZ)
                        libdir = line;
                    else
                        libdir = gmalloc(len);
-                   bcopy (path, libdir, ind);
+                   bcopy(p, libdir, ind);
                    /* plugins are in "graphviz" subdirectory */
                    strcpy(libdir+ind, "/graphviz");  
                    break;
@@ -348,23 +349,22 @@ char * gvconfig_libdir(GVC_t * gvc)
            libdir = line;
 #else
            FILE* f = fopen ("/proc/self/maps", "r");
-           char* path;
            if (f) {
                while (!feof (f)) {
                    if (!fgets (line, sizeof (line), f))
                        continue;
                    if (!strstr (line, " r-xp "))
                        continue;
-                   path = strchr (line, '/');
-                   if (!path)
+                   char *p = strchr(line, '/');
+                   if (!p)
                        continue;
-                   char* tmp = strstr (path, "/libgvc.");
+                   char* tmp = strstr(p, "/libgvc.");
                    if (tmp) {
                        *tmp = 0;
                        /* Check for real /lib dir. Don't accept pre-install /.libs */
-                       if (strcmp(strrchr(path,'/'), "/.libs") == 0)
+                       if (strcmp(strrchr(p'/'), "/.libs") == 0)
                            continue;
-                       memmove(line, path, strlen(path) + 1);  /* use line buffer for result */
+                       memmove(line, p, strlen(p) + 1); // use line buffer for result
                        strcat(line, "/graphviz");  /* plugins are in "graphviz" subdirectory */
                        libdir = line;
                        break;
@@ -473,7 +473,7 @@ static void config_rescan(GVC_t *gvc, char *config_path)
 {
     FILE *f = NULL;
     glob_t globbuf;
-    char *config_glob, *path, *libdir;
+    char *config_glob, *libdir;
     int rc;
     gvplugin_library_t *library;
 #if defined(DARWIN_DYLIB)
@@ -530,11 +530,11 @@ static void config_rescan(GVC_t *gvc, char *config_path)
            if (is_plugin(globbuf.gl_pathv[i])) {
                library = gvplugin_library_load(gvc, globbuf.gl_pathv[i]);
                if (library) {
-                   path = strrchr(globbuf.gl_pathv[i],DIRSEP[0]);
-                   if (path)
-                       path++;
-                   if (f && path)
-                       gvconfig_write_library_config(gvc, path, library, f);
+                   char *p = strrchr(globbuf.gl_pathv[i], DIRSEP[0]);
+                   if (p)
+                       p++;
+                   if (f && p)
+                       gvconfig_write_library_config(gvc, p, library, f);
                }
            }
        }
index 9db1e802df243ffd162e6248aee77e025f0df4a3..9f0f1ab437446deac8951744f7c6ebbcee9b44d6 100644 (file)
@@ -18,7 +18,9 @@
 extern "C" {
 #endif
 
-extern void gvconfig_plugin_install_from_library(GVC_t * gvc, char *path, gvplugin_library_t *library);
+extern void gvconfig_plugin_install_from_library(GVC_t * gvc,
+                                                 char *package_path,
+                                                 gvplugin_library_t *library);
 
 #ifdef __cplusplus
 }