patch 9.0.1246: code is indented more than necessary
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes #11887)
diff --git a/src/uninstall.c b/src/uninstall.c
index c84189f..78b2b7d 100644
--- a/src/uninstall.c
+++ b/src/uninstall.c
@@ -205,18 +205,18 @@
int found = FALSE;
fd = fopen(path, "r");
- if (fd != NULL)
+ if (fd == NULL)
+ return FALSE;
+
+ while (fgets(line, sizeof(line), fd) != NULL)
{
- while (fgets(line, sizeof(line), fd) != NULL)
+ if (strncmp(line, VIMBAT_UNINSTKEY, key_len) == 0)
{
- if (strncmp(line, VIMBAT_UNINSTKEY, key_len) == 0)
- {
- found = TRUE;
- break;
- }
+ found = TRUE;
+ break;
}
- fclose(fd);
}
+ fclose(fd);
return found;
}
@@ -261,12 +261,12 @@
sprintf(buf, "%s\\%s", path, filename);
fd = fopen(buf, "r");
- if (fd != NULL)
- {
- fclose(fd);
- printf("removing %s\n", buf);
- remove(buf);
- }
+ if (fd == NULL)
+ return;
+
+ fclose(fd);
+ printf("removing %s\n", buf);
+ remove(buf);
}
static void
@@ -287,21 +287,21 @@
int i;
struct stat st;
- if (get_shell_folder_path(path, VIM_STARTMENU))
+ if (get_shell_folder_path(path, VIM_STARTMENU) == FAIL)
+ return;
+
+ for (i = 1; i < TARGET_COUNT; ++i)
+ remove_if_exists(path, targets[i].lnkname);
+ remove_if_exists(path, "uninstall.lnk");
+ remove_if_exists(path, "Help.lnk");
+ // Win95 uses .pif, WinNT uses .lnk
+ remove_if_exists(path, "Vim tutor.pif");
+ remove_if_exists(path, "Vim tutor.lnk");
+ remove_if_exists(path, "Vim online.url");
+ if (stat(path, &st) == 0)
{
- for (i = 1; i < TARGET_COUNT; ++i)
- remove_if_exists(path, targets[i].lnkname);
- remove_if_exists(path, "uninstall.lnk");
- remove_if_exists(path, "Help.lnk");
- // Win95 uses .pif, WinNT uses .lnk
- remove_if_exists(path, "Vim tutor.pif");
- remove_if_exists(path, "Vim tutor.lnk");
- remove_if_exists(path, "Vim online.url");
- if (stat(path, &st) == 0)
- {
- printf("removing %s\n", path);
- rmdir(path);
- }
+ printf("removing %s\n", path);
+ rmdir(path);
}
}