Bugzilla – Attachment 2093 Details for
Bug 1935
ls -l with wildcards produces incorrect output
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
glob.diff
glob.diff (text/plain), 2.15 KB, created by
Damien Miller
on 2011-09-21 12:50:10 AEST
(
hide
)
Description:
glob.diff
Filename:
MIME Type:
Creator:
Damien Miller
Created:
2011-09-21 12:50:10 AEST
Size:
2.15 KB
patch
obsolete
>Index: glob.c >=================================================================== >RCS file: /cvs/src/lib/libc/gen/glob.c,v >retrieving revision 1.36 >diff -u -p -r1.36 glob.c >--- glob.c 12 May 2011 07:15:10 -0000 1.36 >+++ glob.c 21 Sep 2011 02:46:59 -0000 >@@ -131,7 +131,13 @@ struct glob_lim { > size_t glim_readdir; > }; > >+struct glob_path_stat { >+ char *gps_path; >+ struct stat *gps_stat; >+}; >+ > static int compare(const void *, const void *); >+static int compare_gps(const void *, const void *); > static int g_Ctoc(const Char *, char *, u_int); > static int g_lstat(Char *, struct stat *, glob_t *); > static DIR *g_opendir(Char *, glob_t *); >@@ -538,9 +544,32 @@ glob0(const Char *pattern, glob_t *pglob > else > return(GLOB_NOMATCH); > } >- if (!(pglob->gl_flags & GLOB_NOSORT)) >- qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc, >- pglob->gl_pathc - oldpathc, sizeof(char *), compare); >+ if (!(pglob->gl_flags & GLOB_NOSORT)) { >+ if ((pglob->gl_flags & GLOB_KEEPSTAT)) { >+ /* Keep the paths and stat info synced during sort */ >+ struct glob_path_stat *path_stat; >+ int i; >+ int n = pglob->gl_pathc - oldpathc; >+ int o = pglob->gl_offs + oldpathc; >+ >+ if ((path_stat = calloc(n, sizeof(*path_stat))) == NULL) >+ return 0; /* return unsorted on alloc failure */ >+ for (i = 0; i < n; i++) { >+ path_stat[i].gps_path = pglob->gl_pathv[o + i]; >+ path_stat[i].gps_stat = pglob->gl_statv[o + i]; >+ } >+ qsort(path_stat, n, sizeof(*path_stat), compare_gps); >+ for (i = 0; i < n; i++) { >+ pglob->gl_pathv[o + i] = path_stat[i].gps_path; >+ pglob->gl_statv[o + i] = path_stat[i].gps_stat; >+ } >+ free(path_stat); >+ } else { >+ qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc, >+ pglob->gl_pathc - oldpathc, sizeof(char *), >+ compare); >+ } >+ } > return(0); > } > >@@ -548,6 +577,15 @@ static int > compare(const void *p, const void *q) > { > return(strcmp(*(char **)p, *(char **)q)); >+} >+ >+static int >+compare_gps(const void *_p, const void *_q) >+{ >+ const struct glob_path_stat *p = (const struct glob_path_stat *)_p; >+ const struct glob_path_stat *q = (const struct glob_path_stat *)_q; >+ >+ return(strcmp(p->gps_path, q->gps_path)); > } > > static int
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1935
: 2093 |
2094