| Summary: | [libc] [patch] remove loop in globpexp1()@lib/libc/gen/glob.c | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Base System | Reporter: | Cheng-Lung Sung <clsung> | ||||
| Component: | kern | Assignee: | freebsd-bugs (Nobody) <bugs> | ||||
| Status: | Open --- | ||||||
| Severity: | Affects Only Me | Keywords: | patch | ||||
| Priority: | Normal | ||||||
| Version: | 8.2-RELEASE | ||||||
| Hardware: | Any | ||||||
| OS: | Any | ||||||
| Attachments: |
|
||||||
For bugs matching the following criteria: Status: In Progress Changed: (is less than) 2014-06-01 Reset to default assignee and clear in-progress tags. Mail being skipped Keyword:
patch
or patch-ready
– in lieu of summary line prefix:
[patch]
* bulk change for the keyword
* summary lines may be edited manually (not in bulk).
Keyword descriptions and search interface:
<https://bugs.freebsd.org/bugzilla/describekeywords.cgi>
|
One can see that globexp1() is called with GLOB_BRACE. In globexp1(), examine the pattern: only "{}" => call glob0() no LBRACE => call glob0() with LBRACE => call globexp2 to deal with expression inside LBRACE Take a look in glob0(): glob0, return 0 if success, otherwise error (except GLOB_NOMATCH) => return err => return globextend()/GLOB_NOMATCH => return 0 In globexp2() => non matched braces => call glob0(), return 0 => matched brace-pair => parse brace => reach rbrace, call globexp1(), set return value to *rv set *rv = 0, return 0 *which implies always return 0 in globexp2* As a result, the following code block in globexp1 can be reduced from: - while ((ptr = g_strchr(ptr, LBRACE)) != NULL) - if (!globexp2(ptr, pattern, pglob, &rv, limit)) - return rv; to: + if ((ptr = g_strchr(ptr, LBRACE)) != NULL) + return globexp2(ptr, pattern, pglob, limit) Besides, since *rv should indicate the acctual return value, the setting *rv = 0 and return 0 is ambiguous. So the flow in globexp2() should be: In globexp2() => non matched braces => call glob0(), return 0 => matched brace-pair => parse brace => reach rbrace, call globexp1(), set return value to *rv => if success in glob0 return 0 => if failed in glob0 (but not GLOB_NOMATCH) return err