glob.patch 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. --- a/glob.c (index)
  2. +++ b/glob.c (working tree)
  3. @@ -82,17 +82,19 @@ __FBSDID("$FreeBSD$");
  4. #include <ctype.h>
  5. #include <dirent.h>
  6. #include <errno.h>
  7. -#include <glob.h>
  8. +#include "glob.h"
  9. #include <limits.h>
  10. #include <pwd.h>
  11. #include <stdint.h>
  12. #include <stdio.h>
  13. -#include <stdlib.h>
  14. +#include "stdlib.h"
  15. #include <string.h>
  16. -#include <unistd.h>
  17. +#include "unistd.h"
  18. #include <wchar.h>
  19. +#ifdef USE_LOCALE_COLLATE
  20. #include "collate.h"
  21. +#endif
  22. /*
  23. * glob(3) expansion limits. Stop the expansion if any of these limits
  24. @@ -911,8 +913,10 @@ match(Char *name, Char *pat, Char *patend)
  25. {
  26. int ok, negate_range;
  27. Char c, k, *nextp, *nextn;
  28. +#ifdef USE_LOCALE_COLLATE
  29. struct xlocale_collate *table =
  30. (struct xlocale_collate*)__get_locale()->components[XLC_COLLATE];
  31. +#endif
  32. nextn = NULL;
  33. nextp = NULL;
  34. @@ -942,6 +946,7 @@ match(Char *name, Char *pat, Char *patend)
  35. ++pat;
  36. while (((c = *pat++) & M_MASK) != M_END)
  37. if ((*pat & M_MASK) == M_RNG) {
  38. +#ifdef USE_LOCALE_COLLATE
  39. if (table->__collate_load_error ?
  40. CHAR(c) <= CHAR(k) &&
  41. CHAR(k) <= CHAR(pat[1]) :
  42. @@ -949,6 +954,9 @@ match(Char *name, Char *pat, Char *patend)
  43. CHAR(k)) <= 0 &&
  44. __wcollate_range_cmp(CHAR(k),
  45. CHAR(pat[1])) <= 0)
  46. +#else
  47. + if (c <= k && k <= pat[1])
  48. +#endif
  49. ok = 1;
  50. pat += 2;
  51. } else if (c == k)
  52. --- a/stdlib.h (index)
  53. +++ b/stdlib.h (working tree)
  54. @@ -0,0 +1,3 @@
  55. +#include <stdlib.h>
  56. +
  57. +void* reallocarray(void*, size_t, size_t);
  58. --- a/unistd.h (index)
  59. +++ b/unistd.h (working tree)
  60. @@ -0,0 +1,3 @@
  61. +#include <unistd.h>
  62. +
  63. +#define issetugid() 0
  64. --- a/glob.h (index)
  65. +++ b/glob.h (working tree)
  66. @@ -39,12 +39,8 @@
  67. #define _GLOB_H_
  68. #include <sys/cdefs.h>
  69. -#include <sys/_types.h>
  70. +#include <sys/types.h>
  71. -#ifndef _SIZE_T_DECLARED
  72. -typedef __size_t size_t;
  73. -#define _SIZE_T_DECLARED
  74. -#endif
  75. struct stat;
  76. typedef struct {
  77. @@ -68,7 +64,7 @@ typedef struct {
  78. int (*gl_stat)(const char *, struct stat *);
  79. } glob_t;
  80. -#if __POSIX_VISIBLE >= 199209
  81. +// #if __POSIX_VISIBLE >= 199209
  82. /* Believed to have been introduced in 1003.2-1992 */
  83. #define GLOB_APPEND 0x0001 /* Append to output from previous call. */
  84. #define GLOB_DOOFFS 0x0002 /* Use gl_offs. */
  85. @@ -83,9 +79,9 @@ typedef struct {
  86. #define GLOB_ABORTED (-2) /* Unignored error. */
  87. #define GLOB_NOMATCH (-3) /* No match and GLOB_NOCHECK was not set. */
  88. #define GLOB_NOSYS (-4) /* Obsolete: source comptability only. */
  89. -#endif /* __POSIX_VISIBLE >= 199209 */
  90. +// #endif /* __POSIX_VISIBLE >= 199209 */
  91. -#if __BSD_VISIBLE
  92. +// #if __BSD_VISIBLE
  93. #define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */
  94. #define GLOB_BRACE 0x0080 /* Expand braces ala csh. */
  95. #define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */
  96. @@ -97,7 +93,7 @@ typedef struct {
  97. /* source compatibility, these are the old names */
  98. #define GLOB_MAXPATH GLOB_LIMIT
  99. #define GLOB_ABEND GLOB_ABORTED
  100. -#endif /* __BSD_VISIBLE */
  101. +// #endif /* __BSD_VISIBLE */
  102. __BEGIN_DECLS
  103. int glob(const char * __restrict, int,