mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
glob_make_pattern: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
This commit is contained in:
parent
9c92dcf366
commit
70857ae1aa
Notes:
git
2020-06-29 11:07:09 +09:00
1 changed files with 6 additions and 4 deletions
10
dir.c
10
dir.c
|
@ -1705,10 +1705,7 @@ glob_make_pattern(const char *p, const char *e, int flags, rb_encoding *enc)
|
|||
|
||||
tmp = GLOB_ALLOC(struct glob_pattern);
|
||||
if (!tmp) {
|
||||
error:
|
||||
*tail = 0;
|
||||
glob_free_pattern(list);
|
||||
return 0;
|
||||
goto error;
|
||||
}
|
||||
tmp->type = dirsep ? MATCH_DIR : MATCH_ALL;
|
||||
tmp->str = 0;
|
||||
|
@ -1716,6 +1713,11 @@ glob_make_pattern(const char *p, const char *e, int flags, rb_encoding *enc)
|
|||
tmp->next = 0;
|
||||
|
||||
return list;
|
||||
|
||||
error:
|
||||
*tail = 0;
|
||||
glob_free_pattern(list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Add table
Reference in a new issue