diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2023-01-09 19:04:23 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-01-09 19:04:23 +0000 |
commit | 1cfb14aa972ccf3235ac67f07b7db1175b7c5384 (patch) | |
tree | b746eda548993b9e0987d7c9c0c543ddddc5758f /src/ex_cmds2.c | |
parent | 765d82a657c5e42d5d7c88ae410e53f398c34c43 (diff) |
patch 9.0.1166: code is indented more than necessaryv9.0.1166
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes #11792)
Diffstat (limited to 'src/ex_cmds2.c')
-rw-r--r-- | src/ex_cmds2.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index c52c227de9..567b839cdb 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -828,40 +828,40 @@ requires_py_version(char_u *filename) lines = 5; file = mch_fopen((char *)filename, "r"); - if (file != NULL) + if (file == NULL) + return 0; + + for (i = 0; i < lines; i++) { - for (i = 0; i < lines; i++) + if (vim_fgets(IObuff, IOSIZE, file)) + break; + if (i == 0 && IObuff[0] == '#' && IObuff[1] == '!') { - if (vim_fgets(IObuff, IOSIZE, file)) - break; - if (i == 0 && IObuff[0] == '#' && IObuff[1] == '!') - { - // Check shebang. - if (strstr((char *)IObuff + 2, "python2") != NULL) - { - requires_py_version = 2; - break; - } - if (strstr((char *)IObuff + 2, "python3") != NULL) - { - requires_py_version = 3; - break; - } - } - IObuff[21] = '\0'; - if (STRCMP("# requires python 2.x", IObuff) == 0) + // Check shebang. + if (strstr((char *)IObuff + 2, "python2") != NULL) { requires_py_version = 2; break; } - if (STRCMP("# requires python 3.x", IObuff) == 0) + if (strstr((char *)IObuff + 2, "python3") != NULL) { requires_py_version = 3; break; } } - fclose(file); + IObuff[21] = '\0'; + if (STRCMP("# requires python 2.x", IObuff) == 0) + { + requires_py_version = 2; + break; + } + if (STRCMP("# requires python 3.x", IObuff) == 0) + { + requires_py_version = 3; + break; + } } + fclose(file); return requires_py_version; } |