New patches from Fedora.
[fedora-mingw.git] / popt / popt-gnulib.patch
1 diff -urN popt-for-windows/lib/alloca.c popt-for-windows-gnulib/lib/alloca.c
2 --- popt-for-windows/lib/alloca.c       1970-01-01 01:00:00.000000000 +0100
3 +++ popt-for-windows-gnulib/lib/alloca.c        2008-10-25 15:17:05.000000000 +0100
4 @@ -0,0 +1,489 @@
5 +/* alloca.c -- allocate automatically reclaimed memory
6 +   (Mostly) portable public-domain implementation -- D A Gwyn
7 +
8 +   This implementation of the PWB library alloca function,
9 +   which is used to allocate space off the run-time stack so
10 +   that it is automatically reclaimed upon procedure exit,
11 +   was inspired by discussions with J. Q. Johnson of Cornell.
12 +   J.Otto Tennant <jot@cray.com> contributed the Cray support.
13 +
14 +   There are some preprocessor constants that can
15 +   be defined when compiling for your specific system, for
16 +   improved efficiency; however, the defaults should be okay.
17 +
18 +   The general concept of this implementation is to keep
19 +   track of all alloca-allocated blocks, and reclaim any
20 +   that are found to be deeper in the stack than the current
21 +   invocation.  This heuristic does not reclaim storage as
22 +   soon as it becomes invalid, but it will do so eventually.
23 +
24 +   As a special case, alloca(0) reclaims storage without
25 +   allocating any.  It is a good idea to use alloca(0) in
26 +   your main control loop, etc. to force garbage collection.  */
27 +
28 +#include <config.h>
29 +
30 +#include <alloca.h>
31 +
32 +#include <string.h>
33 +#include <stdlib.h>
34 +
35 +#ifdef emacs
36 +# include "lisp.h"
37 +# include "blockinput.h"
38 +# ifdef EMACS_FREE
39 +#  undef free
40 +#  define free EMACS_FREE
41 +# endif
42 +#else
43 +# define memory_full() abort ()
44 +#endif
45 +
46 +/* If compiling with GCC 2, this file's not needed.  */
47 +#if !defined (__GNUC__) || __GNUC__ < 2
48 +
49 +/* If someone has defined alloca as a macro,
50 +   there must be some other way alloca is supposed to work.  */
51 +# ifndef alloca
52 +
53 +#  ifdef emacs
54 +#   ifdef static
55 +/* actually, only want this if static is defined as ""
56 +   -- this is for usg, in which emacs must undefine static
57 +   in order to make unexec workable
58 +   */
59 +#    ifndef STACK_DIRECTION
60 +you
61 +lose
62 +-- must know STACK_DIRECTION at compile-time
63 +/* Using #error here is not wise since this file should work for
64 +   old and obscure compilers.  */
65 +#    endif /* STACK_DIRECTION undefined */
66 +#   endif /* static */
67 +#  endif /* emacs */
68 +
69 +/* If your stack is a linked list of frames, you have to
70 +   provide an "address metric" ADDRESS_FUNCTION macro.  */
71 +
72 +#  if defined (CRAY) && defined (CRAY_STACKSEG_END)
73 +long i00afunc ();
74 +#   define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg))
75 +#  else
76 +#   define ADDRESS_FUNCTION(arg) &(arg)
77 +#  endif
78 +
79 +/* Define STACK_DIRECTION if you know the direction of stack
80 +   growth for your system; otherwise it will be automatically
81 +   deduced at run-time.
82 +
83 +   STACK_DIRECTION > 0 => grows toward higher addresses
84 +   STACK_DIRECTION < 0 => grows toward lower addresses
85 +   STACK_DIRECTION = 0 => direction of growth unknown  */
86 +
87 +#  ifndef STACK_DIRECTION
88 +#   define STACK_DIRECTION     0       /* Direction unknown.  */
89 +#  endif
90 +
91 +#  if STACK_DIRECTION != 0
92 +
93 +#   define STACK_DIR   STACK_DIRECTION /* Known at compile-time.  */
94 +
95 +#  else /* STACK_DIRECTION == 0; need run-time code.  */
96 +
97 +static int stack_dir;          /* 1 or -1 once known.  */
98 +#   define STACK_DIR   stack_dir
99 +
100 +static void
101 +find_stack_direction (void)
102 +{
103 +  static char *addr = NULL;    /* Address of first `dummy', once known.  */
104 +  auto char dummy;             /* To get stack address.  */
105 +
106 +  if (addr == NULL)
107 +    {                          /* Initial entry.  */
108 +      addr = ADDRESS_FUNCTION (dummy);
109 +
110 +      find_stack_direction (); /* Recurse once.  */
111 +    }
112 +  else
113 +    {
114 +      /* Second entry.  */
115 +      if (ADDRESS_FUNCTION (dummy) > addr)
116 +       stack_dir = 1;          /* Stack grew upward.  */
117 +      else
118 +       stack_dir = -1;         /* Stack grew downward.  */
119 +    }
120 +}
121 +
122 +#  endif /* STACK_DIRECTION == 0 */
123 +
124 +/* An "alloca header" is used to:
125 +   (a) chain together all alloca'ed blocks;
126 +   (b) keep track of stack depth.
127 +
128 +   It is very important that sizeof(header) agree with malloc
129 +   alignment chunk size.  The following default should work okay.  */
130 +
131 +#  ifndef      ALIGN_SIZE
132 +#   define ALIGN_SIZE  sizeof(double)
133 +#  endif
134 +
135 +typedef union hdr
136 +{
137 +  char align[ALIGN_SIZE];      /* To force sizeof(header).  */
138 +  struct
139 +    {
140 +      union hdr *next;         /* For chaining headers.  */
141 +      char *deep;              /* For stack depth measure.  */
142 +    } h;
143 +} header;
144 +
145 +static header *last_alloca_header = NULL;      /* -> last alloca header.  */
146 +
147 +/* Return a pointer to at least SIZE bytes of storage,
148 +   which will be automatically reclaimed upon exit from
149 +   the procedure that called alloca.  Originally, this space
150 +   was supposed to be taken from the current stack frame of the
151 +   caller, but that method cannot be made to work for some
152 +   implementations of C, for example under Gould's UTX/32.  */
153 +
154 +void *
155 +alloca (size_t size)
156 +{
157 +  auto char probe;             /* Probes stack depth: */
158 +  register char *depth = ADDRESS_FUNCTION (probe);
159 +
160 +#  if STACK_DIRECTION == 0
161 +  if (STACK_DIR == 0)          /* Unknown growth direction.  */
162 +    find_stack_direction ();
163 +#  endif
164 +
165 +  /* Reclaim garbage, defined as all alloca'd storage that
166 +     was allocated from deeper in the stack than currently.  */
167 +
168 +  {
169 +    register header *hp;       /* Traverses linked list.  */
170 +
171 +#  ifdef emacs
172 +    BLOCK_INPUT;
173 +#  endif
174 +
175 +    for (hp = last_alloca_header; hp != NULL;)
176 +      if ((STACK_DIR > 0 && hp->h.deep > depth)
177 +         || (STACK_DIR < 0 && hp->h.deep < depth))
178 +       {
179 +         register header *np = hp->h.next;
180 +
181 +         free (hp);            /* Collect garbage.  */
182 +
183 +         hp = np;              /* -> next header.  */
184 +       }
185 +      else
186 +       break;                  /* Rest are not deeper.  */
187 +
188 +    last_alloca_header = hp;   /* -> last valid storage.  */
189 +
190 +#  ifdef emacs
191 +    UNBLOCK_INPUT;
192 +#  endif
193 +  }
194 +
195 +  if (size == 0)
196 +    return NULL;               /* No allocation required.  */
197 +
198 +  /* Allocate combined header + user data storage.  */
199 +
200 +  {
201 +    /* Address of header.  */
202 +    register header *new;
203 +
204 +    size_t combined_size = sizeof (header) + size;
205 +    if (combined_size < sizeof (header))
206 +      memory_full ();
207 +
208 +    new = malloc (combined_size);
209 +
210 +    if (! new)
211 +      memory_full ();
212 +
213 +    new->h.next = last_alloca_header;
214 +    new->h.deep = depth;
215 +
216 +    last_alloca_header = new;
217 +
218 +    /* User storage begins just after header.  */
219 +
220 +    return (void *) (new + 1);
221 +  }
222 +}
223 +
224 +#  if defined (CRAY) && defined (CRAY_STACKSEG_END)
225 +
226 +#   ifdef DEBUG_I00AFUNC
227 +#    include <stdio.h>
228 +#   endif
229 +
230 +#   ifndef CRAY_STACK
231 +#    define CRAY_STACK
232 +#    ifndef CRAY2
233 +/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */
234 +struct stack_control_header
235 +  {
236 +    long shgrow:32;            /* Number of times stack has grown.  */
237 +    long shaseg:32;            /* Size of increments to stack.  */
238 +    long shhwm:32;             /* High water mark of stack.  */
239 +    long shsize:32;            /* Current size of stack (all segments).  */
240 +  };
241 +
242 +/* The stack segment linkage control information occurs at
243 +   the high-address end of a stack segment.  (The stack
244 +   grows from low addresses to high addresses.)  The initial
245 +   part of the stack segment linkage control information is
246 +   0200 (octal) words.  This provides for register storage
247 +   for the routine which overflows the stack.  */
248 +
249 +struct stack_segment_linkage
250 +  {
251 +    long ss[0200];             /* 0200 overflow words.  */
252 +    long sssize:32;            /* Number of words in this segment.  */
253 +    long ssbase:32;            /* Offset to stack base.  */
254 +    long:32;
255 +    long sspseg:32;            /* Offset to linkage control of previous
256 +                                  segment of stack.  */
257 +    long:32;
258 +    long sstcpt:32;            /* Pointer to task common address block.  */
259 +    long sscsnm;               /* Private control structure number for
260 +                                  microtasking.  */
261 +    long ssusr1;               /* Reserved for user.  */
262 +    long ssusr2;               /* Reserved for user.  */
263 +    long sstpid;               /* Process ID for pid based multi-tasking.  */
264 +    long ssgvup;               /* Pointer to multitasking thread giveup.  */
265 +    long sscray[7];            /* Reserved for Cray Research.  */
266 +    long ssa0;
267 +    long ssa1;
268 +    long ssa2;
269 +    long ssa3;
270 +    long ssa4;
271 +    long ssa5;
272 +    long ssa6;
273 +    long ssa7;
274 +    long sss0;
275 +    long sss1;
276 +    long sss2;
277 +    long sss3;
278 +    long sss4;
279 +    long sss5;
280 +    long sss6;
281 +    long sss7;
282 +  };
283 +
284 +#    else /* CRAY2 */
285 +/* The following structure defines the vector of words
286 +   returned by the STKSTAT library routine.  */
287 +struct stk_stat
288 +  {
289 +    long now;                  /* Current total stack size.  */
290 +    long maxc;                 /* Amount of contiguous space which would
291 +                                  be required to satisfy the maximum
292 +                                  stack demand to date.  */
293 +    long high_water;           /* Stack high-water mark.  */
294 +    long overflows;            /* Number of stack overflow ($STKOFEN) calls.  */
295 +    long hits;                 /* Number of internal buffer hits.  */
296 +    long extends;              /* Number of block extensions.  */
297 +    long stko_mallocs;         /* Block allocations by $STKOFEN.  */
298 +    long underflows;           /* Number of stack underflow calls ($STKRETN).  */
299 +    long stko_free;            /* Number of deallocations by $STKRETN.  */
300 +    long stkm_free;            /* Number of deallocations by $STKMRET.  */
301 +    long segments;             /* Current number of stack segments.  */
302 +    long maxs;                 /* Maximum number of stack segments so far.  */
303 +    long pad_size;             /* Stack pad size.  */
304 +    long current_address;      /* Current stack segment address.  */
305 +    long current_size;         /* Current stack segment size.  This
306 +                                  number is actually corrupted by STKSTAT to
307 +                                  include the fifteen word trailer area.  */
308 +    long initial_address;      /* Address of initial segment.  */
309 +    long initial_size;         /* Size of initial segment.  */
310 +  };
311 +
312 +/* The following structure describes the data structure which trails
313 +   any stack segment.  I think that the description in 'asdef' is
314 +   out of date.  I only describe the parts that I am sure about.  */
315 +
316 +struct stk_trailer
317 +  {
318 +    long this_address;         /* Address of this block.  */
319 +    long this_size;            /* Size of this block (does not include
320 +                                  this trailer).  */
321 +    long unknown2;
322 +    long unknown3;
323 +    long link;                 /* Address of trailer block of previous
324 +                                  segment.  */
325 +    long unknown5;
326 +    long unknown6;
327 +    long unknown7;
328 +    long unknown8;
329 +    long unknown9;
330 +    long unknown10;
331 +    long unknown11;
332 +    long unknown12;
333 +    long unknown13;
334 +    long unknown14;
335 +  };
336 +
337 +#    endif /* CRAY2 */
338 +#   endif /* not CRAY_STACK */
339 +
340 +#   ifdef CRAY2
341 +/* Determine a "stack measure" for an arbitrary ADDRESS.
342 +   I doubt that "lint" will like this much.  */
343 +
344 +static long
345 +i00afunc (long *address)
346 +{
347 +  struct stk_stat status;
348 +  struct stk_trailer *trailer;
349 +  long *block, size;
350 +  long result = 0;
351 +
352 +  /* We want to iterate through all of the segments.  The first
353 +     step is to get the stack status structure.  We could do this
354 +     more quickly and more directly, perhaps, by referencing the
355 +     $LM00 common block, but I know that this works.  */
356 +
357 +  STKSTAT (&status);
358 +
359 +  /* Set up the iteration.  */
360 +
361 +  trailer = (struct stk_trailer *) (status.current_address
362 +                                   + status.current_size
363 +                                   - 15);
364 +
365 +  /* There must be at least one stack segment.  Therefore it is
366 +     a fatal error if "trailer" is null.  */
367 +
368 +  if (trailer == 0)
369 +    abort ();
370 +
371 +  /* Discard segments that do not contain our argument address.  */
372 +
373 +  while (trailer != 0)
374 +    {
375 +      block = (long *) trailer->this_address;
376 +      size = trailer->this_size;
377 +      if (block == 0 || size == 0)
378 +       abort ();
379 +      trailer = (struct stk_trailer *) trailer->link;
380 +      if ((block <= address) && (address < (block + size)))
381 +       break;
382 +    }
383 +
384 +  /* Set the result to the offset in this segment and add the sizes
385 +     of all predecessor segments.  */
386 +
387 +  result = address - block;
388 +
389 +  if (trailer == 0)
390 +    {
391 +      return result;
392 +    }
393 +
394 +  do
395 +    {
396 +      if (trailer->this_size <= 0)
397 +       abort ();
398 +      result += trailer->this_size;
399 +      trailer = (struct stk_trailer *) trailer->link;
400 +    }
401 +  while (trailer != 0);
402 +
403 +  /* We are done.  Note that if you present a bogus address (one
404 +     not in any segment), you will get a different number back, formed
405 +     from subtracting the address of the first block.  This is probably
406 +     not what you want.  */
407 +
408 +  return (result);
409 +}
410 +
411 +#   else /* not CRAY2 */
412 +/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP.
413 +   Determine the number of the cell within the stack,
414 +   given the address of the cell.  The purpose of this
415 +   routine is to linearize, in some sense, stack addresses
416 +   for alloca.  */
417 +
418 +static long
419 +i00afunc (long address)
420 +{
421 +  long stkl = 0;
422 +
423 +  long size, pseg, this_segment, stack;
424 +  long result = 0;
425 +
426 +  struct stack_segment_linkage *ssptr;
427 +
428 +  /* Register B67 contains the address of the end of the
429 +     current stack segment.  If you (as a subprogram) store
430 +     your registers on the stack and find that you are past
431 +     the contents of B67, you have overflowed the segment.
432 +
433 +     B67 also points to the stack segment linkage control
434 +     area, which is what we are really interested in.  */
435 +
436 +  stkl = CRAY_STACKSEG_END ();
437 +  ssptr = (struct stack_segment_linkage *) stkl;
438 +
439 +  /* If one subtracts 'size' from the end of the segment,
440 +     one has the address of the first word of the segment.
441 +
442 +     If this is not the first segment, 'pseg' will be
443 +     nonzero.  */
444 +
445 +  pseg = ssptr->sspseg;
446 +  size = ssptr->sssize;
447 +
448 +  this_segment = stkl - size;
449 +
450 +  /* It is possible that calling this routine itself caused
451 +     a stack overflow.  Discard stack segments which do not
452 +     contain the target address.  */
453 +
454 +  while (!(this_segment <= address && address <= stkl))
455 +    {
456 +#    ifdef DEBUG_I00AFUNC
457 +      fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl);
458 +#    endif
459 +      if (pseg == 0)
460 +       break;
461 +      stkl = stkl - pseg;
462 +      ssptr = (struct stack_segment_linkage *) stkl;
463 +      size = ssptr->sssize;
464 +      pseg = ssptr->sspseg;
465 +      this_segment = stkl - size;
466 +    }
467 +
468 +  result = address - this_segment;
469 +
470 +  /* If you subtract pseg from the current end of the stack,
471 +     you get the address of the previous stack segment's end.
472 +     This seems a little convoluted to me, but I'll bet you save
473 +     a cycle somewhere.  */
474 +
475 +  while (pseg != 0)
476 +    {
477 +#    ifdef DEBUG_I00AFUNC
478 +      fprintf (stderr, "%011o %011o\n", pseg, size);
479 +#    endif
480 +      stkl = stkl - pseg;
481 +      ssptr = (struct stack_segment_linkage *) stkl;
482 +      size = ssptr->sssize;
483 +      pseg = ssptr->sspseg;
484 +      result += size;
485 +    }
486 +  return (result);
487 +}
488 +
489 +#   endif /* not CRAY2 */
490 +#  endif /* CRAY */
491 +
492 +# endif /* no alloca */
493 +#endif /* not GCC version 3 */
494 diff -urN popt-for-windows/lib/alloca.in.h popt-for-windows-gnulib/lib/alloca.in.h
495 --- popt-for-windows/lib/alloca.in.h    1970-01-01 01:00:00.000000000 +0100
496 +++ popt-for-windows-gnulib/lib/alloca.in.h     2008-10-25 15:17:05.000000000 +0100
497 @@ -0,0 +1,56 @@
498 +/* Memory allocation on the stack.
499 +
500 +   Copyright (C) 1995, 1999, 2001-2004, 2006-2008 Free Software
501 +   Foundation, Inc.
502 +
503 +   This program is free software; you can redistribute it and/or modify it
504 +   under the terms of the GNU General Public License as published
505 +   by the Free Software Foundation; either version 3, or (at your option)
506 +   any later version.
507 +
508 +   This program is distributed in the hope that it will be useful,
509 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
510 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
511 +   General Public License for more details.
512 +
513 +   You should have received a copy of the GNU General Public
514 +   License along with this program; if not, write to the Free Software
515 +   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
516 +   USA.  */
517 +
518 +/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H
519 +   means there is a real alloca function.  */
520 +#ifndef _GL_ALLOCA_H
521 +#define _GL_ALLOCA_H
522 +
523 +/* alloca (N) returns a pointer to N bytes of memory
524 +   allocated on the stack, which will last until the function returns.
525 +   Use of alloca should be avoided:
526 +     - inside arguments of function calls - undefined behaviour,
527 +     - in inline functions - the allocation may actually last until the
528 +       calling function returns,
529 +     - for huge N (say, N >= 65536) - you never know how large (or small)
530 +       the stack is, and when the stack cannot fulfill the memory allocation
531 +       request, the program just crashes.
532 + */
533 +
534 +#ifndef alloca
535 +# ifdef __GNUC__
536 +#  define alloca __builtin_alloca
537 +# elif defined _AIX
538 +#  define alloca __alloca
539 +# elif defined _MSC_VER
540 +#  include <malloc.h>
541 +#  define alloca _alloca
542 +# elif defined __DECC && defined __VMS
543 +#  define alloca __ALLOCA
544 +# else
545 +#  include <stddef.h>
546 +#  ifdef  __cplusplus
547 +extern "C"
548 +#  endif
549 +void *alloca (size_t);
550 +# endif
551 +#endif
552 +
553 +#endif /* _GL_ALLOCA_H */
554 diff -urN popt-for-windows/lib/.cvsignore popt-for-windows-gnulib/lib/.cvsignore
555 --- popt-for-windows/lib/.cvsignore     1970-01-01 01:00:00.000000000 +0100
556 +++ popt-for-windows-gnulib/lib/.cvsignore      2008-10-25 15:17:05.000000000 +0100
557 @@ -0,0 +1,25 @@
558 +.deps
559 +.dirstamp
560 +Makefile.am
561 +alloca.c
562 +alloca.in.h
563 +dirent.in.h
564 +dirfd.c
565 +dummy.c
566 +fnmatch.c
567 +fnmatch.in.h
568 +fnmatch_loop.c
569 +getlogin_r.c
570 +glob-libc.h
571 +glob.c
572 +glob.in.h
573 +malloc.c
574 +mempcpy.c
575 +stdbool.in.h
576 +stdlib.in.h
577 +strdup.c
578 +string.in.h
579 +sys_stat.in.h
580 +unistd.in.h
581 +wchar.in.h
582 +wctype.in.h
583 diff -urN popt-for-windows/lib/dirent.in.h popt-for-windows-gnulib/lib/dirent.in.h
584 --- popt-for-windows/lib/dirent.in.h    1970-01-01 01:00:00.000000000 +0100
585 +++ popt-for-windows-gnulib/lib/dirent.in.h     2008-10-25 15:17:05.000000000 +0100
586 @@ -0,0 +1,67 @@
587 +/* A GNU-like <dirent.h>.
588 +   Copyright (C) 2006-2008 Free Software Foundation, Inc.
589 +
590 +   This program is free software: you can redistribute it and/or modify
591 +   it under the terms of the GNU General Public License as published by
592 +   the Free Software Foundation; either version 3 of the License, or
593 +   (at your option) any later version.
594 +
595 +   This program is distributed in the hope that it will be useful,
596 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
597 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
598 +   GNU General Public License for more details.
599 +
600 +   You should have received a copy of the GNU General Public License
601 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
602 +
603 +#ifndef _GL_DIRENT_H
604 +
605 +#if __GNUC__ >= 3
606 +@PRAGMA_SYSTEM_HEADER@
607 +#endif
608 +
609 +/* The include_next requires a split double-inclusion guard.  */
610 +#@INCLUDE_NEXT@ @NEXT_DIRENT_H@
611 +
612 +#ifndef _GL_DIRENT_H
613 +#define _GL_DIRENT_H
614 +
615 +/* The definition of GL_LINK_WARNING is copied here.  */
616 +
617 +
618 +#ifdef __cplusplus
619 +extern "C" {
620 +#endif
621 +
622 +/* Declare overridden functions.  */
623 +
624 +#if @REPLACE_FCHDIR@
625 +# define opendir rpl_opendir
626 +extern DIR * opendir (const char *);
627 +# define closedir rpl_closedir
628 +extern int closedir (DIR *);
629 +#endif
630 +
631 +/* Declare GNU extensions.  */
632 +
633 +#if @GNULIB_DIRFD@
634 +# if !@HAVE_DECL_DIRFD@ && !defined dirfd
635 +/* Return the file descriptor associated with the given directory stream,
636 +   or -1 if none exists.  */
637 +extern int dirfd (DIR const *dir);
638 +# endif
639 +#elif defined GNULIB_POSIXCHECK
640 +# undef dirfd
641 +# define dirfd(d) \
642 +    (GL_LINK_WARNING ("dirfd is unportable - " \
643 +                      "use gnulib module dirfd for portability"), \
644 +     dirfd (d))
645 +#endif
646 +
647 +#ifdef __cplusplus
648 +}
649 +#endif
650 +
651 +
652 +#endif /* _GL_DIRENT_H */
653 +#endif /* _GL_DIRENT_H */
654 diff -urN popt-for-windows/lib/dirfd.c popt-for-windows-gnulib/lib/dirfd.c
655 --- popt-for-windows/lib/dirfd.c        1970-01-01 01:00:00.000000000 +0100
656 +++ popt-for-windows-gnulib/lib/dirfd.c 2008-10-25 15:17:05.000000000 +0100
657 @@ -0,0 +1,28 @@
658 +/* dirfd.c -- return the file descriptor associated with an open DIR*
659 +
660 +   Copyright (C) 2001, 2006, 2008 Free Software Foundation, Inc.
661 +
662 +   This program is free software: you can redistribute it and/or modify
663 +   it under the terms of the GNU General Public License as published by
664 +   the Free Software Foundation; either version 3 of the License, or
665 +   (at your option) any later version.
666 +
667 +   This program is distributed in the hope that it will be useful,
668 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
669 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
670 +   GNU General Public License for more details.
671 +
672 +   You should have received a copy of the GNU General Public License
673 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
674 +
675 +/* Written by Jim Meyering. */
676 +
677 +#include <config.h>
678 +
679 +#include <dirent.h>
680 +
681 +int
682 +dirfd (DIR const *dir_p)
683 +{
684 +  return DIR_TO_FD (dir_p);
685 +}
686 diff -urN popt-for-windows/lib/dummy.c popt-for-windows-gnulib/lib/dummy.c
687 --- popt-for-windows/lib/dummy.c        1970-01-01 01:00:00.000000000 +0100
688 +++ popt-for-windows-gnulib/lib/dummy.c 2008-10-25 15:17:05.000000000 +0100
689 @@ -0,0 +1,42 @@
690 +/* A dummy file, to prevent empty libraries from breaking builds.
691 +   Copyright (C) 2004, 2007 Free Software Foundation, Inc.
692 +
693 +   This program is free software: you can redistribute it and/or modify
694 +   it under the terms of the GNU General Public License as published by
695 +   the Free Software Foundation; either version 3 of the License, or
696 +   (at your option) any later version.
697 +
698 +   This program is distributed in the hope that it will be useful,
699 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
700 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
701 +   GNU General Public License for more details.
702 +
703 +   You should have received a copy of the GNU General Public License
704 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
705 +
706 +/* Some systems, reportedly OpenBSD and Mac OS X, refuse to create
707 +   libraries without any object files.  You might get an error like:
708 +
709 +   > ar cru .libs/libgl.a
710 +   > ar: no archive members specified
711 +
712 +   Compiling this file, and adding its object file to the library, will
713 +   prevent the library from being empty.  */
714 +
715 +/* Some systems, such as Solaris with cc 5.0, refuse to work with libraries
716 +   that don't export any symbol.  You might get an error like:
717 +
718 +   > cc ... libgnu.a
719 +   > ild: (bad file) garbled symbol table in archive ../gllib/libgnu.a
720 +
721 +   Compiling this file, and adding its object file to the library, will
722 +   prevent the library from exporting no symbols.  */
723 +
724 +#ifdef __sun
725 +/* This declaration ensures that the library will export at least 1 symbol.  */
726 +int gl_dummy_symbol;
727 +#else
728 +/* This declaration is solely to ensure that after preprocessing
729 +   this file is never empty.  */
730 +typedef int dummy;
731 +#endif
732 diff -urN popt-for-windows/lib/fnmatch.c popt-for-windows-gnulib/lib/fnmatch.c
733 --- popt-for-windows/lib/fnmatch.c      1970-01-01 01:00:00.000000000 +0100
734 +++ popt-for-windows-gnulib/lib/fnmatch.c       2008-10-25 15:17:05.000000000 +0100
735 @@ -0,0 +1,354 @@
736 +/* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007
737 +       Free Software Foundation, Inc.
738 +
739 +   This program is free software; you can redistribute it and/or modify
740 +   it under the terms of the GNU General Public License as published by
741 +   the Free Software Foundation; either version 3, or (at your option)
742 +   any later version.
743 +
744 +   This program is distributed in the hope that it will be useful,
745 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
746 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
747 +   GNU General Public License for more details.
748 +
749 +   You should have received a copy of the GNU General Public License
750 +   along with this program; if not, write to the Free Software Foundation,
751 +   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
752 +
753 +#ifndef _LIBC
754 +# include <config.h>
755 +#endif
756 +
757 +/* Enable GNU extensions in fnmatch.h.  */
758 +#ifndef _GNU_SOURCE
759 +# define _GNU_SOURCE   1
760 +#endif
761 +
762 +#if ! defined __builtin_expect && __GNUC__ < 3
763 +# define __builtin_expect(expr, expected) (expr)
764 +#endif
765 +
766 +#include <fnmatch.h>
767 +
768 +#include <alloca.h>
769 +#include <assert.h>
770 +#include <ctype.h>
771 +#include <errno.h>
772 +#include <stddef.h>
773 +#include <stdbool.h>
774 +#include <stdlib.h>
775 +#include <string.h>
776 +
777 +#define WIDE_CHAR_SUPPORT \
778 +  (HAVE_WCTYPE_H && HAVE_BTOWC && HAVE_ISWCTYPE \
779 +   && HAVE_WMEMCHR && (HAVE_WMEMCPY || HAVE_WMEMPCPY))
780 +
781 +/* For platform which support the ISO C amendement 1 functionality we
782 +   support user defined character classes.  */
783 +#if defined _LIBC || WIDE_CHAR_SUPPORT
784 +# include <wctype.h>
785 +# include <wchar.h>
786 +#endif
787 +
788 +/* We need some of the locale data (the collation sequence information)
789 +   but there is no interface to get this information in general.  Therefore
790 +   we support a correct implementation only in glibc.  */
791 +#ifdef _LIBC
792 +# include "../locale/localeinfo.h"
793 +# include "../locale/elem-hash.h"
794 +# include "../locale/coll-lookup.h"
795 +# include <shlib-compat.h>
796 +
797 +# define CONCAT(a,b) __CONCAT(a,b)
798 +# define mbsrtowcs __mbsrtowcs
799 +# define fnmatch __fnmatch
800 +extern int fnmatch (const char *pattern, const char *string, int flags);
801 +#endif
802 +
803 +#ifndef SIZE_MAX
804 +# define SIZE_MAX ((size_t) -1)
805 +#endif
806 +
807 +/* We often have to test for FNM_FILE_NAME and FNM_PERIOD being both set.  */
808 +#define NO_LEADING_PERIOD(flags) \
809 +  ((flags & (FNM_FILE_NAME | FNM_PERIOD)) == (FNM_FILE_NAME | FNM_PERIOD))
810 +
811 +/* Comment out all this code if we are using the GNU C Library, and are not
812 +   actually compiling the library itself, and have not detected a bug
813 +   in the library.  This code is part of the GNU C
814 +   Library, but also included in many other GNU distributions.  Compiling
815 +   and linking in this code is a waste when using the GNU C library
816 +   (especially if it is a shared library).  Rather than having every GNU
817 +   program understand `configure --with-gnu-libc' and omit the object files,
818 +   it is simpler to just do this in the source for each such file.  */
819 +
820 +#if defined _LIBC || !defined __GNU_LIBRARY__ || !HAVE_FNMATCH_GNU
821 +
822 +
823 +# if ! (defined isblank || (HAVE_ISBLANK && HAVE_DECL_ISBLANK))
824 +#  define isblank(c) ((c) == ' ' || (c) == '\t')
825 +# endif
826 +
827 +# define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
828 +
829 +# if defined _LIBC || WIDE_CHAR_SUPPORT
830 +/* The GNU C library provides support for user-defined character classes
831 +   and the functions from ISO C amendement 1.  */
832 +#  ifdef CHARCLASS_NAME_MAX
833 +#   define CHAR_CLASS_MAX_LENGTH CHARCLASS_NAME_MAX
834 +#  else
835 +/* This shouldn't happen but some implementation might still have this
836 +   problem.  Use a reasonable default value.  */
837 +#   define CHAR_CLASS_MAX_LENGTH 256
838 +#  endif
839 +
840 +#  ifdef _LIBC
841 +#   define IS_CHAR_CLASS(string) __wctype (string)
842 +#  else
843 +#   define IS_CHAR_CLASS(string) wctype (string)
844 +#  endif
845 +
846 +#  ifdef _LIBC
847 +#   define ISWCTYPE(WC, WT)    __iswctype (WC, WT)
848 +#  else
849 +#   define ISWCTYPE(WC, WT)    iswctype (WC, WT)
850 +#  endif
851 +
852 +#  if (HAVE_MBSTATE_T && HAVE_MBSRTOWCS) || _LIBC
853 +/* In this case we are implementing the multibyte character handling.  */
854 +#   define HANDLE_MULTIBYTE    1
855 +#  endif
856 +
857 +# else
858 +#  define CHAR_CLASS_MAX_LENGTH  6 /* Namely, `xdigit'.  */
859 +
860 +#  define IS_CHAR_CLASS(string)                                                      \
861 +   (STREQ (string, "alpha") || STREQ (string, "upper")                       \
862 +    || STREQ (string, "lower") || STREQ (string, "digit")                    \
863 +    || STREQ (string, "alnum") || STREQ (string, "xdigit")                   \
864 +    || STREQ (string, "space") || STREQ (string, "print")                    \
865 +    || STREQ (string, "punct") || STREQ (string, "graph")                    \
866 +    || STREQ (string, "cntrl") || STREQ (string, "blank"))
867 +# endif
868 +
869 +/* Avoid depending on library functions or files
870 +   whose names are inconsistent.  */
871 +
872 +/* Global variable.  */
873 +static int posixly_correct;
874 +
875 +# ifndef internal_function
876 +/* Inside GNU libc we mark some function in a special way.  In other
877 +   environments simply ignore the marking.  */
878 +#  define internal_function
879 +# endif
880 +
881 +/* Note that this evaluates C many times.  */
882 +# define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c))
883 +# define CHAR  char
884 +# define UCHAR unsigned char
885 +# define INT   int
886 +# define FCT   internal_fnmatch
887 +# define EXT   ext_match
888 +# define END   end_pattern
889 +# define L_(CS)        CS
890 +# ifdef _LIBC
891 +#  define BTOWC(C)     __btowc (C)
892 +# else
893 +#  define BTOWC(C)     btowc (C)
894 +# endif
895 +# define STRLEN(S) strlen (S)
896 +# define STRCAT(D, S) strcat (D, S)
897 +# ifdef _LIBC
898 +#  define MEMPCPY(D, S, N) __mempcpy (D, S, N)
899 +# else
900 +#  if HAVE_MEMPCPY
901 +#   define MEMPCPY(D, S, N) mempcpy (D, S, N)
902 +#  else
903 +#   define MEMPCPY(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N)))
904 +#  endif
905 +# endif
906 +# define MEMCHR(S, C, N) memchr (S, C, N)
907 +# define STRCOLL(S1, S2) strcoll (S1, S2)
908 +# include "fnmatch_loop.c"
909 +
910 +
911 +# if HANDLE_MULTIBYTE
912 +#  define FOLD(c) ((flags & FNM_CASEFOLD) ? towlower (c) : (c))
913 +#  define CHAR wchar_t
914 +#  define UCHAR        wint_t
915 +#  define INT  wint_t
916 +#  define FCT  internal_fnwmatch
917 +#  define EXT  ext_wmatch
918 +#  define END  end_wpattern
919 +#  define L_(CS)       L##CS
920 +#  define BTOWC(C)     (C)
921 +#  ifdef _LIBC
922 +#   define STRLEN(S) __wcslen (S)
923 +#   define STRCAT(D, S) __wcscat (D, S)
924 +#   define MEMPCPY(D, S, N) __wmempcpy (D, S, N)
925 +#  else
926 +#   define STRLEN(S) wcslen (S)
927 +#   define STRCAT(D, S) wcscat (D, S)
928 +#   if HAVE_WMEMPCPY
929 +#    define MEMPCPY(D, S, N) wmempcpy (D, S, N)
930 +#   else
931 +#    define MEMPCPY(D, S, N) (wmemcpy (D, S, N) + (N))
932 +#   endif
933 +#  endif
934 +#  define MEMCHR(S, C, N) wmemchr (S, C, N)
935 +#  define STRCOLL(S1, S2) wcscoll (S1, S2)
936 +#  define WIDE_CHAR_VERSION 1
937 +
938 +#  undef IS_CHAR_CLASS
939 +/* We have to convert the wide character string in a multibyte string.  But
940 +   we know that the character class names consist of alphanumeric characters
941 +   from the portable character set, and since the wide character encoding
942 +   for a member of the portable character set is the same code point as
943 +   its single-byte encoding, we can use a simplified method to convert the
944 +   string to a multibyte character string.  */
945 +static wctype_t
946 +is_char_class (const wchar_t *wcs)
947 +{
948 +  char s[CHAR_CLASS_MAX_LENGTH + 1];
949 +  char *cp = s;
950 +
951 +  do
952 +    {
953 +      /* Test for a printable character from the portable character set.  */
954 +#  ifdef _LIBC
955 +      if (*wcs < 0x20 || *wcs > 0x7e
956 +         || *wcs == 0x24 || *wcs == 0x40 || *wcs == 0x60)
957 +       return (wctype_t) 0;
958 +#  else
959 +      switch (*wcs)
960 +       {
961 +       case L' ': case L'!': case L'"': case L'#': case L'%':
962 +       case L'&': case L'\'': case L'(': case L')': case L'*':
963 +       case L'+': case L',': case L'-': case L'.': case L'/':
964 +       case L'0': case L'1': case L'2': case L'3': case L'4':
965 +       case L'5': case L'6': case L'7': case L'8': case L'9':
966 +       case L':': case L';': case L'<': case L'=': case L'>':
967 +       case L'?':
968 +       case L'A': case L'B': case L'C': case L'D': case L'E':
969 +       case L'F': case L'G': case L'H': case L'I': case L'J':
970 +       case L'K': case L'L': case L'M': case L'N': case L'O':
971 +       case L'P': case L'Q': case L'R': case L'S': case L'T':
972 +       case L'U': case L'V': case L'W': case L'X': case L'Y':
973 +       case L'Z':
974 +       case L'[': case L'\\': case L']': case L'^': case L'_':
975 +       case L'a': case L'b': case L'c': case L'd': case L'e':
976 +       case L'f': case L'g': case L'h': case L'i': case L'j':
977 +       case L'k': case L'l': case L'm': case L'n': case L'o':
978 +       case L'p': case L'q': case L'r': case L's': case L't':
979 +       case L'u': case L'v': case L'w': case L'x': case L'y':
980 +       case L'z': case L'{': case L'|': case L'}': case L'~':
981 +         break;
982 +       default:
983 +         return (wctype_t) 0;
984 +       }
985 +#  endif
986 +
987 +      /* Avoid overrunning the buffer.  */
988 +      if (cp == s + CHAR_CLASS_MAX_LENGTH)
989 +       return (wctype_t) 0;
990 +
991 +      *cp++ = (char) *wcs++;
992 +    }
993 +  while (*wcs != L'\0');
994 +
995 +  *cp = '\0';
996 +
997 +#  ifdef _LIBC
998 +  return __wctype (s);
999 +#  else
1000 +  return wctype (s);
1001 +#  endif
1002 +}
1003 +#  define IS_CHAR_CLASS(string) is_char_class (string)
1004 +
1005 +#  include "fnmatch_loop.c"
1006 +# endif
1007 +
1008 +
1009 +int
1010 +fnmatch (const char *pattern, const char *string, int flags)
1011 +{
1012 +# if HANDLE_MULTIBYTE
1013 +#  define ALLOCA_LIMIT 2000
1014 +  if (__builtin_expect (MB_CUR_MAX, 1) != 1)
1015 +    {
1016 +      mbstate_t ps;
1017 +      size_t patsize;
1018 +      size_t strsize;
1019 +      size_t totsize;
1020 +      wchar_t *wpattern;
1021 +      wchar_t *wstring;
1022 +      int res;
1023 +
1024 +      /* Calculate the size needed to convert the strings to
1025 +        wide characters.  */
1026 +      memset (&ps, '\0', sizeof (ps));
1027 +      patsize = mbsrtowcs (NULL, &pattern, 0, &ps) + 1;
1028 +      if (__builtin_expect (patsize != 0, 1))
1029 +       {
1030 +         assert (mbsinit (&ps));
1031 +         strsize = mbsrtowcs (NULL, &string, 0, &ps) + 1;
1032 +         if (__builtin_expect (strsize != 0, 1))
1033 +           {
1034 +             assert (mbsinit (&ps));
1035 +             totsize = patsize + strsize;
1036 +             if (__builtin_expect (! (patsize <= totsize
1037 +                                      && totsize <= SIZE_MAX / sizeof (wchar_t)),
1038 +                                   0))
1039 +               {
1040 +                 errno = ENOMEM;
1041 +                 return -1;
1042 +               }
1043 +
1044 +             /* Allocate room for the wide characters.  */
1045 +             if (__builtin_expect (totsize < ALLOCA_LIMIT, 1))
1046 +               wpattern = (wchar_t *) alloca (totsize * sizeof (wchar_t));
1047 +             else
1048 +               {
1049 +                 wpattern = malloc (totsize * sizeof (wchar_t));
1050 +                 if (__builtin_expect (! wpattern, 0))
1051 +                   {
1052 +                     errno = ENOMEM;
1053 +                     return -1;
1054 +                   }
1055 +               }
1056 +             wstring = wpattern + patsize;
1057 +
1058 +             /* Convert the strings into wide characters.  */
1059 +             mbsrtowcs (wpattern, &pattern, patsize, &ps);
1060 +             assert (mbsinit (&ps));
1061 +             mbsrtowcs (wstring, &string, strsize, &ps);
1062 +
1063 +             res = internal_fnwmatch (wpattern, wstring, wstring + strsize - 1,
1064 +                                      flags & FNM_PERIOD, flags);
1065 +
1066 +             if (__builtin_expect (! (totsize < ALLOCA_LIMIT), 0))
1067 +               free (wpattern);
1068 +             return res;
1069 +           }
1070 +       }
1071 +    }
1072 +
1073 +# endif /* HANDLE_MULTIBYTE */
1074 +
1075 +  return internal_fnmatch (pattern, string, string + strlen (string),
1076 +                          flags & FNM_PERIOD, flags);
1077 +}
1078 +
1079 +# ifdef _LIBC
1080 +#  undef fnmatch
1081 +versioned_symbol (libc, __fnmatch, fnmatch, GLIBC_2_2_3);
1082 +#  if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_2_3)
1083 +strong_alias (__fnmatch, __fnmatch_old)
1084 +compat_symbol (libc, __fnmatch_old, fnmatch, GLIBC_2_0);
1085 +#  endif
1086 +libc_hidden_ver (__fnmatch, fnmatch)
1087 +# endif
1088 +
1089 +#endif /* _LIBC or not __GNU_LIBRARY__.  */
1090 diff -urN popt-for-windows/lib/fnmatch.in.h popt-for-windows-gnulib/lib/fnmatch.in.h
1091 --- popt-for-windows/lib/fnmatch.in.h   1970-01-01 01:00:00.000000000 +0100
1092 +++ popt-for-windows-gnulib/lib/fnmatch.in.h    2008-10-25 15:17:05.000000000 +0100
1093 @@ -0,0 +1,65 @@
1094 +/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2001, 2002, 2003,
1095 +   2005, 2007 Free Software Foundation, Inc.
1096 +
1097 +   This file is part of the GNU C Library.
1098 +
1099 +   This program is free software; you can redistribute it and/or modify
1100 +   it under the terms of the GNU General Public License as published by
1101 +   the Free Software Foundation; either version 3, or (at your option)
1102 +   any later version.
1103 +
1104 +   This program is distributed in the hope that it will be useful,
1105 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
1106 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1107 +   GNU General Public License for more details.
1108 +
1109 +   You should have received a copy of the GNU General Public License
1110 +   along with this program; if not, write to the Free Software Foundation,
1111 +   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
1112 +
1113 +#ifndef        _FNMATCH_H
1114 +#define        _FNMATCH_H      1
1115 +
1116 +#ifdef __cplusplus
1117 +extern "C" {
1118 +#endif
1119 +
1120 +/* We #undef these before defining them because some losing systems
1121 +   (HP-UX A.08.07 for example) define these in <unistd.h>.  */
1122 +#undef FNM_PATHNAME
1123 +#undef FNM_NOESCAPE
1124 +#undef FNM_PERIOD
1125 +
1126 +/* Bits set in the FLAGS argument to `fnmatch'.  */
1127 +#define        FNM_PATHNAME    (1 << 0) /* No wildcard can ever match `/'.  */
1128 +#define        FNM_NOESCAPE    (1 << 1) /* Backslashes don't quote special chars.  */
1129 +#define        FNM_PERIOD      (1 << 2) /* Leading `.' is matched only explicitly.  */
1130 +
1131 +#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE
1132 +# define FNM_FILE_NAME  FNM_PATHNAME   /* Preferred GNU name.  */
1133 +# define FNM_LEADING_DIR (1 << 3)      /* Ignore `/...' after a match.  */
1134 +# define FNM_CASEFOLD   (1 << 4)       /* Compare without regard to case.  */
1135 +# define FNM_EXTMATCH   (1 << 5)       /* Use ksh-like extended matching. */
1136 +#endif
1137 +
1138 +/* Value returned by `fnmatch' if STRING does not match PATTERN.  */
1139 +#define        FNM_NOMATCH     1
1140 +
1141 +/* This value is returned if the implementation does not support
1142 +   `fnmatch'.  Since this is not the case here it will never be
1143 +   returned but the conformance test suites still require the symbol
1144 +   to be defined.  */
1145 +#ifdef _XOPEN_SOURCE
1146 +# define FNM_NOSYS     (-1)
1147 +#endif
1148 +
1149 +/* Match NAME against the file name pattern PATTERN,
1150 +   returning zero if it matches, FNM_NOMATCH if not.  */
1151 +extern int fnmatch (const char *__pattern, const char *__name,
1152 +                   int __flags);
1153 +
1154 +#ifdef __cplusplus
1155 +}
1156 +#endif
1157 +
1158 +#endif /* fnmatch.h */
1159 diff -urN popt-for-windows/lib/fnmatch_loop.c popt-for-windows-gnulib/lib/fnmatch_loop.c
1160 --- popt-for-windows/lib/fnmatch_loop.c 1970-01-01 01:00:00.000000000 +0100
1161 +++ popt-for-windows-gnulib/lib/fnmatch_loop.c  2008-10-25 15:17:05.000000000 +0100
1162 @@ -0,0 +1,1210 @@
1163 +/* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006
1164 +   Free Software Foundation, Inc.
1165 +   This file is part of the GNU C Library.
1166 +
1167 +   This program is free software; you can redistribute it and/or modify
1168 +   it under the terms of the GNU General Public License as published by
1169 +   the Free Software Foundation; either version 3, or (at your option)
1170 +   any later version.
1171 +
1172 +   This program is distributed in the hope that it will be useful,
1173 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
1174 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1175 +   GNU General Public License for more details.
1176 +
1177 +   You should have received a copy of the GNU General Public License
1178 +   along with this program; if not, write to the Free Software Foundation,
1179 +   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
1180 +
1181 +/* Match STRING against the file name pattern PATTERN, returning zero if
1182 +   it matches, nonzero if not.  */
1183 +static int EXT (INT opt, const CHAR *pattern, const CHAR *string,
1184 +               const CHAR *string_end, bool no_leading_period, int flags)
1185 +     internal_function;
1186 +static const CHAR *END (const CHAR *patternp) internal_function;
1187 +
1188 +static int
1189 +internal_function
1190 +FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
1191 +     bool no_leading_period, int flags)
1192 +{
1193 +  register const CHAR *p = pattern, *n = string;
1194 +  register UCHAR c;
1195 +#ifdef _LIBC
1196 +# if WIDE_CHAR_VERSION
1197 +  const char *collseq = (const char *)
1198 +    _NL_CURRENT(LC_COLLATE, _NL_COLLATE_COLLSEQWC);
1199 +# else
1200 +  const UCHAR *collseq = (const UCHAR *)
1201 +    _NL_CURRENT(LC_COLLATE, _NL_COLLATE_COLLSEQMB);
1202 +# endif
1203 +#endif
1204 +
1205 +  while ((c = *p++) != L_('\0'))
1206 +    {
1207 +      bool new_no_leading_period = false;
1208 +      c = FOLD (c);
1209 +
1210 +      switch (c)
1211 +       {
1212 +       case L_('?'):
1213 +         if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(')
1214 +           {
1215 +             int res;
1216 +
1217 +             res = EXT (c, p, n, string_end, no_leading_period,
1218 +                        flags);
1219 +             if (res != -1)
1220 +               return res;
1221 +           }
1222 +
1223 +         if (n == string_end)
1224 +           return FNM_NOMATCH;
1225 +         else if (*n == L_('/') && (flags & FNM_FILE_NAME))
1226 +           return FNM_NOMATCH;
1227 +         else if (*n == L_('.') && no_leading_period)
1228 +           return FNM_NOMATCH;
1229 +         break;
1230 +
1231 +       case L_('\\'):
1232 +         if (!(flags & FNM_NOESCAPE))
1233 +           {
1234 +             c = *p++;
1235 +             if (c == L_('\0'))
1236 +               /* Trailing \ loses.  */
1237 +               return FNM_NOMATCH;
1238 +             c = FOLD (c);
1239 +           }
1240 +         if (n == string_end || FOLD ((UCHAR) *n) != c)
1241 +           return FNM_NOMATCH;
1242 +         break;
1243 +
1244 +       case L_('*'):
1245 +         if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(')
1246 +           {
1247 +             int res;
1248 +
1249 +             res = EXT (c, p, n, string_end, no_leading_period,
1250 +                        flags);
1251 +             if (res != -1)
1252 +               return res;
1253 +           }
1254 +
1255 +         if (n != string_end && *n == L_('.') && no_leading_period)
1256 +           return FNM_NOMATCH;
1257 +
1258 +         for (c = *p++; c == L_('?') || c == L_('*'); c = *p++)
1259 +           {
1260 +             if (*p == L_('(') && (flags & FNM_EXTMATCH) != 0)
1261 +               {
1262 +                 const CHAR *endp = END (p);
1263 +                 if (endp != p)
1264 +                   {
1265 +                     /* This is a pattern.  Skip over it.  */
1266 +                     p = endp;
1267 +                     continue;
1268 +                   }
1269 +               }
1270 +
1271 +             if (c == L_('?'))
1272 +               {
1273 +                 /* A ? needs to match one character.  */
1274 +                 if (n == string_end)
1275 +                   /* There isn't another character; no match.  */
1276 +                   return FNM_NOMATCH;
1277 +                 else if (*n == L_('/')
1278 +                          && __builtin_expect (flags & FNM_FILE_NAME, 0))
1279 +                   /* A slash does not match a wildcard under
1280 +                      FNM_FILE_NAME.  */
1281 +                   return FNM_NOMATCH;
1282 +                 else
1283 +                   /* One character of the string is consumed in matching
1284 +                      this ? wildcard, so *??? won't match if there are
1285 +                      less than three characters.  */
1286 +                   ++n;
1287 +               }
1288 +           }
1289 +
1290 +         if (c == L_('\0'))
1291 +           /* The wildcard(s) is/are the last element of the pattern.
1292 +              If the name is a file name and contains another slash
1293 +              this means it cannot match, unless the FNM_LEADING_DIR
1294 +              flag is set.  */
1295 +           {
1296 +             int result = (flags & FNM_FILE_NAME) == 0 ? 0 : FNM_NOMATCH;
1297 +
1298 +             if (flags & FNM_FILE_NAME)
1299 +               {
1300 +                 if (flags & FNM_LEADING_DIR)
1301 +                   result = 0;
1302 +                 else
1303 +                   {
1304 +                     if (MEMCHR (n, L_('/'), string_end - n) == NULL)
1305 +                       result = 0;
1306 +                   }
1307 +               }
1308 +
1309 +             return result;
1310 +           }
1311 +         else
1312 +           {
1313 +             const CHAR *endp;
1314 +
1315 +             endp = MEMCHR (n, (flags & FNM_FILE_NAME) ? L_('/') : L_('\0'),
1316 +                            string_end - n);
1317 +             if (endp == NULL)
1318 +               endp = string_end;
1319 +
1320 +             if (c == L_('[')
1321 +                 || (__builtin_expect (flags & FNM_EXTMATCH, 0) != 0
1322 +                     && (c == L_('@') || c == L_('+') || c == L_('!'))
1323 +                     && *p == L_('(')))
1324 +               {
1325 +                 int flags2 = ((flags & FNM_FILE_NAME)
1326 +                               ? flags : (flags & ~FNM_PERIOD));
1327 +                 bool no_leading_period2 = no_leading_period;
1328 +
1329 +                 for (--p; n < endp; ++n, no_leading_period2 = false)
1330 +                   if (FCT (p, n, string_end, no_leading_period2, flags2)
1331 +                       == 0)
1332 +                     return 0;
1333 +               }
1334 +             else if (c == L_('/') && (flags & FNM_FILE_NAME))
1335 +               {
1336 +                 while (n < string_end && *n != L_('/'))
1337 +                   ++n;
1338 +                 if (n < string_end && *n == L_('/')
1339 +                     && (FCT (p, n + 1, string_end, flags & FNM_PERIOD, flags)
1340 +                         == 0))
1341 +                   return 0;
1342 +               }
1343 +             else
1344 +               {
1345 +                 int flags2 = ((flags & FNM_FILE_NAME)
1346 +                               ? flags : (flags & ~FNM_PERIOD));
1347 +                 int no_leading_period2 = no_leading_period;
1348 +
1349 +                 if (c == L_('\\') && !(flags & FNM_NOESCAPE))
1350 +                   c = *p;
1351 +                 c = FOLD (c);
1352 +                 for (--p; n < endp; ++n, no_leading_period2 = false)
1353 +                   if (FOLD ((UCHAR) *n) == c
1354 +                       && (FCT (p, n, string_end, no_leading_period2, flags2)
1355 +                           == 0))
1356 +                     return 0;
1357 +               }
1358 +           }
1359 +
1360 +         /* If we come here no match is possible with the wildcard.  */
1361 +         return FNM_NOMATCH;
1362 +
1363 +       case L_('['):
1364 +         {
1365 +           /* Nonzero if the sense of the character class is inverted.  */
1366 +           register bool not;
1367 +           CHAR cold;
1368 +           UCHAR fn;
1369 +
1370 +           if (posixly_correct == 0)
1371 +             posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
1372 +
1373 +           if (n == string_end)
1374 +             return FNM_NOMATCH;
1375 +
1376 +           if (*n == L_('.') && no_leading_period)
1377 +             return FNM_NOMATCH;
1378 +
1379 +           if (*n == L_('/') && (flags & FNM_FILE_NAME))
1380 +             /* `/' cannot be matched.  */
1381 +             return FNM_NOMATCH;
1382 +
1383 +           not = (*p == L_('!') || (posixly_correct < 0 && *p == L_('^')));
1384 +           if (not)
1385 +             ++p;
1386 +
1387 +           fn = FOLD ((UCHAR) *n);
1388 +
1389 +           c = *p++;
1390 +           for (;;)
1391 +             {
1392 +               if (!(flags & FNM_NOESCAPE) && c == L_('\\'))
1393 +                 {
1394 +                   if (*p == L_('\0'))
1395 +                     return FNM_NOMATCH;
1396 +                   c = FOLD ((UCHAR) *p);
1397 +                   ++p;
1398 +
1399 +                   goto normal_bracket;
1400 +                 }
1401 +               else if (c == L_('[') && *p == L_(':'))
1402 +                 {
1403 +                   /* Leave room for the null.  */
1404 +                   CHAR str[CHAR_CLASS_MAX_LENGTH + 1];
1405 +                   size_t c1 = 0;
1406 +#if defined _LIBC || WIDE_CHAR_SUPPORT
1407 +                   wctype_t wt;
1408 +#endif
1409 +                   const CHAR *startp = p;
1410 +
1411 +                   for (;;)
1412 +                     {
1413 +                       if (c1 == CHAR_CLASS_MAX_LENGTH)
1414 +                         /* The name is too long and therefore the pattern
1415 +                            is ill-formed.  */
1416 +                         return FNM_NOMATCH;
1417 +
1418 +                       c = *++p;
1419 +                       if (c == L_(':') && p[1] == L_(']'))
1420 +                         {
1421 +                           p += 2;
1422 +                           break;
1423 +                         }
1424 +                       if (c < L_('a') || c >= L_('z'))
1425 +                         {
1426 +                           /* This cannot possibly be a character class name.
1427 +                              Match it as a normal range.  */
1428 +                           p = startp;
1429 +                           c = L_('[');
1430 +                           goto normal_bracket;
1431 +                         }
1432 +                       str[c1++] = c;
1433 +                     }
1434 +                   str[c1] = L_('\0');
1435 +
1436 +#if defined _LIBC || WIDE_CHAR_SUPPORT
1437 +                   wt = IS_CHAR_CLASS (str);
1438 +                   if (wt == 0)
1439 +                     /* Invalid character class name.  */
1440 +                     return FNM_NOMATCH;
1441 +
1442 +# if defined _LIBC && ! WIDE_CHAR_VERSION
1443 +                   /* The following code is glibc specific but does
1444 +                      there a good job in speeding up the code since
1445 +                      we can avoid the btowc() call.  */
1446 +                   if (_ISCTYPE ((UCHAR) *n, wt))
1447 +                     goto matched;
1448 +# else
1449 +                   if (ISWCTYPE (BTOWC ((UCHAR) *n), wt))
1450 +                     goto matched;
1451 +# endif
1452 +#else
1453 +                   if ((STREQ (str, L_("alnum")) && isalnum ((UCHAR) *n))
1454 +                       || (STREQ (str, L_("alpha")) && isalpha ((UCHAR) *n))
1455 +                       || (STREQ (str, L_("blank")) && isblank ((UCHAR) *n))
1456 +                       || (STREQ (str, L_("cntrl")) && iscntrl ((UCHAR) *n))
1457 +                       || (STREQ (str, L_("digit")) && isdigit ((UCHAR) *n))
1458 +                       || (STREQ (str, L_("graph")) && isgraph ((UCHAR) *n))
1459 +                       || (STREQ (str, L_("lower")) && islower ((UCHAR) *n))
1460 +                       || (STREQ (str, L_("print")) && isprint ((UCHAR) *n))
1461 +                       || (STREQ (str, L_("punct")) && ispunct ((UCHAR) *n))
1462 +                       || (STREQ (str, L_("space")) && isspace ((UCHAR) *n))
1463 +                       || (STREQ (str, L_("upper")) && isupper ((UCHAR) *n))
1464 +                       || (STREQ (str, L_("xdigit")) && isxdigit ((UCHAR) *n)))
1465 +                     goto matched;
1466 +#endif
1467 +                   c = *p++;
1468 +                 }
1469 +#ifdef _LIBC
1470 +               else if (c == L_('[') && *p == L_('='))
1471 +                 {
1472 +                   UCHAR str[1];
1473 +                   uint32_t nrules =
1474 +                     _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
1475 +                   const CHAR *startp = p;
1476 +
1477 +                   c = *++p;
1478 +                   if (c == L_('\0'))
1479 +                     {
1480 +                       p = startp;
1481 +                       c = L_('[');
1482 +                       goto normal_bracket;
1483 +                     }
1484 +                   str[0] = c;
1485 +
1486 +                   c = *++p;
1487 +                   if (c != L_('=') || p[1] != L_(']'))
1488 +                     {
1489 +                       p = startp;
1490 +                       c = L_('[');
1491 +                       goto normal_bracket;
1492 +                     }
1493 +                   p += 2;
1494 +
1495 +                   if (nrules == 0)
1496 +                     {
1497 +                       if ((UCHAR) *n == str[0])
1498 +                         goto matched;
1499 +                     }
1500 +                   else
1501 +                     {
1502 +                       const int32_t *table;
1503 +# if WIDE_CHAR_VERSION
1504 +                       const int32_t *weights;
1505 +                       const int32_t *extra;
1506 +# else
1507 +                       const unsigned char *weights;
1508 +                       const unsigned char *extra;
1509 +# endif
1510 +                       const int32_t *indirect;
1511 +                       int32_t idx;
1512 +                       const UCHAR *cp = (const UCHAR *) str;
1513 +
1514 +                       /* This #include defines a local function!  */
1515 +# if WIDE_CHAR_VERSION
1516 +#  include <locale/weightwc.h>
1517 +# else
1518 +#  include <locale/weight.h>
1519 +# endif
1520 +
1521 +# if WIDE_CHAR_VERSION
1522 +                       table = (const int32_t *)
1523 +                         _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEWC);
1524 +                       weights = (const int32_t *)
1525 +                         _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTWC);
1526 +                       extra = (const int32_t *)
1527 +                         _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAWC);
1528 +                       indirect = (const int32_t *)
1529 +                         _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTWC);
1530 +# else
1531 +                       table = (const int32_t *)
1532 +                         _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
1533 +                       weights = (const unsigned char *)
1534 +                         _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB);
1535 +                       extra = (const unsigned char *)
1536 +                         _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
1537 +                       indirect = (const int32_t *)
1538 +                         _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB);
1539 +# endif
1540 +
1541 +                       idx = findidx (&cp);
1542 +                       if (idx != 0)
1543 +                         {
1544 +                           /* We found a table entry.  Now see whether the
1545 +                              character we are currently at has the same
1546 +                              equivalance class value.  */
1547 +                           int len = weights[idx];
1548 +                           int32_t idx2;
1549 +                           const UCHAR *np = (const UCHAR *) n;
1550 +
1551 +                           idx2 = findidx (&np);
1552 +                           if (idx2 != 0 && len == weights[idx2])
1553 +                             {
1554 +                               int cnt = 0;
1555 +
1556 +                               while (cnt < len
1557 +                                      && (weights[idx + 1 + cnt]
1558 +                                          == weights[idx2 + 1 + cnt]))
1559 +                                 ++cnt;
1560 +
1561 +                               if (cnt == len)
1562 +                                 goto matched;
1563 +                             }
1564 +                         }
1565 +                     }
1566 +
1567 +                   c = *p++;
1568 +                 }
1569 +#endif
1570 +               else if (c == L_('\0'))
1571 +                 /* [ (unterminated) loses.  */
1572 +                 return FNM_NOMATCH;
1573 +               else
1574 +                 {
1575 +                   bool is_range = false;
1576 +
1577 +#ifdef _LIBC
1578 +                   bool is_seqval = false;
1579 +
1580 +                   if (c == L_('[') && *p == L_('.'))
1581 +                     {
1582 +                       uint32_t nrules =
1583 +                         _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
1584 +                       const CHAR *startp = p;
1585 +                       size_t c1 = 0;
1586 +
1587 +                       while (1)
1588 +                         {
1589 +                           c = *++p;
1590 +                           if (c == L_('.') && p[1] == L_(']'))
1591 +                             {
1592 +                               p += 2;
1593 +                               break;
1594 +                             }
1595 +                           if (c == '\0')
1596 +                             return FNM_NOMATCH;
1597 +                           ++c1;
1598 +                         }
1599 +
1600 +                       /* We have to handling the symbols differently in
1601 +                          ranges since then the collation sequence is
1602 +                          important.  */
1603 +                       is_range = *p == L_('-') && p[1] != L_('\0');
1604 +
1605 +                       if (nrules == 0)
1606 +                         {
1607 +                           /* There are no names defined in the collation
1608 +                              data.  Therefore we only accept the trivial
1609 +                              names consisting of the character itself.  */
1610 +                           if (c1 != 1)
1611 +                             return FNM_NOMATCH;
1612 +
1613 +                           if (!is_range && *n == startp[1])
1614 +                             goto matched;
1615 +
1616 +                           cold = startp[1];
1617 +                           c = *p++;
1618 +                         }
1619 +                       else
1620 +                         {
1621 +                           int32_t table_size;
1622 +                           const int32_t *symb_table;
1623 +# ifdef WIDE_CHAR_VERSION
1624 +                           char str[c1];
1625 +                           size_t strcnt;
1626 +# else
1627 +#  define str (startp + 1)
1628 +# endif
1629 +                           const unsigned char *extra;
1630 +                           int32_t idx;
1631 +                           int32_t elem;
1632 +                           int32_t second;
1633 +                           int32_t hash;
1634 +
1635 +# ifdef WIDE_CHAR_VERSION
1636 +                           /* We have to convert the name to a single-byte
1637 +                              string.  This is possible since the names
1638 +                              consist of ASCII characters and the internal
1639 +                              representation is UCS4.  */
1640 +                           for (strcnt = 0; strcnt < c1; ++strcnt)
1641 +                             str[strcnt] = startp[1 + strcnt];
1642 +# endif
1643 +
1644 +                           table_size =
1645 +                             _NL_CURRENT_WORD (LC_COLLATE,
1646 +                                               _NL_COLLATE_SYMB_HASH_SIZEMB);
1647 +                           symb_table = (const int32_t *)
1648 +                             _NL_CURRENT (LC_COLLATE,
1649 +                                          _NL_COLLATE_SYMB_TABLEMB);
1650 +                           extra = (const unsigned char *)
1651 +                             _NL_CURRENT (LC_COLLATE,
1652 +                                          _NL_COLLATE_SYMB_EXTRAMB);
1653 +
1654 +                           /* Locate the character in the hashing table.  */
1655 +                           hash = elem_hash (str, c1);
1656 +
1657 +                           idx = 0;
1658 +                           elem = hash % table_size;
1659 +                           if (symb_table[2 * elem] != 0)
1660 +                             {
1661 +                               second = hash % (table_size - 2) + 1;
1662 +
1663 +                               do
1664 +                                 {
1665 +                                   /* First compare the hashing value.  */
1666 +                                   if (symb_table[2 * elem] == hash
1667 +                                       && (c1
1668 +                                           == extra[symb_table[2 * elem + 1]])
1669 +                                       && memcmp (str,
1670 +                                                  &extra[symb_table[2 * elem
1671 +                                                                    + 1]
1672 +                                                         + 1], c1) == 0)
1673 +                                     {
1674 +                                       /* Yep, this is the entry.  */
1675 +                                       idx = symb_table[2 * elem + 1];
1676 +                                       idx += 1 + extra[idx];
1677 +                                       break;
1678 +                                     }
1679 +
1680 +                                   /* Next entry.  */
1681 +                                   elem += second;
1682 +                                 }
1683 +                               while (symb_table[2 * elem] != 0);
1684 +                             }
1685 +
1686 +                           if (symb_table[2 * elem] != 0)
1687 +                             {
1688 +                               /* Compare the byte sequence but only if
1689 +                                  this is not part of a range.  */
1690 +# ifdef WIDE_CHAR_VERSION
1691 +                               int32_t *wextra;
1692 +
1693 +                               idx += 1 + extra[idx];
1694 +                               /* Adjust for the alignment.  */
1695 +                               idx = (idx + 3) & ~3;
1696 +
1697 +                               wextra = (int32_t *) &extra[idx + 4];
1698 +# endif
1699 +
1700 +                               if (! is_range)
1701 +                                 {
1702 +# ifdef WIDE_CHAR_VERSION
1703 +                                   for (c1 = 0;
1704 +                                        (int32_t) c1 < wextra[idx];
1705 +                                        ++c1)
1706 +                                     if (n[c1] != wextra[1 + c1])
1707 +                                       break;
1708 +
1709 +                                   if ((int32_t) c1 == wextra[idx])
1710 +                                     goto matched;
1711 +# else
1712 +                                   for (c1 = 0; c1 < extra[idx]; ++c1)
1713 +                                     if (n[c1] != extra[1 + c1])
1714 +                                       break;
1715 +
1716 +                                   if (c1 == extra[idx])
1717 +                                     goto matched;
1718 +# endif
1719 +                                 }
1720 +
1721 +                               /* Get the collation sequence value.  */
1722 +                               is_seqval = true;
1723 +# ifdef WIDE_CHAR_VERSION
1724 +                               cold = wextra[1 + wextra[idx]];
1725 +# else
1726 +                               /* Adjust for the alignment.  */
1727 +                               idx += 1 + extra[idx];
1728 +                               idx = (idx + 3) & ~4;
1729 +                               cold = *((int32_t *) &extra[idx]);
1730 +# endif
1731 +
1732 +                               c = *p++;
1733 +                             }
1734 +                           else if (c1 == 1)
1735 +                             {
1736 +                               /* No valid character.  Match it as a
1737 +                                  single byte.  */
1738 +                               if (!is_range && *n == str[0])
1739 +                                 goto matched;
1740 +
1741 +                               cold = str[0];
1742 +                               c = *p++;
1743 +                             }
1744 +                           else
1745 +                             return FNM_NOMATCH;
1746 +                         }
1747 +                     }
1748 +                   else
1749 +# undef str
1750 +#endif
1751 +                     {
1752 +                       c = FOLD (c);
1753 +                     normal_bracket:
1754 +
1755 +                       /* We have to handling the symbols differently in
1756 +                          ranges since then the collation sequence is
1757 +                          important.  */
1758 +                       is_range = (*p == L_('-') && p[1] != L_('\0')
1759 +                                   && p[1] != L_(']'));
1760 +
1761 +                       if (!is_range && c == fn)
1762 +                         goto matched;
1763 +
1764 +#if _LIBC
1765 +                       /* This is needed if we goto normal_bracket; from
1766 +                          outside of is_seqval's scope.  */
1767 +                       is_seqval = false;
1768 +#endif
1769 +
1770 +                       cold = c;
1771 +                       c = *p++;
1772 +                     }
1773 +
1774 +                   if (c == L_('-') && *p != L_(']'))
1775 +                     {
1776 +#if _LIBC
1777 +                       /* We have to find the collation sequence
1778 +                          value for C.  Collation sequence is nothing
1779 +                          we can regularly access.  The sequence
1780 +                          value is defined by the order in which the
1781 +                          definitions of the collation values for the
1782 +                          various characters appear in the source
1783 +                          file.  A strange concept, nowhere
1784 +                          documented.  */
1785 +                       uint32_t fcollseq;
1786 +                       uint32_t lcollseq;
1787 +                       UCHAR cend = *p++;
1788 +
1789 +# ifdef WIDE_CHAR_VERSION
1790 +                       /* Search in the `names' array for the characters.  */
1791 +                       fcollseq = __collseq_table_lookup (collseq, fn);
1792 +                       if (fcollseq == ~((uint32_t) 0))
1793 +                         /* XXX We don't know anything about the character
1794 +                            we are supposed to match.  This means we are
1795 +                            failing.  */
1796 +                         goto range_not_matched;
1797 +
1798 +                       if (is_seqval)
1799 +                         lcollseq = cold;
1800 +                       else
1801 +                         lcollseq = __collseq_table_lookup (collseq, cold);
1802 +# else
1803 +                       fcollseq = collseq[fn];
1804 +                       lcollseq = is_seqval ? cold : collseq[(UCHAR) cold];
1805 +# endif
1806 +
1807 +                       is_seqval = false;
1808 +                       if (cend == L_('[') && *p == L_('.'))
1809 +                         {
1810 +                           uint32_t nrules =
1811 +                             _NL_CURRENT_WORD (LC_COLLATE,
1812 +                                               _NL_COLLATE_NRULES);
1813 +                           const CHAR *startp = p;
1814 +                           size_t c1 = 0;
1815 +
1816 +                           while (1)
1817 +                             {
1818 +                               c = *++p;
1819 +                               if (c == L_('.') && p[1] == L_(']'))
1820 +                                 {
1821 +                                   p += 2;
1822 +                                   break;
1823 +                                 }
1824 +                               if (c == '\0')
1825 +                                 return FNM_NOMATCH;
1826 +                               ++c1;
1827 +                             }
1828 +
1829 +                           if (nrules == 0)
1830 +                             {
1831 +                               /* There are no names defined in the
1832 +                                  collation data.  Therefore we only
1833 +                                  accept the trivial names consisting
1834 +                                  of the character itself.  */
1835 +                               if (c1 != 1)
1836 +                                 return FNM_NOMATCH;
1837 +
1838 +                               cend = startp[1];
1839 +                             }
1840 +                           else
1841 +                             {
1842 +                               int32_t table_size;
1843 +                               const int32_t *symb_table;
1844 +# ifdef WIDE_CHAR_VERSION
1845 +                               char str[c1];
1846 +                               size_t strcnt;
1847 +# else
1848 +#  define str (startp + 1)
1849 +# endif
1850 +                               const unsigned char *extra;
1851 +                               int32_t idx;
1852 +                               int32_t elem;
1853 +                               int32_t second;
1854 +                               int32_t hash;
1855 +
1856 +# ifdef WIDE_CHAR_VERSION
1857 +                               /* We have to convert the name to a single-byte
1858 +                                  string.  This is possible since the names
1859 +                                  consist of ASCII characters and the internal
1860 +                                  representation is UCS4.  */
1861 +                               for (strcnt = 0; strcnt < c1; ++strcnt)
1862 +                                 str[strcnt] = startp[1 + strcnt];
1863 +# endif
1864 +
1865 +                               table_size =
1866 +                                 _NL_CURRENT_WORD (LC_COLLATE,
1867 +                                                   _NL_COLLATE_SYMB_HASH_SIZEMB);
1868 +                               symb_table = (const int32_t *)
1869 +                                 _NL_CURRENT (LC_COLLATE,
1870 +                                              _NL_COLLATE_SYMB_TABLEMB);
1871 +                               extra = (const unsigned char *)
1872 +                                 _NL_CURRENT (LC_COLLATE,
1873 +                                              _NL_COLLATE_SYMB_EXTRAMB);
1874 +
1875 +                               /* Locate the character in the hashing
1876 +                                   table.  */
1877 +                               hash = elem_hash (str, c1);
1878 +
1879 +                               idx = 0;
1880 +                               elem = hash % table_size;
1881 +                               if (symb_table[2 * elem] != 0)
1882 +                                 {
1883 +                                   second = hash % (table_size - 2) + 1;
1884 +
1885 +                                   do
1886 +                                     {
1887 +                                       /* First compare the hashing value.  */
1888 +                                       if (symb_table[2 * elem] == hash
1889 +                                           && (c1
1890 +                                               == extra[symb_table[2 * elem + 1]])
1891 +                                           && memcmp (str,
1892 +                                                      &extra[symb_table[2 * elem + 1]
1893 +                                                             + 1], c1) == 0)
1894 +                                         {
1895 +                                           /* Yep, this is the entry.  */
1896 +                                           idx = symb_table[2 * elem + 1];
1897 +                                           idx += 1 + extra[idx];
1898 +                                           break;
1899 +                                         }
1900 +
1901 +                                       /* Next entry.  */
1902 +                                       elem += second;
1903 +                                     }
1904 +                                   while (symb_table[2 * elem] != 0);
1905 +                                 }
1906 +
1907 +                               if (symb_table[2 * elem] != 0)
1908 +                                 {
1909 +                                   /* Compare the byte sequence but only if
1910 +                                      this is not part of a range.  */
1911 +# ifdef WIDE_CHAR_VERSION
1912 +                                   int32_t *wextra;
1913 +
1914 +                                   idx += 1 + extra[idx];
1915 +                                   /* Adjust for the alignment.  */
1916 +                                   idx = (idx + 3) & ~4;
1917 +
1918 +                                   wextra = (int32_t *) &extra[idx + 4];
1919 +# endif
1920 +                                   /* Get the collation sequence value.  */
1921 +                                   is_seqval = true;
1922 +# ifdef WIDE_CHAR_VERSION
1923 +                                   cend = wextra[1 + wextra[idx]];
1924 +# else
1925 +                                   /* Adjust for the alignment.  */
1926 +                                   idx += 1 + extra[idx];
1927 +                                   idx = (idx + 3) & ~4;
1928 +                                   cend = *((int32_t *) &extra[idx]);
1929 +# endif
1930 +                                 }
1931 +                               else if (symb_table[2 * elem] != 0 && c1 == 1)
1932 +                                 {
1933 +                                   cend = str[0];
1934 +                                   c = *p++;
1935 +                                 }
1936 +                               else
1937 +                                 return FNM_NOMATCH;
1938 +                             }
1939 +# undef str
1940 +                         }
1941 +                       else
1942 +                         {
1943 +                           if (!(flags & FNM_NOESCAPE) && cend == L_('\\'))
1944 +                             cend = *p++;
1945 +                           if (cend == L_('\0'))
1946 +                             return FNM_NOMATCH;
1947 +                           cend = FOLD (cend);
1948 +                         }
1949 +
1950 +                       /* XXX It is not entirely clear to me how to handle
1951 +                          characters which are not mentioned in the
1952 +                          collation specification.  */
1953 +                       if (
1954 +# ifdef WIDE_CHAR_VERSION
1955 +                           lcollseq == 0xffffffff ||
1956 +# endif
1957 +                           lcollseq <= fcollseq)
1958 +                         {
1959 +                           /* We have to look at the upper bound.  */
1960 +                           uint32_t hcollseq;
1961 +
1962 +                           if (is_seqval)
1963 +                             hcollseq = cend;
1964 +                           else
1965 +                             {
1966 +# ifdef WIDE_CHAR_VERSION
1967 +                               hcollseq =
1968 +                                 __collseq_table_lookup (collseq, cend);
1969 +                               if (hcollseq == ~((uint32_t) 0))
1970 +                                 {
1971 +                                   /* Hum, no information about the upper
1972 +                                      bound.  The matching succeeds if the
1973 +                                      lower bound is matched exactly.  */
1974 +                                   if (lcollseq != fcollseq)
1975 +                                     goto range_not_matched;
1976 +
1977 +                                   goto matched;
1978 +                                 }
1979 +# else
1980 +                               hcollseq = collseq[cend];
1981 +# endif
1982 +                             }
1983 +
1984 +                           if (lcollseq <= hcollseq && fcollseq <= hcollseq)
1985 +                             goto matched;
1986 +                         }
1987 +# ifdef WIDE_CHAR_VERSION
1988 +                     range_not_matched:
1989 +# endif
1990 +#else
1991 +                       /* We use a boring value comparison of the character
1992 +                          values.  This is better than comparing using
1993 +                          `strcoll' since the latter would have surprising
1994 +                          and sometimes fatal consequences.  */
1995 +                       UCHAR cend = *p++;
1996 +
1997 +                       if (!(flags & FNM_NOESCAPE) && cend == L_('\\'))
1998 +                         cend = *p++;
1999 +                       if (cend == L_('\0'))
2000 +                         return FNM_NOMATCH;
2001 +
2002 +                       /* It is a range.  */
2003 +                       if (cold <= fn && fn <= cend)
2004 +                         goto matched;
2005 +#endif
2006 +
2007 +                       c = *p++;
2008 +                     }
2009 +                 }
2010 +
2011 +               if (c == L_(']'))
2012 +                 break;
2013 +             }
2014 +
2015 +           if (!not)
2016 +             return FNM_NOMATCH;
2017 +           break;
2018 +
2019 +         matched:
2020 +           /* Skip the rest of the [...] that already matched.  */
2021 +           do
2022 +             {
2023 +             ignore_next:
2024 +               c = *p++;
2025 +
2026 +               if (c == L_('\0'))
2027 +                 /* [... (unterminated) loses.  */
2028 +                 return FNM_NOMATCH;
2029 +
2030 +               if (!(flags & FNM_NOESCAPE) && c == L_('\\'))
2031 +                 {
2032 +                   if (*p == L_('\0'))
2033 +                     return FNM_NOMATCH;
2034 +                   /* XXX 1003.2d11 is unclear if this is right.  */
2035 +                   ++p;
2036 +                 }
2037 +               else if (c == L_('[') && *p == L_(':'))
2038 +                 {
2039 +                   int c1 = 0;
2040 +                   const CHAR *startp = p;
2041 +
2042 +                   while (1)
2043 +                     {
2044 +                       c = *++p;
2045 +                       if (++c1 == CHAR_CLASS_MAX_LENGTH)
2046 +                         return FNM_NOMATCH;
2047 +
2048 +                       if (*p == L_(':') && p[1] == L_(']'))
2049 +                         break;
2050 +
2051 +                       if (c < L_('a') || c >= L_('z'))
2052 +                         {
2053 +                           p = startp;
2054 +                           goto ignore_next;
2055 +                         }
2056 +                     }
2057 +                   p += 2;
2058 +                   c = *p++;
2059 +                 }
2060 +               else if (c == L_('[') && *p == L_('='))
2061 +                 {
2062 +                   c = *++p;
2063 +                   if (c == L_('\0'))
2064 +                     return FNM_NOMATCH;
2065 +                   c = *++p;
2066 +                   if (c != L_('=') || p[1] != L_(']'))
2067 +                     return FNM_NOMATCH;
2068 +                   p += 2;
2069 +                   c = *p++;
2070 +                 }
2071 +               else if (c == L_('[') && *p == L_('.'))
2072 +                 {
2073 +                   ++p;
2074 +                   while (1)
2075 +                     {
2076 +                       c = *++p;
2077 +                       if (c == '\0')
2078 +                         return FNM_NOMATCH;
2079 +
2080 +                       if (*p == L_('.') && p[1] == L_(']'))
2081 +                         break;
2082 +                     }
2083 +                   p += 2;
2084 +                   c = *p++;
2085 +                 }
2086 +             }
2087 +           while (c != L_(']'));
2088 +           if (not)
2089 +             return FNM_NOMATCH;
2090 +         }
2091 +         break;
2092 +
2093 +       case L_('+'):
2094 +       case L_('@'):
2095 +       case L_('!'):
2096 +         if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(')
2097 +           {
2098 +             int res;
2099 +
2100 +             res = EXT (c, p, n, string_end, no_leading_period, flags);
2101 +             if (res != -1)
2102 +               return res;
2103 +           }
2104 +         goto normal_match;
2105 +
2106 +       case L_('/'):
2107 +         if (NO_LEADING_PERIOD (flags))
2108 +           {
2109 +             if (n == string_end || c != (UCHAR) *n)
2110 +               return FNM_NOMATCH;
2111 +
2112 +             new_no_leading_period = true;
2113 +             break;
2114 +           }
2115 +         /* FALLTHROUGH */
2116 +       default:
2117 +       normal_match:
2118 +         if (n == string_end || c != FOLD ((UCHAR) *n))
2119 +           return FNM_NOMATCH;
2120 +       }
2121 +
2122 +      no_leading_period = new_no_leading_period;
2123 +      ++n;
2124 +    }
2125 +
2126 +  if (n == string_end)
2127 +    return 0;
2128 +
2129 +  if ((flags & FNM_LEADING_DIR) && n != string_end && *n == L_('/'))
2130 +    /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz".  */
2131 +    return 0;
2132 +
2133 +  return FNM_NOMATCH;
2134 +}
2135 +
2136 +
2137 +static const CHAR *
2138 +internal_function
2139 +END (const CHAR *pattern)
2140 +{
2141 +  const CHAR *p = pattern;
2142 +
2143 +  while (1)
2144 +    if (*++p == L_('\0'))
2145 +      /* This is an invalid pattern.  */
2146 +      return pattern;
2147 +    else if (*p == L_('['))
2148 +      {
2149 +       /* Handle brackets special.  */
2150 +       if (posixly_correct == 0)
2151 +         posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
2152 +
2153 +       /* Skip the not sign.  We have to recognize it because of a possibly
2154 +          following ']'.  */
2155 +       if (*++p == L_('!') || (posixly_correct < 0 && *p == L_('^')))
2156 +         ++p;
2157 +       /* A leading ']' is recognized as such.  */
2158 +       if (*p == L_(']'))
2159 +         ++p;
2160 +       /* Skip over all characters of the list.  */
2161 +       while (*p != L_(']'))
2162 +         if (*p++ == L_('\0'))
2163 +           /* This is no valid pattern.  */
2164 +           return pattern;
2165 +      }
2166 +    else if ((*p == L_('?') || *p == L_('*') || *p == L_('+') || *p == L_('@')
2167 +             || *p == L_('!')) && p[1] == L_('('))
2168 +      p = END (p + 1);
2169 +    else if (*p == L_(')'))
2170 +      break;
2171 +
2172 +  return p + 1;
2173 +}
2174 +
2175 +
2176 +static int
2177 +internal_function
2178 +EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
2179 +     bool no_leading_period, int flags)
2180 +{
2181 +  const CHAR *startp;
2182 +  size_t level;
2183 +  struct patternlist
2184 +  {
2185 +    struct patternlist *next;
2186 +    CHAR str[1];
2187 +  } *list = NULL;
2188 +  struct patternlist **lastp = &list;
2189 +  size_t pattern_len = STRLEN (pattern);
2190 +  const CHAR *p;
2191 +  const CHAR *rs;
2192 +  enum { ALLOCA_LIMIT = 8000 };
2193 +
2194 +  /* Parse the pattern.  Store the individual parts in the list.  */
2195 +  level = 0;
2196 +  for (startp = p = pattern + 1; ; ++p)
2197 +    if (*p == L_('\0'))
2198 +      /* This is an invalid pattern.  */
2199 +      return -1;
2200 +    else if (*p == L_('['))
2201 +      {
2202 +       /* Handle brackets special.  */
2203 +       if (posixly_correct == 0)
2204 +         posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
2205 +
2206 +       /* Skip the not sign.  We have to recognize it because of a possibly
2207 +          following ']'.  */
2208 +       if (*++p == L_('!') || (posixly_correct < 0 && *p == L_('^')))
2209 +         ++p;
2210 +       /* A leading ']' is recognized as such.  */
2211 +       if (*p == L_(']'))
2212 +         ++p;
2213 +       /* Skip over all characters of the list.  */
2214 +       while (*p != L_(']'))
2215 +         if (*p++ == L_('\0'))
2216 +           /* This is no valid pattern.  */
2217 +           return -1;
2218 +      }
2219 +    else if ((*p == L_('?') || *p == L_('*') || *p == L_('+') || *p == L_('@')
2220 +             || *p == L_('!')) && p[1] == L_('('))
2221 +      /* Remember the nesting level.  */
2222 +      ++level;
2223 +    else if (*p == L_(')'))
2224 +      {
2225 +       if (level-- == 0)
2226 +         {
2227 +           /* This means we found the end of the pattern.  */
2228 +#define NEW_PATTERN \
2229 +           struct patternlist *newp;                                         \
2230 +           size_t plen;                                                      \
2231 +           size_t plensize;                                                  \
2232 +           size_t newpsize;                                                  \
2233 +                                                                             \
2234 +           plen = (opt == L_('?') || opt == L_('@')                          \
2235 +                   ? pattern_len                                             \
2236 +                   : p - startp + 1);                                        \
2237 +           plensize = plen * sizeof (CHAR);                                  \
2238 +           newpsize = offsetof (struct patternlist, str) + plensize;         \
2239 +           if ((size_t) -1 / sizeof (CHAR) < plen                            \
2240 +               || newpsize < offsetof (struct patternlist, str)              \
2241 +               || ALLOCA_LIMIT <= newpsize)                                  \
2242 +             return -1;                                                      \
2243 +           newp = (struct patternlist *) alloca (newpsize);                  \
2244 +           *((CHAR *) MEMPCPY (newp->str, startp, p - startp)) = L_('\0');    \
2245 +           newp->next = NULL;                                                \
2246 +           *lastp = newp;                                                    \
2247 +           lastp = &newp->next
2248 +           NEW_PATTERN;
2249 +           break;
2250 +         }
2251 +      }
2252 +    else if (*p == L_('|'))
2253 +      {
2254 +       if (level == 0)
2255 +         {
2256 +           NEW_PATTERN;
2257 +           startp = p + 1;
2258 +         }
2259 +      }
2260 +  assert (list != NULL);
2261 +  assert (p[-1] == L_(')'));
2262 +#undef NEW_PATTERN
2263 +
2264 +  switch (opt)
2265 +    {
2266 +    case L_('*'):
2267 +      if (FCT (p, string, string_end, no_leading_period, flags) == 0)
2268 +       return 0;
2269 +      /* FALLTHROUGH */
2270 +
2271 +    case L_('+'):
2272 +      do
2273 +       {
2274 +         for (rs = string; rs <= string_end; ++rs)
2275 +           /* First match the prefix with the current pattern with the
2276 +              current pattern.  */
2277 +           if (FCT (list->str, string, rs, no_leading_period,
2278 +                    flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0
2279 +               /* This was successful.  Now match the rest with the rest
2280 +                  of the pattern.  */
2281 +               && (FCT (p, rs, string_end,
2282 +                        rs == string
2283 +                        ? no_leading_period
2284 +                        : rs[-1] == '/' && NO_LEADING_PERIOD (flags),
2285 +                        flags & FNM_FILE_NAME
2286 +                        ? flags : flags & ~FNM_PERIOD) == 0
2287 +                   /* This didn't work.  Try the whole pattern.  */
2288 +                   || (rs != string
2289 +                       && FCT (pattern - 1, rs, string_end,
2290 +                               rs == string
2291 +                               ? no_leading_period
2292 +                               : rs[-1] == '/' && NO_LEADING_PERIOD (flags),
2293 +                               flags & FNM_FILE_NAME
2294 +                               ? flags : flags & ~FNM_PERIOD) == 0)))
2295 +             /* It worked.  Signal success.  */
2296 +             return 0;
2297 +       }
2298 +      while ((list = list->next) != NULL);
2299 +
2300 +      /* None of the patterns lead to a match.  */
2301 +      return FNM_NOMATCH;
2302 +
2303 +    case L_('?'):
2304 +      if (FCT (p, string, string_end, no_leading_period, flags) == 0)
2305 +       return 0;
2306 +      /* FALLTHROUGH */
2307 +
2308 +    case L_('@'):
2309 +      do
2310 +       /* I cannot believe it but `strcat' is actually acceptable
2311 +          here.  Match the entire string with the prefix from the
2312 +          pattern list and the rest of the pattern following the
2313 +          pattern list.  */
2314 +       if (FCT (STRCAT (list->str, p), string, string_end,
2315 +                no_leading_period,
2316 +                flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0)
2317 +         /* It worked.  Signal success.  */
2318 +         return 0;
2319 +      while ((list = list->next) != NULL);
2320 +
2321 +      /* None of the patterns lead to a match.  */
2322 +      return FNM_NOMATCH;
2323 +
2324 +    case L_('!'):
2325 +      for (rs = string; rs <= string_end; ++rs)
2326 +       {
2327 +         struct patternlist *runp;
2328 +
2329 +         for (runp = list; runp != NULL; runp = runp->next)
2330 +           if (FCT (runp->str, string, rs,  no_leading_period,
2331 +                    flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0)
2332 +             break;
2333 +
2334 +         /* If none of the patterns matched see whether the rest does.  */
2335 +         if (runp == NULL
2336 +             && (FCT (p, rs, string_end,
2337 +                      rs == string
2338 +                      ? no_leading_period
2339 +                      : rs[-1] == '/' && NO_LEADING_PERIOD (flags),
2340 +                      flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD)
2341 +                 == 0))
2342 +           /* This is successful.  */
2343 +           return 0;
2344 +       }
2345 +
2346 +      /* None of the patterns together with the rest of the pattern
2347 +        lead to a match.  */
2348 +      return FNM_NOMATCH;
2349 +
2350 +    default:
2351 +      assert (! "Invalid extended matching operator");
2352 +      break;
2353 +    }
2354 +
2355 +  return -1;
2356 +}
2357 +
2358 +
2359 +#undef FOLD
2360 +#undef CHAR
2361 +#undef UCHAR
2362 +#undef INT
2363 +#undef FCT
2364 +#undef EXT
2365 +#undef END
2366 +#undef MEMPCPY
2367 +#undef MEMCHR
2368 +#undef STRCOLL
2369 +#undef STRLEN
2370 +#undef STRCAT
2371 +#undef L_
2372 +#undef BTOWC
2373 diff -urN popt-for-windows/lib/getlogin_r.c popt-for-windows-gnulib/lib/getlogin_r.c
2374 --- popt-for-windows/lib/getlogin_r.c   1970-01-01 01:00:00.000000000 +0100
2375 +++ popt-for-windows-gnulib/lib/getlogin_r.c    2008-10-25 15:17:05.000000000 +0100
2376 @@ -0,0 +1,56 @@
2377 +/* Provide a working getlogin_r for systems which lack it.
2378 +
2379 +   Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
2380 +
2381 +   This program is free software; you can redistribute it and/or modify
2382 +   it under the terms of the GNU General Public License as published by
2383 +   the Free Software Foundation; either version 3, or (at your option)
2384 +   any later version.
2385 +
2386 +   This program is distributed in the hope that it will be useful,
2387 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
2388 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2389 +   GNU General Public License for more details.
2390 +
2391 +   You should have received a copy of the GNU General Public License
2392 +   along with this program; if not, write to the Free Software Foundation,
2393 +   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
2394 +
2395 +/* written by Paul Eggert and Derek Price */
2396 +
2397 +#include <config.h>
2398 +
2399 +/* Specification.  */
2400 +#include <unistd.h>
2401 +
2402 +#include <errno.h>
2403 +#include <string.h>
2404 +
2405 +#if !HAVE_DECL_GETLOGIN
2406 +char *getlogin (void);
2407 +#endif
2408 +
2409 +/* See unistd.in.h for documentation.  */
2410 +int
2411 +getlogin_r (char *name, size_t size)
2412 +{
2413 +  char *n;
2414 +  size_t nlen;
2415 +
2416 +  errno = 0;
2417 +  n = getlogin ();
2418 +
2419 +  /* A system function like getlogin_r is never supposed to set errno
2420 +     to zero, so make sure errno is nonzero here.  ENOENT is a
2421 +     reasonable errno value if getlogin returns NULL.  */
2422 +  if (!errno)
2423 +    errno = ENOENT;
2424 +
2425 +  if (!n)
2426 +    return errno;
2427 +  nlen = strlen (n);
2428 +  if (size <= nlen)
2429 +    return ERANGE;
2430 +  memcpy (name, n, nlen + 1);
2431 +  return 0;
2432 +}
2433 diff -urN popt-for-windows/lib/glob.c popt-for-windows-gnulib/lib/glob.c
2434 --- popt-for-windows/lib/glob.c 1970-01-01 01:00:00.000000000 +0100
2435 +++ popt-for-windows-gnulib/lib/glob.c  2008-10-25 15:17:05.000000000 +0100
2436 @@ -0,0 +1,1548 @@
2437 +/* Copyright (C) 1991-2002, 2003, 2004, 2005, 2006, 2007, 2008
2438 +   Free Software Foundation, Inc.
2439 +   This file is part of the GNU C Library.
2440 +
2441 +   The GNU C Library is free software; you can redistribute it and/or
2442 +   modify it under the terms of the GNU General Public
2443 +   License as published by the Free Software Foundation; either
2444 +   version 3 of the License, or (at your option) any later version.
2445 +
2446 +   The GNU C Library is distributed in the hope that it will be useful,
2447 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
2448 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2449 +   Lesser General Public License for more details.
2450 +
2451 +   You should have received a copy of the GNU General Public
2452 +   License along with the GNU C Library; if not, write to the Free
2453 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
2454 +   02111-1307 USA.  */
2455 +
2456 +#ifndef _LIBC
2457 +# include <config.h>
2458 +#endif
2459 +
2460 +#include <glob.h>
2461 +
2462 +#include <errno.h>
2463 +#include <sys/types.h>
2464 +#include <sys/stat.h>
2465 +#include <stddef.h>
2466 +
2467 +/* Outcomment the following line for production quality code.  */
2468 +/* #define NDEBUG 1 */
2469 +#include <assert.h>
2470 +
2471 +#include <stdbool.h>
2472 +
2473 +#include <stdio.h>             /* Needed on stupid SunOS for assert.  */
2474 +
2475 +#if !defined _LIBC || !defined GLOB_ONLY_P
2476 +
2477 +#include <unistd.h>
2478 +#if !defined POSIX && defined _POSIX_VERSION
2479 +# define POSIX
2480 +#endif
2481 +
2482 +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
2483 +# define WINDOWS32
2484 +#endif
2485 +
2486 +#ifndef WINDOWS32
2487 +# include <pwd.h>
2488 +#endif
2489 +
2490 +#include <errno.h>
2491 +#ifndef __set_errno
2492 +# define __set_errno(val) errno = (val)
2493 +#endif
2494 +
2495 +#include <dirent.h>
2496 +
2497 +
2498 +/* In GNU systems, <dirent.h> defines this macro for us.  */
2499 +#ifndef _D_EXACT_NAMLEN
2500 +# define _D_EXACT_NAMLEN(dirent) strlen ((dirent)->d_name)
2501 +#endif
2502 +
2503 +/* When used in the GNU libc the symbol _DIRENT_HAVE_D_TYPE is available
2504 +   if the `d_type' member for `struct dirent' is available.
2505 +   HAVE_STRUCT_DIRENT_D_TYPE plays the same role in GNULIB.  */
2506 +#if defined _DIRENT_HAVE_D_TYPE || defined HAVE_STRUCT_DIRENT_D_TYPE
2507 +/* True if the directory entry D must be of type T.  */
2508 +# define DIRENT_MUST_BE(d, t)  ((d)->d_type == (t))
2509 +
2510 +/* True if the directory entry D might be a symbolic link.  */
2511 +# define DIRENT_MIGHT_BE_SYMLINK(d) \
2512 +    ((d)->d_type == DT_UNKNOWN || (d)->d_type == DT_LNK)
2513 +
2514 +/* True if the directory entry D might be a directory.  */
2515 +# define DIRENT_MIGHT_BE_DIR(d)         \
2516 +    ((d)->d_type == DT_DIR || DIRENT_MIGHT_BE_SYMLINK (d))
2517 +
2518 +#else /* !HAVE_D_TYPE */
2519 +# define DIRENT_MUST_BE(d, t)          false
2520 +# define DIRENT_MIGHT_BE_SYMLINK(d)    true
2521 +# define DIRENT_MIGHT_BE_DIR(d)                true
2522 +#endif /* HAVE_D_TYPE */
2523 +
2524 +/* If the system has the `struct dirent64' type we use it internally.  */
2525 +#if defined _LIBC && !defined COMPILE_GLOB64
2526 +# if (defined POSIX || defined WINDOWS32) && !defined __GNU_LIBRARY__
2527 +#  define CONVERT_D_INO(d64, d32)
2528 +# else
2529 +#  define CONVERT_D_INO(d64, d32) \
2530 +  (d64)->d_ino = (d32)->d_ino;
2531 +# endif
2532 +
2533 +# ifdef _DIRENT_HAVE_D_TYPE
2534 +#  define CONVERT_D_TYPE(d64, d32) \
2535 +  (d64)->d_type = (d32)->d_type;
2536 +# else
2537 +#  define CONVERT_D_TYPE(d64, d32)
2538 +# endif
2539 +
2540 +# define CONVERT_DIRENT_DIRENT64(d64, d32) \
2541 +  memcpy ((d64)->d_name, (d32)->d_name, _D_EXACT_NAMLEN (d32) + 1);          \
2542 +  CONVERT_D_INO (d64, d32)                                                   \
2543 +  CONVERT_D_TYPE (d64, d32)
2544 +#endif
2545 +
2546 +
2547 +#if (defined POSIX || defined WINDOWS32) && !defined __GNU_LIBRARY__
2548 +/* Posix does not require that the d_ino field be present, and some
2549 +   systems do not provide it. */
2550 +# define REAL_DIR_ENTRY(dp) 1
2551 +#else
2552 +# define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
2553 +#endif /* POSIX */
2554 +
2555 +#include <stdlib.h>
2556 +#include <string.h>
2557 +
2558 +/* NAME_MAX is usually defined in <dirent.h> or <limits.h>.  */
2559 +#include <limits.h>
2560 +#ifndef NAME_MAX
2561 +# define NAME_MAX (sizeof (((struct dirent *) 0)->d_name))
2562 +#endif
2563 +
2564 +#include <alloca.h>
2565 +
2566 +#ifdef _LIBC
2567 +# undef strdup
2568 +# define strdup(str) __strdup (str)
2569 +# define sysconf(id) __sysconf (id)
2570 +# define closedir(dir) __closedir (dir)
2571 +# define opendir(name) __opendir (name)
2572 +# define readdir(str) __readdir64 (str)
2573 +# define getpwnam_r(name, bufp, buf, len, res) \
2574 +   __getpwnam_r (name, bufp, buf, len, res)
2575 +# ifndef __stat64
2576 +#  define __stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf)
2577 +# endif
2578 +# define struct_stat64         struct stat64
2579 +#else /* !_LIBC */
2580 +# define __stat64(fname, buf)  stat (fname, buf)
2581 +# define __fxstatat64(_, d, f, st, flag) fstatat (d, f, st, flag)
2582 +# define struct_stat64         struct stat
2583 +# define __stat(fname, buf)    stat (fname, buf)
2584 +# define __alloca              alloca
2585 +# define __readdir             readdir
2586 +# define __readdir64           readdir64
2587 +# define __glob_pattern_p      glob_pattern_p
2588 +#endif /* _LIBC */
2589 +
2590 +#include <fnmatch.h>
2591 +
2592 +#ifdef _SC_GETPW_R_SIZE_MAX
2593 +# define GETPW_R_SIZE_MAX()    sysconf (_SC_GETPW_R_SIZE_MAX)
2594 +#else
2595 +# define GETPW_R_SIZE_MAX()    (-1)
2596 +#endif
2597 +#ifdef _SC_LOGIN_NAME_MAX
2598 +# define GET_LOGIN_NAME_MAX()  sysconf (_SC_LOGIN_NAME_MAX)
2599 +#else
2600 +# define GET_LOGIN_NAME_MAX()  (-1)
2601 +#endif
2602 +\f
2603 +static const char *next_brace_sub (const char *begin, int flags) __THROW;
2604 +
2605 +#endif /* !defined _LIBC || !defined GLOB_ONLY_P */
2606 +
2607 +#ifndef attribute_hidden
2608 +# define attribute_hidden
2609 +#endif
2610 +
2611 +#ifndef __attribute_noinline__
2612 +# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 1)
2613 +#  define __attribute_noinline__ /* Ignore */
2614 +#else
2615 +#  define __attribute_noinline__ __attribute__ ((__noinline__))
2616 +# endif
2617 +#endif
2618 +
2619 +#if ! defined __builtin_expect && __GNUC__ < 3
2620 +# define __builtin_expect(expr, expected) (expr)
2621 +#endif
2622 +
2623 +#ifndef _LIBC
2624 +/* The results of opendir() in this file are not used with dirfd and fchdir,
2625 +   therefore save some unnecessary work in fchdir.c.  */
2626 +# undef opendir
2627 +# undef closedir
2628 +
2629 +# if HAVE_ALLOCA
2630 +/* The OS usually guarantees only one guard page at the bottom of the stack,
2631 +   and a page size can be as small as 4096 bytes.  So we cannot safely
2632 +   allocate anything larger than 4096 bytes.  Also care for the possibility
2633 +   of a few compiler-allocated temporary stack slots.  */
2634 +#  define __libc_use_alloca(n) ((n) < 4032)
2635 +# else
2636 +/* alloca is implemented with malloc, so just use malloc.  */
2637 +#  define __libc_use_alloca(n) 0
2638 +# endif
2639 +#endif
2640 +
2641 +static int glob_in_dir (const char *pattern, const char *directory,
2642 +                       int flags, int (*errfunc) (const char *, int),
2643 +                       glob_t *pglob);
2644 +extern int __glob_pattern_type (const char *pattern, int quote)
2645 +    attribute_hidden;
2646 +
2647 +#if !defined _LIBC || !defined GLOB_ONLY_P
2648 +static int prefix_array (const char *prefix, char **array, size_t n) __THROW;
2649 +static int collated_compare (const void *, const void *) __THROW;
2650 +
2651 +
2652 +/* Find the end of the sub-pattern in a brace expression.  */
2653 +static const char *
2654 +next_brace_sub (const char *cp, int flags)
2655 +{
2656 +  unsigned int depth = 0;
2657 +  while (*cp != '\0')
2658 +    if ((flags & GLOB_NOESCAPE) == 0 && *cp == '\\')
2659 +      {
2660 +       if (*++cp == '\0')
2661 +         break;
2662 +       ++cp;
2663 +      }
2664 +    else
2665 +      {
2666 +       if ((*cp == '}' && depth-- == 0) || (*cp == ',' && depth == 0))
2667 +         break;
2668 +
2669 +       if (*cp++ == '{')
2670 +         depth++;
2671 +      }
2672 +
2673 +  return *cp != '\0' ? cp : NULL;
2674 +}
2675 +
2676 +#endif /* !defined _LIBC || !defined GLOB_ONLY_P */
2677 +
2678 +/* Do glob searching for PATTERN, placing results in PGLOB.
2679 +   The bits defined above may be set in FLAGS.
2680 +   If a directory cannot be opened or read and ERRFUNC is not nil,
2681 +   it is called with the pathname that caused the error, and the
2682 +   `errno' value from the failing call; if it returns non-zero
2683 +   `glob' returns GLOB_ABORTED; if it returns zero, the error is ignored.
2684 +   If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
2685 +   Otherwise, `glob' returns zero.  */
2686 +int
2687 +#ifdef GLOB_ATTRIBUTE
2688 +GLOB_ATTRIBUTE
2689 +#endif
2690 +glob (pattern, flags, errfunc, pglob)
2691 +     const char * restrict pattern;
2692 +     int flags;
2693 +     int (*errfunc) (const char *, int);
2694 +     glob_t * restrict pglob;
2695 +{
2696 +  const char *filename;
2697 +  const char *dirname;
2698 +  size_t dirlen;
2699 +  int status;
2700 +  size_t oldcount;
2701 +  int meta;
2702 +  int dirname_modified;
2703 +  glob_t dirs;
2704 +
2705 +  if (pattern == NULL || pglob == NULL || (flags & ~__GLOB_FLAGS) != 0)
2706 +    {
2707 +      __set_errno (EINVAL);
2708 +      return -1;
2709 +    }
2710 +
2711 +  if (!(flags & GLOB_DOOFFS))
2712 +    /* Have to do this so `globfree' knows where to start freeing.  It
2713 +       also makes all the code that uses gl_offs simpler. */
2714 +    pglob->gl_offs = 0;
2715 +
2716 +  if (flags & GLOB_BRACE)
2717 +    {
2718 +      const char *begin;
2719 +
2720 +      if (flags & GLOB_NOESCAPE)
2721 +       begin = strchr (pattern, '{');
2722 +      else
2723 +       {
2724 +         begin = pattern;
2725 +         while (1)
2726 +           {
2727 +             if (*begin == '\0')
2728 +               {
2729 +                 begin = NULL;
2730 +                 break;
2731 +               }
2732 +
2733 +             if (*begin == '\\' && begin[1] != '\0')
2734 +               ++begin;
2735 +             else if (*begin == '{')
2736 +               break;
2737 +
2738 +             ++begin;
2739 +           }
2740 +       }
2741 +
2742 +      if (begin != NULL)
2743 +       {
2744 +         /* Allocate working buffer large enough for our work.  Note that
2745 +           we have at least an opening and closing brace.  */
2746 +         size_t firstc;
2747 +         char *alt_start;
2748 +         const char *p;
2749 +         const char *next;
2750 +         const char *rest;
2751 +         size_t rest_len;
2752 +#ifdef __GNUC__
2753 +         char onealt[strlen (pattern) - 1];
2754 +#else
2755 +         char *onealt = malloc (strlen (pattern) - 1);
2756 +         if (onealt == NULL)
2757 +           {
2758 +             if (!(flags & GLOB_APPEND))
2759 +               {
2760 +                 pglob->gl_pathc = 0;
2761 +                 pglob->gl_pathv = NULL;
2762 +               }
2763 +             return GLOB_NOSPACE;
2764 +           }
2765 +#endif
2766 +
2767 +         /* We know the prefix for all sub-patterns.  */
2768 +         alt_start = mempcpy (onealt, pattern, begin - pattern);
2769 +
2770 +         /* Find the first sub-pattern and at the same time find the
2771 +            rest after the closing brace.  */
2772 +         next = next_brace_sub (begin + 1, flags);
2773 +         if (next == NULL)
2774 +           {
2775 +             /* It is an invalid expression.  */
2776 +#ifndef __GNUC__
2777 +             free (onealt);
2778 +#endif
2779 +             return glob (pattern, flags & ~GLOB_BRACE, errfunc, pglob);
2780 +           }
2781 +
2782 +         /* Now find the end of the whole brace expression.  */
2783 +         rest = next;
2784 +         while (*rest != '}')
2785 +           {
2786 +             rest = next_brace_sub (rest + 1, flags);
2787 +             if (rest == NULL)
2788 +               {
2789 +                 /* It is an invalid expression.  */
2790 +#ifndef __GNUC__
2791 +                 free (onealt);
2792 +#endif
2793 +                 return glob (pattern, flags & ~GLOB_BRACE, errfunc, pglob);
2794 +               }
2795 +           }
2796 +         /* Please note that we now can be sure the brace expression
2797 +            is well-formed.  */
2798 +         rest_len = strlen (++rest) + 1;
2799 +
2800 +         /* We have a brace expression.  BEGIN points to the opening {,
2801 +            NEXT points past the terminator of the first element, and END
2802 +            points past the final }.  We will accumulate result names from
2803 +            recursive runs for each brace alternative in the buffer using
2804 +            GLOB_APPEND.  */
2805 +
2806 +         if (!(flags & GLOB_APPEND))
2807 +           {
2808 +             /* This call is to set a new vector, so clear out the
2809 +                vector so we can append to it.  */
2810 +             pglob->gl_pathc = 0;
2811 +             pglob->gl_pathv = NULL;
2812 +           }
2813 +         firstc = pglob->gl_pathc;
2814 +
2815 +         p = begin + 1;
2816 +         while (1)
2817 +           {
2818 +             int result;
2819 +
2820 +             /* Construct the new glob expression.  */
2821 +             mempcpy (mempcpy (alt_start, p, next - p), rest, rest_len);
2822 +
2823 +             result = glob (onealt,
2824 +                            ((flags & ~(GLOB_NOCHECK | GLOB_NOMAGIC))
2825 +                             | GLOB_APPEND), errfunc, pglob);
2826 +
2827 +             /* If we got an error, return it.  */
2828 +             if (result && result != GLOB_NOMATCH)
2829 +               {
2830 +#ifndef __GNUC__
2831 +                 free (onealt);
2832 +#endif
2833 +                 if (!(flags & GLOB_APPEND))
2834 +                   {
2835 +                     globfree (pglob);
2836 +                     pglob->gl_pathc = 0;
2837 +                   }
2838 +                 return result;
2839 +               }
2840 +
2841 +             if (*next == '}')
2842 +               /* We saw the last entry.  */
2843 +               break;
2844 +
2845 +             p = next + 1;
2846 +             next = next_brace_sub (p, flags);
2847 +             assert (next != NULL);
2848 +           }
2849 +
2850 +#ifndef __GNUC__
2851 +         free (onealt);
2852 +#endif
2853 +
2854 +         if (pglob->gl_pathc != firstc)
2855 +           /* We found some entries.  */
2856 +           return 0;
2857 +         else if (!(flags & (GLOB_NOCHECK|GLOB_NOMAGIC)))
2858 +           return GLOB_NOMATCH;
2859 +       }
2860 +    }
2861 +
2862 +  /* Find the filename.  */
2863 +  filename = strrchr (pattern, '/');
2864 +#if defined __MSDOS__ || defined WINDOWS32
2865 +  /* The case of "d:pattern".  Since `:' is not allowed in
2866 +     file names, we can safely assume that wherever it
2867 +     happens in pattern, it signals the filename part.  This
2868 +     is so we could some day support patterns like "[a-z]:foo".  */
2869 +  if (filename == NULL)
2870 +    filename = strchr (pattern, ':');
2871 +#endif /* __MSDOS__ || WINDOWS32 */
2872 +  dirname_modified = 0;
2873 +  if (filename == NULL)
2874 +    {
2875 +      /* This can mean two things: a simple name or "~name".  The latter
2876 +        case is nothing but a notation for a directory.  */
2877 +      if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && pattern[0] == '~')
2878 +       {
2879 +         dirname = pattern;
2880 +         dirlen = strlen (pattern);
2881 +
2882 +         /* Set FILENAME to NULL as a special flag.  This is ugly but
2883 +            other solutions would require much more code.  We test for
2884 +            this special case below.  */
2885 +         filename = NULL;
2886 +       }
2887 +      else
2888 +       {
2889 +         filename = pattern;
2890 +#ifdef _AMIGA
2891 +         dirname = "";
2892 +#else
2893 +         dirname = ".";
2894 +#endif
2895 +         dirlen = 0;
2896 +       }
2897 +    }
2898 +  else if (filename == pattern
2899 +          || (filename == pattern + 1 && pattern[0] == '\\'
2900 +              && (flags & GLOB_NOESCAPE) == 0))
2901 +    {
2902 +      /* "/pattern" or "\\/pattern".  */
2903 +      dirname = "/";
2904 +      dirlen = 1;
2905 +      ++filename;
2906 +    }
2907 +  else
2908 +    {
2909 +      char *newp;
2910 +      dirlen = filename - pattern;
2911 +#if defined __MSDOS__ || defined WINDOWS32
2912 +      if (*filename == ':'
2913 +         || (filename > pattern + 1 && filename[-1] == ':'))
2914 +       {
2915 +         char *drive_spec;
2916 +
2917 +         ++dirlen;
2918 +         drive_spec = __alloca (dirlen + 1);
2919 +         *((char *) mempcpy (drive_spec, pattern, dirlen)) = '\0';
2920 +         /* For now, disallow wildcards in the drive spec, to
2921 +            prevent infinite recursion in glob.  */
2922 +         if (__glob_pattern_p (drive_spec, !(flags & GLOB_NOESCAPE)))
2923 +           return GLOB_NOMATCH;
2924 +         /* If this is "d:pattern", we need to copy `:' to DIRNAME
2925 +            as well.  If it's "d:/pattern", don't remove the slash
2926 +            from "d:/", since "d:" and "d:/" are not the same.*/
2927 +       }
2928 +#endif
2929 +      newp = __alloca (dirlen + 1);
2930 +      *((char *) mempcpy (newp, pattern, dirlen)) = '\0';
2931 +      dirname = newp;
2932 +      ++filename;
2933 +
2934 +      if (filename[0] == '\0'
2935 +#if defined __MSDOS__ || defined WINDOWS32
2936 +          && dirname[dirlen - 1] != ':'
2937 +         && (dirlen < 3 || dirname[dirlen - 2] != ':'
2938 +             || dirname[dirlen - 1] != '/')
2939 +#endif
2940 +         && dirlen > 1)
2941 +       /* "pattern/".  Expand "pattern", appending slashes.  */
2942 +       {
2943 +         int orig_flags = flags;
2944 +         int val;
2945 +         if (!(flags & GLOB_NOESCAPE) && dirname[dirlen - 1] == '\\')
2946 +           {
2947 +             /* "pattern\\/".  Remove the final backslash if it hasn't
2948 +                been quoted.  */
2949 +             char *p = (char *) &dirname[dirlen - 1];
2950 +
2951 +             while (p > dirname && p[-1] == '\\') --p;
2952 +             if ((&dirname[dirlen] - p) & 1)
2953 +               {
2954 +                 *(char *) &dirname[--dirlen] = '\0';
2955 +                 flags &= ~(GLOB_NOCHECK | GLOB_NOMAGIC);
2956 +               }
2957 +           }
2958 +         val = glob (dirname, flags | GLOB_MARK, errfunc, pglob);
2959 +         if (val == 0)
2960 +           pglob->gl_flags = ((pglob->gl_flags & ~GLOB_MARK)
2961 +                              | (flags & GLOB_MARK));
2962 +         else if (val == GLOB_NOMATCH && flags != orig_flags)
2963 +           {
2964 +             /* Make sure globfree (&dirs); is a nop.  */
2965 +             dirs.gl_pathv = NULL;
2966 +             flags = orig_flags;
2967 +             oldcount = pglob->gl_pathc + pglob->gl_offs;
2968 +             goto no_matches;
2969 +           }
2970 +         return val;
2971 +       }
2972 +    }
2973 +
2974 +  if (!(flags & GLOB_APPEND))
2975 +    {
2976 +      pglob->gl_pathc = 0;
2977 +      if (!(flags & GLOB_DOOFFS))
2978 +        pglob->gl_pathv = NULL;
2979 +      else
2980 +       {
2981 +         size_t i;
2982 +         pglob->gl_pathv = malloc ((pglob->gl_offs + 1) * sizeof (char *));
2983 +         if (pglob->gl_pathv == NULL)
2984 +           return GLOB_NOSPACE;
2985 +
2986 +         for (i = 0; i <= pglob->gl_offs; ++i)
2987 +           pglob->gl_pathv[i] = NULL;
2988 +       }
2989 +    }
2990 +
2991 +  oldcount = pglob->gl_pathc + pglob->gl_offs;
2992 +
2993 +  if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && dirname[0] == '~')
2994 +    {
2995 +      if (dirname[1] == '\0' || dirname[1] == '/'
2996 +         || (!(flags & GLOB_NOESCAPE) && dirname[1] == '\\'
2997 +             && (dirname[2] == '\0' || dirname[2] == '/')))
2998 +       {
2999 +         /* Look up home directory.  */
3000 +         const char *home_dir = getenv ("HOME");
3001 +# ifdef _AMIGA
3002 +         if (home_dir == NULL || home_dir[0] == '\0')
3003 +           home_dir = "SYS:";
3004 +# else
3005 +#  ifdef WINDOWS32
3006 +         /* Windows NT defines HOMEDRIVE and HOMEPATH.  But give preference
3007 +            to HOME, because the user can change HOME.  */
3008 +         if (home_dir == NULL || home_dir[0] == '\0')
3009 +           {
3010 +             const char *home_drive = getenv ("HOMEDRIVE");
3011 +             const char *home_path = getenv ("HOMEPATH");
3012 +
3013 +             if (home_drive != NULL && home_path != NULL)
3014 +               {
3015 +                 size_t home_drive_len = strlen (home_drive);
3016 +                 size_t home_path_len = strlen (home_path);
3017 +                 char *mem = alloca (home_drive_len + home_path_len + 1);
3018 +
3019 +                 memcpy (mem, home_drive, home_drive_len);
3020 +                 memcpy (mem + home_drive_len, home_path, home_path_len + 1);
3021 +                 home_dir = mem;
3022 +               }
3023 +             else
3024 +               home_dir = "c:/users/default"; /* poor default */
3025 +           }
3026 +#  else
3027 +         if (home_dir == NULL || home_dir[0] == '\0')
3028 +           {
3029 +             int success;
3030 +             char *name;
3031 +             size_t buflen = GET_LOGIN_NAME_MAX () + 1;
3032 +
3033 +             if (buflen == 0)
3034 +               /* `sysconf' does not support _SC_LOGIN_NAME_MAX.  Try
3035 +                  a moderate value.  */
3036 +               buflen = 20;
3037 +             name = __alloca (buflen);
3038 +
3039 +             success = getlogin_r (name, buflen) == 0;
3040 +             if (success)
3041 +               {
3042 +                 struct passwd *p;
3043 +#   if defined HAVE_GETPWNAM_R || defined _LIBC
3044 +                 long int pwbuflen = GETPW_R_SIZE_MAX ();
3045 +                 char *pwtmpbuf;
3046 +                 struct passwd pwbuf;
3047 +                 int save = errno;
3048 +
3049 +#    ifndef _LIBC
3050 +                 if (pwbuflen == -1)
3051 +                   /* `sysconf' does not support _SC_GETPW_R_SIZE_MAX.
3052 +                      Try a moderate value.  */
3053 +                   pwbuflen = 1024;
3054 +#    endif
3055 +                 pwtmpbuf = __alloca (pwbuflen);
3056 +
3057 +                 while (getpwnam_r (name, &pwbuf, pwtmpbuf, pwbuflen, &p)
3058 +                        != 0)
3059 +                   {
3060 +                     if (errno != ERANGE)
3061 +                       {
3062 +                         p = NULL;
3063 +                         break;
3064 +                       }
3065 +#    ifdef _LIBC
3066 +                     pwtmpbuf = extend_alloca (pwtmpbuf, pwbuflen,
3067 +                                               2 * pwbuflen);
3068 +#    else
3069 +                     pwbuflen *= 2;
3070 +                     pwtmpbuf = __alloca (pwbuflen);
3071 +#    endif
3072 +                     __set_errno (save);
3073 +                   }
3074 +#   else
3075 +                 p = getpwnam (name);
3076 +#   endif
3077 +                 if (p != NULL)
3078 +                   home_dir = p->pw_dir;
3079 +               }
3080 +           }
3081 +         if (home_dir == NULL || home_dir[0] == '\0')
3082 +           {
3083 +             if (flags & GLOB_TILDE_CHECK)
3084 +               return GLOB_NOMATCH;
3085 +             else
3086 +               home_dir = "~"; /* No luck.  */
3087 +           }
3088 +#  endif /* WINDOWS32 */
3089 +# endif
3090 +         /* Now construct the full directory.  */
3091 +         if (dirname[1] == '\0')
3092 +           {
3093 +             dirname = home_dir;
3094 +             dirlen = strlen (dirname);
3095 +           }
3096 +         else
3097 +           {
3098 +             char *newp;
3099 +             size_t home_len = strlen (home_dir);
3100 +             newp = __alloca (home_len + dirlen);
3101 +             mempcpy (mempcpy (newp, home_dir, home_len),
3102 +                      &dirname[1], dirlen);
3103 +             dirname = newp;
3104 +             dirlen += home_len - 1;
3105 +           }
3106 +         dirname_modified = 1;
3107 +       }
3108 +# if !defined _AMIGA && !defined WINDOWS32
3109 +      else
3110 +       {
3111 +         char *end_name = strchr (dirname, '/');
3112 +         const char *user_name;
3113 +         const char *home_dir;
3114 +         char *unescape = NULL;
3115 +
3116 +         if (!(flags & GLOB_NOESCAPE))
3117 +           {
3118 +             if (end_name == NULL)
3119 +               {
3120 +                 unescape = strchr (dirname, '\\');
3121 +                 if (unescape)
3122 +                   end_name = strchr (unescape, '\0');
3123 +               }
3124 +             else
3125 +               unescape = memchr (dirname, '\\', end_name - dirname);
3126 +           }
3127 +         if (end_name == NULL)
3128 +           user_name = dirname + 1;
3129 +         else
3130 +           {
3131 +             char *newp;
3132 +             newp = __alloca (end_name - dirname);
3133 +             *((char *) mempcpy (newp, dirname + 1, end_name - dirname))
3134 +               = '\0';
3135 +             if (unescape != NULL)
3136 +               {
3137 +                 char *p = mempcpy (newp, dirname + 1,
3138 +                                    unescape - dirname - 1);
3139 +                 char *q = unescape;
3140 +                 while (*q != '\0')
3141 +                   {
3142 +                     if (*q == '\\')
3143 +                       {
3144 +                         if (q[1] == '\0')
3145 +                           {
3146 +                             /* "~fo\\o\\" unescape to user_name "foo\\",
3147 +                                but "~fo\\o\\/" unescape to user_name
3148 +                                "foo".  */
3149 +                             if (filename == NULL)
3150 +                               *p++ = '\\';
3151 +                             break;
3152 +                           }
3153 +                         ++q;
3154 +                       }
3155 +                     *p++ = *q++;
3156 +                   }
3157 +                 *p = '\0';
3158 +               }
3159 +             else
3160 +               *((char *) mempcpy (newp, dirname + 1, end_name - dirname))
3161 +                 = '\0';
3162 +             user_name = newp;
3163 +           }
3164 +
3165 +         /* Look up specific user's home directory.  */
3166 +         {
3167 +           struct passwd *p;
3168 +#  if defined HAVE_GETPWNAM_R || defined _LIBC
3169 +           long int buflen = GETPW_R_SIZE_MAX ();
3170 +           char *pwtmpbuf;
3171 +           struct passwd pwbuf;
3172 +           int save = errno;
3173 +
3174 +#   ifndef _LIBC
3175 +           if (buflen == -1)
3176 +             /* `sysconf' does not support _SC_GETPW_R_SIZE_MAX.  Try a
3177 +                moderate value.  */
3178 +             buflen = 1024;
3179 +#   endif
3180 +           pwtmpbuf = __alloca (buflen);
3181 +
3182 +           while (getpwnam_r (user_name, &pwbuf, pwtmpbuf, buflen, &p) != 0)
3183 +             {
3184 +               if (errno != ERANGE)
3185 +                 {
3186 +                   p = NULL;
3187 +                   break;
3188 +                 }
3189 +#   ifdef _LIBC
3190 +               pwtmpbuf = extend_alloca (pwtmpbuf, buflen, 2 * buflen);
3191 +#   else
3192 +               buflen *= 2;
3193 +               pwtmpbuf = __alloca (buflen);
3194 +#   endif
3195 +               __set_errno (save);
3196 +             }
3197 +#  else
3198 +           p = getpwnam (user_name);
3199 +#  endif
3200 +           if (p != NULL)
3201 +             home_dir = p->pw_dir;
3202 +           else
3203 +             home_dir = NULL;
3204 +         }
3205 +         /* If we found a home directory use this.  */
3206 +         if (home_dir != NULL)
3207 +           {
3208 +             char *newp;
3209 +             size_t home_len = strlen (home_dir);
3210 +             size_t rest_len = end_name == NULL ? 0 : strlen (end_name);
3211 +             newp = __alloca (home_len + rest_len + 1);
3212 +             *((char *) mempcpy (mempcpy (newp, home_dir, home_len),
3213 +                                 end_name, rest_len)) = '\0';
3214 +             dirname = newp;
3215 +             dirlen = home_len + rest_len;
3216 +             dirname_modified = 1;
3217 +           }
3218 +         else
3219 +           if (flags & GLOB_TILDE_CHECK)
3220 +             /* We have to regard it as an error if we cannot find the
3221 +                home directory.  */
3222 +             return GLOB_NOMATCH;
3223 +       }
3224 +# endif        /* Not Amiga && not WINDOWS32.  */
3225 +    }
3226 +
3227 +  /* Now test whether we looked for "~" or "~NAME".  In this case we
3228 +     can give the answer now.  */
3229 +  if (filename == NULL)
3230 +    {
3231 +      struct stat st;
3232 +      struct_stat64 st64;
3233 +
3234 +      /* Return the directory if we don't check for error or if it exists.  */
3235 +      if ((flags & GLOB_NOCHECK)
3236 +         || (((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0))
3237 +              ? ((*pglob->gl_stat) (dirname, &st) == 0
3238 +                 && S_ISDIR (st.st_mode))
3239 +              : (__stat64 (dirname, &st64) == 0 && S_ISDIR (st64.st_mode)))))
3240 +       {
3241 +         int newcount = pglob->gl_pathc + pglob->gl_offs;
3242 +         char **new_gl_pathv;
3243 +
3244 +         new_gl_pathv
3245 +           = realloc (pglob->gl_pathv, (newcount + 1 + 1) * sizeof (char *));
3246 +         if (new_gl_pathv == NULL)
3247 +           {
3248 +           nospace:
3249 +             free (pglob->gl_pathv);
3250 +             pglob->gl_pathv = NULL;
3251 +             pglob->gl_pathc = 0;
3252 +             return GLOB_NOSPACE;
3253 +           }
3254 +         pglob->gl_pathv = new_gl_pathv;
3255 +
3256 +         if (flags & GLOB_MARK)
3257 +           {
3258 +             char *p;
3259 +             pglob->gl_pathv[newcount] = malloc (dirlen + 2);
3260 +             if (pglob->gl_pathv[newcount] == NULL)
3261 +               goto nospace;
3262 +             p = mempcpy (pglob->gl_pathv[newcount], dirname, dirlen);
3263 +             p[0] = '/';
3264 +             p[1] = '\0';
3265 +           }
3266 +         else
3267 +           {
3268 +             pglob->gl_pathv[newcount] = strdup (dirname);
3269 +             if (pglob->gl_pathv[newcount] == NULL)
3270 +               goto nospace;
3271 +           }
3272 +         pglob->gl_pathv[++newcount] = NULL;
3273 +         ++pglob->gl_pathc;
3274 +         pglob->gl_flags = flags;
3275 +
3276 +         return 0;
3277 +       }
3278 +
3279 +      /* Not found.  */
3280 +      return GLOB_NOMATCH;
3281 +    }
3282 +
3283 +  meta = __glob_pattern_type (dirname, !(flags & GLOB_NOESCAPE));
3284 +  /* meta is 1 if correct glob pattern containing metacharacters.
3285 +     If meta has bit (1 << 2) set, it means there was an unterminated
3286 +     [ which we handle the same, using fnmatch.  Broken unterminated
3287 +     pattern bracket expressions ought to be rare enough that it is
3288 +     not worth special casing them, fnmatch will do the right thing.  */
3289 +  if (meta & 5)
3290 +    {
3291 +      /* The directory name contains metacharacters, so we
3292 +        have to glob for the directory, and then glob for
3293 +        the pattern in each directory found.  */
3294 +      size_t i;
3295 +
3296 +      if (!(flags & GLOB_NOESCAPE) && dirlen > 0 && dirname[dirlen - 1] == '\\')
3297 +       {
3298 +         /* "foo\\/bar".  Remove the final backslash from dirname
3299 +            if it has not been quoted.  */
3300 +         char *p = (char *) &dirname[dirlen - 1];
3301 +
3302 +         while (p > dirname && p[-1] == '\\') --p;
3303 +         if ((&dirname[dirlen] - p) & 1)
3304 +           *(char *) &dirname[--dirlen] = '\0';
3305 +       }
3306 +
3307 +      if (__builtin_expect ((flags & GLOB_ALTDIRFUNC) != 0, 0))
3308 +       {
3309 +         /* Use the alternative access functions also in the recursive
3310 +            call.  */
3311 +         dirs.gl_opendir = pglob->gl_opendir;
3312 +         dirs.gl_readdir = pglob->gl_readdir;
3313 +         dirs.gl_closedir = pglob->gl_closedir;
3314 +         dirs.gl_stat = pglob->gl_stat;
3315 +         dirs.gl_lstat = pglob->gl_lstat;
3316 +       }
3317 +
3318 +      status = glob (dirname,
3319 +                    ((flags & (GLOB_ERR | GLOB_NOESCAPE
3320 +                               | GLOB_ALTDIRFUNC))
3321 +                     | GLOB_NOSORT | GLOB_ONLYDIR),
3322 +                    errfunc, &dirs);
3323 +      if (status != 0)
3324 +       {
3325 +         if ((flags & GLOB_NOCHECK) == 0 || status != GLOB_NOMATCH)
3326 +           return status;
3327 +         goto no_matches;
3328 +       }
3329 +
3330 +      /* We have successfully globbed the preceding directory name.
3331 +        For each name we found, call glob_in_dir on it and FILENAME,
3332 +        appending the results to PGLOB.  */
3333 +      for (i = 0; i < dirs.gl_pathc; ++i)
3334 +       {
3335 +         int old_pathc;
3336 +
3337 +#ifdef SHELL
3338 +         {
3339 +           /* Make globbing interruptible in the bash shell. */
3340 +           extern int interrupt_state;
3341 +
3342 +           if (interrupt_state)
3343 +             {
3344 +               globfree (&dirs);
3345 +               return GLOB_ABORTED;
3346 +             }
3347 +         }
3348 +#endif /* SHELL.  */
3349 +
3350 +         old_pathc = pglob->gl_pathc;
3351 +         status = glob_in_dir (filename, dirs.gl_pathv[i],
3352 +                               ((flags | GLOB_APPEND)
3353 +                                & ~(GLOB_NOCHECK | GLOB_NOMAGIC)),
3354 +                               errfunc, pglob);
3355 +         if (status == GLOB_NOMATCH)
3356 +           /* No matches in this directory.  Try the next.  */
3357 +           continue;
3358 +
3359 +         if (status != 0)
3360 +           {
3361 +             globfree (&dirs);
3362 +             globfree (pglob);
3363 +             pglob->gl_pathc = 0;
3364 +             return status;
3365 +           }
3366 +
3367 +         /* Stick the directory on the front of each name.  */
3368 +         if (prefix_array (dirs.gl_pathv[i],
3369 +                           &pglob->gl_pathv[old_pathc + pglob->gl_offs],
3370 +                           pglob->gl_pathc - old_pathc))
3371 +           {
3372 +             globfree (&dirs);
3373 +             globfree (pglob);
3374 +             pglob->gl_pathc = 0;
3375 +             return GLOB_NOSPACE;
3376 +           }
3377 +       }
3378 +
3379 +      flags |= GLOB_MAGCHAR;
3380 +
3381 +      /* We have ignored the GLOB_NOCHECK flag in the `glob_in_dir' calls.
3382 +        But if we have not found any matching entry and the GLOB_NOCHECK
3383 +        flag was set we must return the input pattern itself.  */
3384 +      if (pglob->gl_pathc + pglob->gl_offs == oldcount)
3385 +       {
3386 +       no_matches:
3387 +         /* No matches.  */
3388 +         if (flags & GLOB_NOCHECK)
3389 +           {
3390 +             int newcount = pglob->gl_pathc + pglob->gl_offs;
3391 +             char **new_gl_pathv;
3392 +
3393 +             new_gl_pathv = realloc (pglob->gl_pathv,
3394 +                                     (newcount + 2) * sizeof (char *));
3395 +             if (new_gl_pathv == NULL)
3396 +               {
3397 +                 globfree (&dirs);
3398 +                 return GLOB_NOSPACE;
3399 +               }
3400 +             pglob->gl_pathv = new_gl_pathv;
3401 +
3402 +             pglob->gl_pathv[newcount] = strdup (pattern);
3403 +             if (pglob->gl_pathv[newcount] == NULL)
3404 +               {
3405 +                 globfree (&dirs);
3406 +                 globfree (pglob);
3407 +                 pglob->gl_pathc = 0;
3408 +                 return GLOB_NOSPACE;
3409 +               }
3410 +
3411 +             ++pglob->gl_pathc;
3412 +             ++newcount;
3413 +
3414 +             pglob->gl_pathv[newcount] = NULL;
3415 +             pglob->gl_flags = flags;
3416 +           }
3417 +         else
3418 +           {
3419 +             globfree (&dirs);
3420 +             return GLOB_NOMATCH;
3421 +           }
3422 +       }
3423 +
3424 +      globfree (&dirs);
3425 +    }
3426 +  else
3427 +    {
3428 +      int old_pathc = pglob->gl_pathc;
3429 +      int orig_flags = flags;
3430 +
3431 +      if (meta & 2)
3432 +       {
3433 +         char *p = strchr (dirname, '\\'), *q;
3434 +         /* We need to unescape the dirname string.  It is certainly
3435 +            allocated by alloca, as otherwise filename would be NULL
3436 +            or dirname wouldn't contain backslashes.  */
3437 +         q = p;
3438 +         do
3439 +           {
3440 +             if (*p == '\\')
3441 +               {
3442 +                 *q = *++p;
3443 +                 --dirlen;
3444 +               }
3445 +             else
3446 +               *q = *p;
3447 +             ++q;
3448 +           }
3449 +         while (*p++ != '\0');
3450 +         dirname_modified = 1;
3451 +       }
3452 +      if (dirname_modified)
3453 +       flags &= ~(GLOB_NOCHECK | GLOB_NOMAGIC);
3454 +      status = glob_in_dir (filename, dirname, flags, errfunc, pglob);
3455 +      if (status != 0)
3456 +       {
3457 +         if (status == GLOB_NOMATCH && flags != orig_flags
3458 +             && pglob->gl_pathc + pglob->gl_offs == oldcount)
3459 +           {
3460 +             /* Make sure globfree (&dirs); is a nop.  */
3461 +             dirs.gl_pathv = NULL;
3462 +             flags = orig_flags;
3463 +             goto no_matches;
3464 +           }
3465 +         return status;
3466 +       }
3467 +
3468 +      if (dirlen > 0)
3469 +       {
3470 +         /* Stick the directory on the front of each name.  */
3471 +         if (prefix_array (dirname,
3472 +                           &pglob->gl_pathv[old_pathc + pglob->gl_offs],
3473 +                           pglob->gl_pathc - old_pathc))
3474 +           {
3475 +             globfree (pglob);
3476 +             pglob->gl_pathc = 0;
3477 +             return GLOB_NOSPACE;
3478 +           }
3479 +       }
3480 +    }
3481 +
3482 +  if (flags & GLOB_MARK)
3483 +    {
3484 +      /* Append slashes to directory names.  */
3485 +      size_t i;
3486 +      struct stat st;
3487 +      struct_stat64 st64;
3488 +
3489 +      for (i = oldcount; i < pglob->gl_pathc + pglob->gl_offs; ++i)
3490 +       if ((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
3491 +            ? ((*pglob->gl_stat) (pglob->gl_pathv[i], &st) == 0
3492 +               && S_ISDIR (st.st_mode))
3493 +            : (__stat64 (pglob->gl_pathv[i], &st64) == 0
3494 +               && S_ISDIR (st64.st_mode))))
3495 +         {
3496 +           size_t len = strlen (pglob->gl_pathv[i]) + 2;
3497 +           char *new = realloc (pglob->gl_pathv[i], len);
3498 +           if (new == NULL)
3499 +             {
3500 +               globfree (pglob);
3501 +               pglob->gl_pathc = 0;
3502 +               return GLOB_NOSPACE;
3503 +             }
3504 +           strcpy (&new[len - 2], "/");
3505 +           pglob->gl_pathv[i] = new;
3506 +         }
3507 +    }
3508 +
3509 +  if (!(flags & GLOB_NOSORT))
3510 +    {
3511 +      /* Sort the vector.  */
3512 +      qsort (&pglob->gl_pathv[oldcount],
3513 +            pglob->gl_pathc + pglob->gl_offs - oldcount,
3514 +            sizeof (char *), collated_compare);
3515 +    }
3516 +
3517 +  return 0;
3518 +}
3519 +#if defined _LIBC && !defined glob
3520 +libc_hidden_def (glob)
3521 +#endif
3522 +
3523 +
3524 +#if !defined _LIBC || !defined GLOB_ONLY_P
3525 +
3526 +/* Free storage allocated in PGLOB by a previous `glob' call.  */
3527 +void
3528 +globfree (pglob)
3529 +     register glob_t *pglob;
3530 +{
3531 +  if (pglob->gl_pathv != NULL)
3532 +    {
3533 +      size_t i;
3534 +      for (i = 0; i < pglob->gl_pathc; ++i)
3535 +       if (pglob->gl_pathv[pglob->gl_offs + i] != NULL)
3536 +         free (pglob->gl_pathv[pglob->gl_offs + i]);
3537 +      free (pglob->gl_pathv);
3538 +      pglob->gl_pathv = NULL;
3539 +    }
3540 +}
3541 +#if defined _LIBC && !defined globfree
3542 +libc_hidden_def (globfree)
3543 +#endif
3544 +
3545 +
3546 +/* Do a collated comparison of A and B.  */
3547 +static int
3548 +collated_compare (const void *a, const void *b)
3549 +{
3550 +  char *const *ps1 = a; char *s1 = *ps1;
3551 +  char *const *ps2 = b; char *s2 = *ps2;
3552 +
3553 +  if (s1 == s2)
3554 +    return 0;
3555 +  if (s1 == NULL)
3556 +    return 1;
3557 +  if (s2 == NULL)
3558 +    return -1;
3559 +  return strcoll (s1, s2);
3560 +}
3561 +
3562 +
3563 +/* Prepend DIRNAME to each of N members of ARRAY, replacing ARRAY's
3564 +   elements in place.  Return nonzero if out of memory, zero if successful.
3565 +   A slash is inserted between DIRNAME and each elt of ARRAY,
3566 +   unless DIRNAME is just "/".  Each old element of ARRAY is freed.  */
3567 +static int
3568 +prefix_array (const char *dirname, char **array, size_t n)
3569 +{
3570 +  register size_t i;
3571 +  size_t dirlen = strlen (dirname);
3572 +#if defined __MSDOS__ || defined WINDOWS32
3573 +  int sep_char = '/';
3574 +# define DIRSEP_CHAR sep_char
3575 +#else
3576 +# define DIRSEP_CHAR '/'
3577 +#endif
3578 +
3579 +  if (dirlen == 1 && dirname[0] == '/')
3580 +    /* DIRNAME is just "/", so normal prepending would get us "//foo".
3581 +       We want "/foo" instead, so don't prepend any chars from DIRNAME.  */
3582 +    dirlen = 0;
3583 +#if defined __MSDOS__ || defined WINDOWS32
3584 +  else if (dirlen > 1)
3585 +    {
3586 +      if (dirname[dirlen - 1] == '/' && dirname[dirlen - 2] == ':')
3587 +       /* DIRNAME is "d:/".  Don't prepend the slash from DIRNAME.  */
3588 +       --dirlen;
3589 +      else if (dirname[dirlen - 1] == ':')
3590 +       {
3591 +         /* DIRNAME is "d:".  Use `:' instead of `/'.  */
3592 +         --dirlen;
3593 +         sep_char = ':';
3594 +       }
3595 +    }
3596 +#endif
3597 +
3598 +  for (i = 0; i < n; ++i)
3599 +    {
3600 +      size_t eltlen = strlen (array[i]) + 1;
3601 +      char *new = malloc (dirlen + 1 + eltlen);
3602 +      if (new == NULL)
3603 +       {
3604 +         while (i > 0)
3605 +           free (array[--i]);
3606 +         return 1;
3607 +       }
3608 +
3609 +      {
3610 +       char *endp = mempcpy (new, dirname, dirlen);
3611 +       *endp++ = DIRSEP_CHAR;
3612 +       mempcpy (endp, array[i], eltlen);
3613 +      }
3614 +      free (array[i]);
3615 +      array[i] = new;
3616 +    }
3617 +
3618 +  return 0;
3619 +}
3620 +
3621 +
3622 +/* We must not compile this function twice.  */
3623 +#if !defined _LIBC || !defined NO_GLOB_PATTERN_P
3624 +int
3625 +__glob_pattern_type (pattern, quote)
3626 +     const char *pattern;
3627 +     int quote;
3628 +{
3629 +  register const char *p;
3630 +  int ret = 0;
3631 +
3632 +  for (p = pattern; *p != '\0'; ++p)
3633 +    switch (*p)
3634 +      {
3635 +      case '?':
3636 +      case '*':
3637 +       return 1;
3638 +
3639 +      case '\\':
3640 +       if (quote)
3641 +         {
3642 +           if (p[1] != '\0')
3643 +             ++p;
3644 +           ret |= 2;
3645 +         }
3646 +       break;
3647 +
3648 +      case '[':
3649 +       ret |= 4;
3650 +       break;
3651 +
3652 +      case ']':
3653 +       if (ret & 4)
3654 +         return 1;
3655 +       break;
3656 +      }
3657 +
3658 +  return ret;
3659 +}
3660 +
3661 +/* Return nonzero if PATTERN contains any metacharacters.
3662 +   Metacharacters can be quoted with backslashes if QUOTE is nonzero.  */
3663 +int
3664 +__glob_pattern_p (pattern, quote)
3665 +     const char *pattern;
3666 +     int quote;
3667 +{
3668 +  return __glob_pattern_type (pattern, quote) == 1;
3669 +}
3670 +# ifdef _LIBC
3671 +weak_alias (__glob_pattern_p, glob_pattern_p)
3672 +# endif
3673 +#endif
3674 +
3675 +#endif /* !GLOB_ONLY_P */
3676 +
3677 +
3678 +#if !defined _LIBC || !defined GLOB_ONLY_P
3679 +/* We put this in a separate function mainly to allow the memory
3680 +   allocated with alloca to be recycled.  */
3681 +static int
3682 +__attribute_noinline__
3683 +link_exists2_p (const char *dir, size_t dirlen, const char *fname,
3684 +               glob_t *pglob
3685 +# if !defined _LIBC && !HAVE_FSTATAT
3686 +               , int flags
3687 +# endif
3688 +               )
3689 +{
3690 +  size_t fnamelen = strlen (fname);
3691 +  char *fullname = __alloca (dirlen + 1 + fnamelen + 1);
3692 +  struct stat st;
3693 +
3694 +  mempcpy (mempcpy (mempcpy (fullname, dir, dirlen), "/", 1),
3695 +          fname, fnamelen + 1);
3696 +
3697 +# if !defined _LIBC && !HAVE_FSTATAT
3698 +  if (__builtin_expect ((flags & GLOB_ALTDIRFUNC) == 0, 1))
3699 +    {
3700 +      struct_stat64 st64;
3701 +      return __stat64 (fullname, &st64) == 0;
3702 +    }
3703 +# endif
3704 +  return (*pglob->gl_stat) (fullname, &st) == 0;
3705 +}
3706 +
3707 +/* Return true if DIR/FNAME exists.  */
3708 +static int
3709 +link_exists_p (int dfd, const char *dir, size_t dirlen, const char *fname,
3710 +              glob_t *pglob, int flags)
3711 +{
3712 +# if defined _LIBC || HAVE_FSTATAT
3713 +  if (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0))
3714 +    return link_exists2_p (dir, dirlen, fname, pglob);
3715 +  else
3716 +    {
3717 +      struct_stat64 st64;
3718 +      return __fxstatat64 (_STAT_VER, dfd, fname, &st64, 0) == 0;
3719 +    }
3720 +# else
3721 +  return link_exists2_p (dir, dirlen, fname, pglob, flags);
3722 +# endif
3723 +}
3724 +#endif
3725 +
3726 +
3727 +/* Like `glob', but PATTERN is a final pathname component,
3728 +   and matches are searched for in DIRECTORY.
3729 +   The GLOB_NOSORT bit in FLAGS is ignored.  No sorting is ever done.
3730 +   The GLOB_APPEND flag is assumed to be set (always appends).  */
3731 +static int
3732 +glob_in_dir (const char *pattern, const char *directory, int flags,
3733 +            int (*errfunc) (const char *, int),
3734 +            glob_t *pglob)
3735 +{
3736 +  size_t dirlen = strlen (directory);
3737 +  void *stream = NULL;
3738 +  struct globnames
3739 +    {
3740 +      struct globnames *next;
3741 +      size_t count;
3742 +      char *name[64];
3743 +    };
3744 +#define INITIAL_COUNT sizeof (init_names.name) / sizeof (init_names.name[0])
3745 +  struct globnames init_names;
3746 +  struct globnames *names = &init_names;
3747 +  struct globnames *names_alloca = &init_names;
3748 +  size_t nfound = 0;
3749 +  size_t allocasize = sizeof (init_names);
3750 +  size_t cur = 0;
3751 +  int meta;
3752 +  int save;
3753 +  int result;
3754 +
3755 +  init_names.next = NULL;
3756 +  init_names.count = INITIAL_COUNT;
3757 +
3758 +  meta = __glob_pattern_type (pattern, !(flags & GLOB_NOESCAPE));
3759 +  if (meta == 0 && (flags & (GLOB_NOCHECK|GLOB_NOMAGIC)))
3760 +    {
3761 +      /* We need not do any tests.  The PATTERN contains no meta
3762 +        characters and we must not return an error therefore the
3763 +        result will always contain exactly one name.  */
3764 +      flags |= GLOB_NOCHECK;
3765 +    }
3766 +  else if (meta == 0)
3767 +    {
3768 +      /* Since we use the normal file functions we can also use stat()
3769 +        to verify the file is there.  */
3770 +      struct stat st;
3771 +      struct_stat64 st64;
3772 +      size_t patlen = strlen (pattern);
3773 +      char *fullname = __alloca (dirlen + 1 + patlen + 1);
3774 +
3775 +      mempcpy (mempcpy (mempcpy (fullname, directory, dirlen),
3776 +                       "/", 1),
3777 +              pattern, patlen + 1);
3778 +      if ((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
3779 +          ? (*pglob->gl_stat) (fullname, &st)
3780 +          : __stat64 (fullname, &st64)) == 0)
3781 +       /* We found this file to be existing.  Now tell the rest
3782 +          of the function to copy this name into the result.  */
3783 +       flags |= GLOB_NOCHECK;
3784 +    }
3785 +  else
3786 +    {
3787 +      stream = (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
3788 +               ? (*pglob->gl_opendir) (directory)
3789 +               : opendir (directory));
3790 +      if (stream == NULL)
3791 +       {
3792 +         if (errno != ENOTDIR
3793 +             && ((errfunc != NULL && (*errfunc) (directory, errno))
3794 +                 || (flags & GLOB_ERR)))
3795 +           return GLOB_ABORTED;
3796 +       }
3797 +      else
3798 +       {
3799 +         int dfd = (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
3800 +                    ? -1 : dirfd ((DIR *) stream));
3801 +         int fnm_flags = ((!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0)
3802 +                          | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)
3803 +#if defined _AMIGA || defined VMS
3804 +                          | FNM_CASEFOLD
3805 +#endif
3806 +                          );
3807 +         flags |= GLOB_MAGCHAR;
3808 +
3809 +         while (1)
3810 +           {
3811 +             const char *name;
3812 +             size_t len;
3813 +#if defined _LIBC && !defined COMPILE_GLOB64
3814 +             struct dirent64 *d;
3815 +             union
3816 +               {
3817 +                 struct dirent64 d64;
3818 +                 char room [offsetof (struct dirent64, d_name[0])
3819 +                            + NAME_MAX + 1];
3820 +               }
3821 +             d64buf;
3822 +
3823 +             if (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0))
3824 +               {
3825 +                 struct dirent *d32 = (*pglob->gl_readdir) (stream);
3826 +                 if (d32 != NULL)
3827 +                   {
3828 +                     CONVERT_DIRENT_DIRENT64 (&d64buf.d64, d32);
3829 +                     d = &d64buf.d64;
3830 +                   }
3831 +                 else
3832 +                   d = NULL;
3833 +               }
3834 +             else
3835 +               d = __readdir64 (stream);
3836 +#else
3837 +             struct dirent *d = (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
3838 +                                 ? ((struct dirent *)
3839 +                                    (*pglob->gl_readdir) (stream))
3840 +                                 : __readdir (stream));
3841 +#endif
3842 +             if (d == NULL)
3843 +               break;
3844 +             if (! REAL_DIR_ENTRY (d))
3845 +               continue;
3846 +
3847 +             /* If we shall match only directories use the information
3848 +                provided by the dirent call if possible.  */
3849 +             if ((flags & GLOB_ONLYDIR) && !DIRENT_MIGHT_BE_DIR (d))
3850 +               continue;
3851 +
3852 +             name = d->d_name;
3853 +
3854 +             if (fnmatch (pattern, name, fnm_flags) == 0)
3855 +               {
3856 +                 /* If the file we found is a symlink we have to
3857 +                    make sure the target file exists.  */
3858 +                 if (!DIRENT_MIGHT_BE_SYMLINK (d)
3859 +                     || link_exists_p (dfd, directory, dirlen, name, pglob,
3860 +                                       flags))
3861 +                   {
3862 +                     if (cur == names->count)
3863 +                       {
3864 +                         struct globnames *newnames;
3865 +                         size_t count = names->count * 2;
3866 +                         size_t size = (sizeof (struct globnames)
3867 +                                        + ((count - INITIAL_COUNT)
3868 +                                           * sizeof (char *)));
3869 +                         allocasize += size;
3870 +                         if (__libc_use_alloca (allocasize))
3871 +                           newnames = names_alloca = __alloca (size);
3872 +                         else if ((newnames = malloc (size))
3873 +                                  == NULL)
3874 +                           goto memory_error;
3875 +                         newnames->count = count;
3876 +                         newnames->next = names;
3877 +                         names = newnames;
3878 +                         cur = 0;
3879 +                       }
3880 +                     len = _D_EXACT_NAMLEN (d);
3881 +                     names->name[cur] = malloc (len + 1);
3882 +                     if (names->name[cur] == NULL)
3883 +                       goto memory_error;
3884 +                     *((char *) mempcpy (names->name[cur++], name, len))
3885 +                       = '\0';
3886 +                     ++nfound;
3887 +                   }
3888 +               }
3889 +           }
3890 +       }
3891 +    }
3892 +
3893 +  if (nfound == 0 && (flags & GLOB_NOCHECK))
3894 +    {
3895 +      size_t len = strlen (pattern);
3896 +      nfound = 1;
3897 +      names->name[cur] = malloc (len + 1);
3898 +      if (names->name[cur] == NULL)
3899 +       goto memory_error;
3900 +      *((char *) mempcpy (names->name[cur++], pattern, len)) = '\0';
3901 +    }
3902 +
3903 +  result = GLOB_NOMATCH;
3904 +  if (nfound != 0)
3905 +    {
3906 +      char **new_gl_pathv
3907 +       = realloc (pglob->gl_pathv,
3908 +                  (pglob->gl_pathc + pglob->gl_offs + nfound + 1)
3909 +                  * sizeof (char *));
3910 +      result = 0;
3911 +
3912 +      if (new_gl_pathv == NULL)
3913 +       {
3914 +       memory_error:
3915 +         while (1)
3916 +           {
3917 +             struct globnames *old = names;
3918 +             size_t i;
3919 +             for (i = 0; i < cur; ++i)
3920 +               free (names->name[i]);
3921 +             names = names->next;
3922 +             /* NB: we will not leak memory here if we exit without
3923 +                freeing the current block assigned to OLD.  At least
3924 +                the very first block is always allocated on the stack
3925 +                and this is the block assigned to OLD here.  */
3926 +             if (names == NULL)
3927 +               {
3928 +                 assert (old == &init_names);
3929 +                 break;
3930 +               }
3931 +             cur = names->count;
3932 +             if (old == names_alloca)
3933 +               names_alloca = names;
3934 +             else
3935 +               free (old);
3936 +           }
3937 +         result = GLOB_NOSPACE;
3938 +       }
3939 +      else
3940 +       {
3941 +         while (1)
3942 +           {
3943 +             struct globnames *old = names;
3944 +             size_t i;
3945 +             for (i = 0; i < cur; ++i)
3946 +               new_gl_pathv[pglob->gl_offs + pglob->gl_pathc++]
3947 +                 = names->name[i];
3948 +             names = names->next;
3949 +             /* NB: we will not leak memory here if we exit without
3950 +                freeing the current block assigned to OLD.  At least
3951 +                the very first block is always allocated on the stack
3952 +                and this is the block assigned to OLD here.  */
3953 +             if (names == NULL)
3954 +               {
3955 +                 assert (old == &init_names);
3956 +                 break;
3957 +               }
3958 +             cur = names->count;
3959 +             if (old == names_alloca)
3960 +               names_alloca = names;
3961 +             else
3962 +               free (old);
3963 +           }
3964 +
3965 +         pglob->gl_pathv = new_gl_pathv;
3966 +
3967 +         pglob->gl_pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
3968 +
3969 +         pglob->gl_flags = flags;
3970 +       }
3971 +    }
3972 +
3973 +  if (stream != NULL)
3974 +    {
3975 +      save = errno;
3976 +      if (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0))
3977 +       (*pglob->gl_closedir) (stream);
3978 +      else
3979 +       closedir (stream);
3980 +      __set_errno (save);
3981 +    }
3982 +
3983 +  return result;
3984 +}
3985 diff -urN popt-for-windows/lib/glob.in.h popt-for-windows-gnulib/lib/glob.in.h
3986 --- popt-for-windows/lib/glob.in.h      1970-01-01 01:00:00.000000000 +0100
3987 +++ popt-for-windows-gnulib/lib/glob.in.h       2008-10-25 15:17:05.000000000 +0100
3988 @@ -0,0 +1,60 @@
3989 +/* glob.h -- Find a path matching a pattern.
3990 +
3991 +   Copyright (C) 2005-2007 Free Software Foundation, Inc.
3992 +
3993 +   Written by Derek Price <derek@ximbiot.com> & Paul Eggert <eggert@CS.UCLA.EDU>
3994 +
3995 +   This program is free software; you can redistribute it and/or modify
3996 +   it under the terms of the GNU General Public License as published by
3997 +   the Free Software Foundation; either version 3, or (at your option)
3998 +   any later version.
3999 +
4000 +   This program is distributed in the hope that it will be useful,
4001 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
4002 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4003 +   GNU General Public License for more details.
4004 +
4005 +   You should have received a copy of the GNU General Public License
4006 +   along with this program; if not, write to the Free Software Foundation,
4007 +   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
4008 +
4009 +#ifndef _GL_GLOB_H
4010 +#define _GL_GLOB_H
4011 +
4012 +#if @HAVE_SYS_CDEFS_H@
4013 +# include <sys/cdefs.h>
4014 +#endif
4015 +
4016 +#include <stddef.h>
4017 +
4018 +/* On some systems, such as AIX 5.1, <sys/stat.h> does a "#define stat stat64".
4019 +   Make sure this definition is seen before glob-libc.h defines types that
4020 +   rely on 'struct stat'.  */
4021 +#include <sys/stat.h>
4022 +
4023 +#ifndef __BEGIN_DECLS
4024 +# define __BEGIN_DECLS
4025 +# define __END_DECLS
4026 +#endif
4027 +#ifndef __THROW
4028 +# define __THROW
4029 +#endif
4030 +
4031 +#ifndef __size_t
4032 +# define __size_t      size_t
4033 +#endif
4034 +#ifndef __USE_GNU
4035 +# define __USE_GNU    1
4036 +#endif
4037 +
4038 +
4039 +#define glob rpl_glob
4040 +#define globfree rpl_globfree
4041 +#define glob_pattern_p rpl_glob_pattern_p
4042 +
4043 +#define __GLOB_GNULIB 1
4044 +
4045 +/* Now the standard GNU C Library header should work.  */
4046 +#include "glob-libc.h"
4047 +
4048 +#endif /* _GL_GLOB_H */
4049 diff -urN popt-for-windows/lib/glob-libc.h popt-for-windows-gnulib/lib/glob-libc.h
4050 --- popt-for-windows/lib/glob-libc.h    1970-01-01 01:00:00.000000000 +0100
4051 +++ popt-for-windows-gnulib/lib/glob-libc.h     2008-10-25 15:17:05.000000000 +0100
4052 @@ -0,0 +1,211 @@
4053 +/* Copyright (C) 1991,92,95-98,2000,2001,2004-2007 Free Software Foundation, Inc.
4054 +   This file is part of the GNU C Library.
4055 +
4056 +   The GNU C Library is free software; you can redistribute it and/or
4057 +   modify it under the terms of the GNU General Public
4058 +   License as published by the Free Software Foundation; either
4059 +   version 3 of the License, or (at your option) any later version.
4060 +
4061 +   The GNU C Library is distributed in the hope that it will be useful,
4062 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
4063 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4064 +   Lesser General Public License for more details.
4065 +
4066 +   You should have received a copy of the GNU General Public
4067 +   License along with the GNU C Library; if not, write to the Free
4068 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
4069 +   02111-1307 USA.  */
4070 +
4071 +#ifndef        _GLOB_H
4072 +#define        _GLOB_H 1
4073 +
4074 +#ifndef __GLOB_GNULIB
4075 +# include <sys/cdefs.h>
4076 +#endif
4077 +
4078 +/* GCC 2.95 and later have "__restrict"; C99 compilers have
4079 +   "restrict", and "configure" may have defined "restrict".
4080 +   Other compilers use __restrict, __restrict__, and _Restrict, and
4081 +   'configure' might #define 'restrict' to those words, so pick a
4082 +   different name.  */
4083 +#ifndef _Restrict_
4084 +# if 199901L <= __STDC_VERSION__
4085 +#  define _Restrict_ restrict
4086 +# elif 2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__)
4087 +#  define _Restrict_ __restrict
4088 +# else
4089 +#  define _Restrict_
4090 +# endif
4091 +#endif
4092 +
4093 +__BEGIN_DECLS
4094 +
4095 +/* We need `size_t' for the following definitions.  */
4096 +#ifndef __size_t
4097 +# if defined __GNUC__ && __GNUC__ >= 2
4098 +typedef __SIZE_TYPE__ __size_t;
4099 +#  ifdef __USE_XOPEN
4100 +typedef __SIZE_TYPE__ size_t;
4101 +#  endif
4102 +# else
4103 +#  include <stddef.h>
4104 +#  ifndef __size_t
4105 +#   define __size_t size_t
4106 +#  endif
4107 +# endif
4108 +#else
4109 +/* The GNU CC stddef.h version defines __size_t as empty.  We need a real
4110 +   definition.  */
4111 +# undef __size_t
4112 +# define __size_t size_t
4113 +#endif
4114 +
4115 +/* Bits set in the FLAGS argument to `glob'.  */
4116 +#define        GLOB_ERR        (1 << 0)/* Return on read errors.  */
4117 +#define        GLOB_MARK       (1 << 1)/* Append a slash to each name.  */
4118 +#define        GLOB_NOSORT     (1 << 2)/* Don't sort the names.  */
4119 +#define        GLOB_DOOFFS     (1 << 3)/* Insert PGLOB->gl_offs NULLs.  */
4120 +#define        GLOB_NOCHECK    (1 << 4)/* If nothing matches, return the pattern.  */
4121 +#define        GLOB_APPEND     (1 << 5)/* Append to results of a previous call.  */
4122 +#define        GLOB_NOESCAPE   (1 << 6)/* Backslashes don't quote metacharacters.  */
4123 +#define        GLOB_PERIOD     (1 << 7)/* Leading `.' can be matched by metachars.  */
4124 +
4125 +#if !defined __USE_POSIX2 || defined __USE_BSD || defined __USE_GNU
4126 +# define GLOB_MAGCHAR   (1 << 8)/* Set in gl_flags if any metachars seen.  */
4127 +# define GLOB_ALTDIRFUNC (1 << 9)/* Use gl_opendir et al functions.  */
4128 +# define GLOB_BRACE     (1 << 10)/* Expand "{a,b}" to "a" "b".  */
4129 +# define GLOB_NOMAGIC   (1 << 11)/* If no magic chars, return the pattern.  */
4130 +# define GLOB_TILDE     (1 << 12)/* Expand ~user and ~ to home directories. */
4131 +# define GLOB_ONLYDIR   (1 << 13)/* Match only directories.  */
4132 +# define GLOB_TILDE_CHECK (1 << 14)/* Like GLOB_TILDE but return an error
4133 +                                     if the user name is not available.  */
4134 +# define __GLOB_FLAGS  (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
4135 +                        GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND|     \
4136 +                        GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE|     \
4137 +                        GLOB_NOMAGIC|GLOB_TILDE|GLOB_ONLYDIR|GLOB_TILDE_CHECK)
4138 +#else
4139 +# define __GLOB_FLAGS  (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
4140 +                        GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND|     \
4141 +                        GLOB_PERIOD)
4142 +#endif
4143 +
4144 +/* Error returns from `glob'.  */
4145 +#define        GLOB_NOSPACE    1       /* Ran out of memory.  */
4146 +#define        GLOB_ABORTED    2       /* Read error.  */
4147 +#define        GLOB_NOMATCH    3       /* No matches found.  */
4148 +#define GLOB_NOSYS     4       /* Not implemented.  */
4149 +#ifdef __USE_GNU
4150 +/* Previous versions of this file defined GLOB_ABEND instead of
4151 +   GLOB_ABORTED.  Provide a compatibility definition here.  */
4152 +# define GLOB_ABEND GLOB_ABORTED
4153 +#endif
4154 +
4155 +/* Structure describing a globbing run.  */
4156 +#ifdef __USE_GNU
4157 +struct stat;
4158 +#endif
4159 +typedef struct
4160 +  {
4161 +    __size_t gl_pathc;         /* Count of paths matched by the pattern.  */
4162 +    char **gl_pathv;           /* List of matched pathnames.  */
4163 +    __size_t gl_offs;          /* Slots to reserve in `gl_pathv'.  */
4164 +    int gl_flags;              /* Set to FLAGS, maybe | GLOB_MAGCHAR.  */
4165 +
4166 +    /* If the GLOB_ALTDIRFUNC flag is set, the following functions
4167 +       are used instead of the normal file access functions.  */
4168 +    void (*gl_closedir) (void *);
4169 +#ifdef __USE_GNU
4170 +    struct dirent *(*gl_readdir) (void *);
4171 +#else
4172 +    void *(*gl_readdir) (void *);
4173 +#endif
4174 +    void *(*gl_opendir) (const char *);
4175 +#ifdef __USE_GNU
4176 +    int (*gl_lstat) (const char *_Restrict_, struct stat *_Restrict_);
4177 +    int (*gl_stat) (const char *_Restrict_, struct stat *_Restrict_);
4178 +#else
4179 +    int (*gl_lstat) (const char *_Restrict_, void *_Restrict_);
4180 +    int (*gl_stat) (const char *_Restrict_, void *_Restrict_);
4181 +#endif
4182 +  } glob_t;
4183 +
4184 +#if defined __USE_LARGEFILE64 && !defined __GLOB_GNULIB
4185 +# ifdef __USE_GNU
4186 +struct stat64;
4187 +# endif
4188 +typedef struct
4189 +  {
4190 +    __size_t gl_pathc;
4191 +    char **gl_pathv;
4192 +    __size_t gl_offs;
4193 +    int gl_flags;
4194 +
4195 +    /* If the GLOB_ALTDIRFUNC flag is set, the following functions
4196 +       are used instead of the normal file access functions.  */
4197 +    void (*gl_closedir) (void *);
4198 +# ifdef __USE_GNU
4199 +    struct dirent64 *(*gl_readdir) (void *);
4200 +# else
4201 +    void *(*gl_readdir) (void *);
4202 +# endif
4203 +    void *(*gl_opendir) (const char *);
4204 +# ifdef __USE_GNU
4205 +    int (*gl_lstat) (const char *_Restrict_, struct stat64 *_Restrict_);
4206 +    int (*gl_stat) (const char *_Restrict_, struct stat64 *_Restrict_);
4207 +# else
4208 +    int (*gl_lstat) (const char *_Restrict_, void *_Restrict_);
4209 +    int (*gl_stat) (const char *_Restrict_, void *_Restrict_);
4210 +# endif
4211 +  } glob64_t;
4212 +#endif
4213 +
4214 +#if __USE_FILE_OFFSET64 && __GNUC__ < 2 && !defined __GLOB_GNULIB
4215 +# define glob glob64
4216 +# define globfree globfree64
4217 +#endif
4218 +
4219 +/* Do glob searching for PATTERN, placing results in PGLOB.
4220 +   The bits defined above may be set in FLAGS.
4221 +   If a directory cannot be opened or read and ERRFUNC is not nil,
4222 +   it is called with the pathname that caused the error, and the
4223 +   `errno' value from the failing call; if it returns non-zero
4224 +   `glob' returns GLOB_ABEND; if it returns zero, the error is ignored.
4225 +   If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
4226 +   Otherwise, `glob' returns zero.  */
4227 +#if !defined __USE_FILE_OFFSET64 || __GNUC__ < 2 || defined __GLOB_GNULIB
4228 +extern int glob (const char *_Restrict_ __pattern, int __flags,
4229 +                int (*__errfunc) (const char *, int),
4230 +                glob_t *_Restrict_ __pglob) __THROW;
4231 +
4232 +/* Free storage allocated in PGLOB by a previous `glob' call.  */
4233 +extern void globfree (glob_t *__pglob) __THROW;
4234 +#else
4235 +extern int __REDIRECT_NTH (glob, (const char *_Restrict_ __pattern,
4236 +                                 int __flags,
4237 +                                 int (*__errfunc) (const char *, int),
4238 +                                 glob_t *_Restrict_ __pglob), glob64);
4239 +
4240 +extern void __REDIRECT_NTH (globfree, (glob_t *__pglob), globfree64);
4241 +#endif
4242 +
4243 +#if defined __USE_LARGEFILE64 && !defined __GLOB_GNULIB
4244 +extern int glob64 (const char *_Restrict_ __pattern, int __flags,
4245 +                  int (*__errfunc) (const char *, int),
4246 +                  glob64_t *_Restrict_ __pglob) __THROW;
4247 +
4248 +extern void globfree64 (glob64_t *__pglob) __THROW;
4249 +#endif
4250 +
4251 +
4252 +#ifdef __USE_GNU
4253 +/* Return nonzero if PATTERN contains any metacharacters.
4254 +   Metacharacters can be quoted with backslashes if QUOTE is nonzero.
4255 +
4256 +   This function is not part of the interface specified by POSIX.2
4257 +   but several programs want to use it.  */
4258 +extern int glob_pattern_p (const char *__pattern, int __quote) __THROW;
4259 +#endif
4260 +
4261 +__END_DECLS
4262 +
4263 +#endif /* glob.h  */
4264 diff -urN popt-for-windows/lib/Makefile.am popt-for-windows-gnulib/lib/Makefile.am
4265 --- popt-for-windows/lib/Makefile.am    1970-01-01 01:00:00.000000000 +0100
4266 +++ popt-for-windows-gnulib/lib/Makefile.am     2008-10-25 15:17:05.000000000 +0100
4267 @@ -0,0 +1,502 @@
4268 +## DO NOT EDIT! GENERATED AUTOMATICALLY!
4269 +## Process this file with automake to produce Makefile.in.
4270 +# Copyright (C) 2002-2008 Free Software Foundation, Inc.
4271 +#
4272 +# This file is free software, distributed under the terms of the GNU
4273 +# General Public License.  As a special exception to the GNU General
4274 +# Public License, this file may be distributed as part of a program
4275 +# that contains a configuration script generated by Autoconf, under
4276 +# the same distribution terms as the rest of that program.
4277 +#
4278 +# Generated by gnulib-tool.
4279 +# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --libtool --macro-prefix=gl glob
4280 +
4281 +AUTOMAKE_OPTIONS = 1.5 gnits
4282 +
4283 +SUBDIRS =
4284 +noinst_HEADERS =
4285 +noinst_LIBRARIES =
4286 +noinst_LTLIBRARIES =
4287 +EXTRA_DIST =
4288 +BUILT_SOURCES =
4289 +SUFFIXES =
4290 +MOSTLYCLEANFILES = core *.stackdump
4291 +MOSTLYCLEANDIRS =
4292 +CLEANFILES =
4293 +DISTCLEANFILES =
4294 +MAINTAINERCLEANFILES =
4295 +
4296 +AM_CPPFLAGS =
4297 +
4298 +noinst_LTLIBRARIES += libgnu.la
4299 +
4300 +libgnu_la_SOURCES =
4301 +libgnu_la_LIBADD = $(gl_LTLIBOBJS)
4302 +libgnu_la_DEPENDENCIES = $(gl_LTLIBOBJS)
4303 +EXTRA_libgnu_la_SOURCES =
4304 +libgnu_la_LDFLAGS = $(AM_LDFLAGS)
4305 +
4306 +## begin gnulib module alloca
4307 +
4308 +
4309 +EXTRA_DIST += alloca.c
4310 +
4311 +EXTRA_libgnu_la_SOURCES += alloca.c
4312 +
4313 +libgnu_la_LIBADD += @LTALLOCA@
4314 +libgnu_la_DEPENDENCIES += @LTALLOCA@
4315 +## end   gnulib module alloca
4316 +
4317 +## begin gnulib module alloca-opt
4318 +
4319 +BUILT_SOURCES += $(ALLOCA_H)
4320 +
4321 +# We need the following in order to create <alloca.h> when the system
4322 +# doesn't have one that works with the given compiler.
4323 +alloca.h: alloca.in.h
4324 +       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
4325 +         cat $(srcdir)/alloca.in.h; \
4326 +       } > $@-t
4327 +       mv -f $@-t $@
4328 +MOSTLYCLEANFILES += alloca.h alloca.h-t
4329 +
4330 +EXTRA_DIST += alloca.in.h
4331 +
4332 +## end   gnulib module alloca-opt
4333 +
4334 +## begin gnulib module dirent
4335 +
4336 +BUILT_SOURCES += $(DIRENT_H)
4337 +
4338 +# We need the following in order to create <dirent.h> when the system
4339 +# doesn't have one that works with the given compiler.
4340 +dirent.h: dirent.in.h
4341 +       rm -f $@-t $@
4342 +       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
4343 +         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
4344 +             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
4345 +             -e 's|@''NEXT_DIRENT_H''@|$(NEXT_DIRENT_H)|g' \
4346 +             -e 's|@''GNULIB_DIRFD''@|$(GNULIB_DIRFD)|g' \
4347 +             -e 's|@''HAVE_DECL_DIRFD''@|$(HAVE_DECL_DIRFD)|g' \
4348 +             -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
4349 +             -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
4350 +             < $(srcdir)/dirent.in.h; \
4351 +       } > $@-t
4352 +       mv $@-t $@
4353 +MOSTLYCLEANFILES += dirent.h dirent.h-t
4354 +
4355 +EXTRA_DIST += dirent.in.h
4356 +
4357 +## end   gnulib module dirent
4358 +
4359 +## begin gnulib module dirfd
4360 +
4361 +
4362 +EXTRA_DIST += dirfd.c
4363 +
4364 +EXTRA_libgnu_la_SOURCES += dirfd.c
4365 +
4366 +## end   gnulib module dirfd
4367 +
4368 +## begin gnulib module fnmatch
4369 +
4370 +BUILT_SOURCES += $(FNMATCH_H)
4371 +
4372 +# We need the following in order to create <fnmatch.h> when the system
4373 +# doesn't have one that supports the required API.
4374 +fnmatch.h: fnmatch.in.h
4375 +       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
4376 +         cat $(srcdir)/fnmatch.in.h; \
4377 +       } > $@-t
4378 +       mv -f $@-t $@
4379 +MOSTLYCLEANFILES += fnmatch.h fnmatch.h-t
4380 +
4381 +EXTRA_DIST += fnmatch.c fnmatch.in.h fnmatch_loop.c
4382 +
4383 +EXTRA_libgnu_la_SOURCES += fnmatch.c fnmatch_loop.c
4384 +
4385 +## end   gnulib module fnmatch
4386 +
4387 +## begin gnulib module getlogin_r
4388 +
4389 +
4390 +EXTRA_DIST += getlogin_r.c
4391 +
4392 +EXTRA_libgnu_la_SOURCES += getlogin_r.c
4393 +
4394 +## end   gnulib module getlogin_r
4395 +
4396 +## begin gnulib module glob
4397 +
4398 +BUILT_SOURCES += $(GLOB_H)
4399 +
4400 +# We need the following in order to create <glob.h> when the system
4401 +# doesn't have one that works with the given compiler.
4402 +glob.h: glob.in.h
4403 +       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
4404 +         sed -e 's|@''HAVE_SYS_CDEFS_H''@|$(HAVE_SYS_CDEFS_H)|g' \
4405 +             < $(srcdir)/glob.in.h; \
4406 +       } > $@-t
4407 +       mv -f $@-t $@
4408 +MOSTLYCLEANFILES += glob.h glob.h-t
4409 +
4410 +EXTRA_DIST += glob-libc.h glob.c glob.in.h
4411 +
4412 +EXTRA_libgnu_la_SOURCES += glob.c
4413 +
4414 +## end   gnulib module glob
4415 +
4416 +## begin gnulib module link-warning
4417 +
4418 +LINK_WARNING_H=$(top_srcdir)/./link-warning.h
4419 +
4420 +EXTRA_DIST += $(top_srcdir)/./link-warning.h
4421 +
4422 +## end   gnulib module link-warning
4423 +
4424 +## begin gnulib module malloc-posix
4425 +
4426 +
4427 +EXTRA_DIST += malloc.c
4428 +
4429 +EXTRA_libgnu_la_SOURCES += malloc.c
4430 +
4431 +## end   gnulib module malloc-posix
4432 +
4433 +## begin gnulib module mempcpy
4434 +
4435 +
4436 +EXTRA_DIST += mempcpy.c
4437 +
4438 +EXTRA_libgnu_la_SOURCES += mempcpy.c
4439 +
4440 +## end   gnulib module mempcpy
4441 +
4442 +## begin gnulib module stdbool
4443 +
4444 +BUILT_SOURCES += $(STDBOOL_H)
4445 +
4446 +# We need the following in order to create <stdbool.h> when the system
4447 +# doesn't have one that works.
4448 +stdbool.h: stdbool.in.h
4449 +       rm -f $@-t $@
4450 +       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
4451 +         sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool.in.h; \
4452 +       } > $@-t
4453 +       mv $@-t $@
4454 +MOSTLYCLEANFILES += stdbool.h stdbool.h-t
4455 +
4456 +EXTRA_DIST += stdbool.in.h
4457 +
4458 +## end   gnulib module stdbool
4459 +
4460 +## begin gnulib module stdlib
4461 +
4462 +BUILT_SOURCES += stdlib.h
4463 +
4464 +# We need the following in order to create <stdlib.h> when the system
4465 +# doesn't have one that works with the given compiler.
4466 +stdlib.h: stdlib.in.h
4467 +       rm -f $@-t $@
4468 +       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
4469 +         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
4470 +             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
4471 +             -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \
4472 +             -e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \
4473 +             -e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \
4474 +             -e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \
4475 +             -e 's|@''GNULIB_ATOLL''@|$(GNULIB_ATOLL)|g' \
4476 +             -e 's|@''GNULIB_GETLOADAVG''@|$(GNULIB_GETLOADAVG)|g' \
4477 +             -e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \
4478 +             -e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \
4479 +             -e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \
4480 +             -e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \
4481 +             -e 's|@''GNULIB_RAND48''@|$(GNULIB_RAND48)|g' \
4482 +             -e 's|@''GNULIB_RANDOM_R''@|$(GNULIB_RANDOM_R)|g' \
4483 +             -e 's|@''GNULIB_RPMATCH''@|$(GNULIB_RPMATCH)|g' \
4484 +             -e 's|@''GNULIB_SETENV''@|$(GNULIB_SETENV)|g' \
4485 +             -e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \
4486 +             -e 's|@''GNULIB_STRTOLL''@|$(GNULIB_STRTOLL)|g' \
4487 +             -e 's|@''GNULIB_STRTOULL''@|$(GNULIB_STRTOULL)|g' \
4488 +             -e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \
4489 +             -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \
4490 +             -e 's|@''HAVE_CALLOC_POSIX''@|$(HAVE_CALLOC_POSIX)|g' \
4491 +             -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
4492 +             -e 's|@''HAVE_MALLOC_POSIX''@|$(HAVE_MALLOC_POSIX)|g' \
4493 +             -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
4494 +             -e 's|@''HAVE_REALLOC_POSIX''@|$(HAVE_REALLOC_POSIX)|g' \
4495 +             -e 's|@''HAVE_RAND48''@|$(HAVE_RAND48)|g' \
4496 +             -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
4497 +             -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
4498 +             -e 's|@''HAVE_SETENV''@|$(HAVE_SETENV)|g' \
4499 +             -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
4500 +             -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \
4501 +             -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \
4502 +             -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \
4503 +             -e 's|@''HAVE_UNSETENV''@|$(HAVE_UNSETENV)|g' \
4504 +             -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
4505 +             -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
4506 +             -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
4507 +             -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
4508 +             -e 's|@''VOID_UNSETENV''@|$(VOID_UNSETENV)|g' \
4509 +             -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
4510 +             < $(srcdir)/stdlib.in.h; \
4511 +       } > $@-t
4512 +       mv $@-t $@
4513 +MOSTLYCLEANFILES += stdlib.h stdlib.h-t
4514 +
4515 +EXTRA_DIST += stdlib.in.h
4516 +
4517 +## end   gnulib module stdlib
4518 +
4519 +## begin gnulib module strdup
4520 +
4521 +
4522 +EXTRA_DIST += strdup.c
4523 +
4524 +EXTRA_libgnu_la_SOURCES += strdup.c
4525 +
4526 +## end   gnulib module strdup
4527 +
4528 +## begin gnulib module string
4529 +
4530 +BUILT_SOURCES += string.h
4531 +
4532 +# We need the following in order to create <string.h> when the system
4533 +# doesn't have one that works with the given compiler.
4534 +string.h: string.in.h
4535 +       rm -f $@-t $@
4536 +       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
4537 +         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
4538 +             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
4539 +             -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \
4540 +             -e 's|@''GNULIB_MBSLEN''@|$(GNULIB_MBSLEN)|g' \
4541 +             -e 's|@''GNULIB_MBSNLEN''@|$(GNULIB_MBSNLEN)|g' \
4542 +             -e 's|@''GNULIB_MBSCHR''@|$(GNULIB_MBSCHR)|g' \
4543 +             -e 's|@''GNULIB_MBSRCHR''@|$(GNULIB_MBSRCHR)|g' \
4544 +             -e 's|@''GNULIB_MBSSTR''@|$(GNULIB_MBSSTR)|g' \
4545 +             -e 's|@''GNULIB_MBSCASECMP''@|$(GNULIB_MBSCASECMP)|g' \
4546 +             -e 's|@''GNULIB_MBSNCASECMP''@|$(GNULIB_MBSNCASECMP)|g' \
4547 +             -e 's|@''GNULIB_MBSPCASECMP''@|$(GNULIB_MBSPCASECMP)|g' \
4548 +             -e 's|@''GNULIB_MBSCASESTR''@|$(GNULIB_MBSCASESTR)|g' \
4549 +             -e 's|@''GNULIB_MBSCSPN''@|$(GNULIB_MBSCSPN)|g' \
4550 +             -e 's|@''GNULIB_MBSPBRK''@|$(GNULIB_MBSPBRK)|g' \
4551 +             -e 's|@''GNULIB_MBSSPN''@|$(GNULIB_MBSSPN)|g' \
4552 +             -e 's|@''GNULIB_MBSSEP''@|$(GNULIB_MBSSEP)|g' \
4553 +             -e 's|@''GNULIB_MBSTOK_R''@|$(GNULIB_MBSTOK_R)|g' \
4554 +             -e 's|@''GNULIB_MEMMEM''@|$(GNULIB_MEMMEM)|g' \
4555 +             -e 's|@''GNULIB_MEMPCPY''@|$(GNULIB_MEMPCPY)|g' \
4556 +             -e 's|@''GNULIB_MEMRCHR''@|$(GNULIB_MEMRCHR)|g' \
4557 +             -e 's|@''GNULIB_RAWMEMCHR''@|$(GNULIB_RAWMEMCHR)|g' \
4558 +             -e 's|@''GNULIB_STPCPY''@|$(GNULIB_STPCPY)|g' \
4559 +             -e 's|@''GNULIB_STPNCPY''@|$(GNULIB_STPNCPY)|g' \
4560 +             -e 's|@''GNULIB_STRCHRNUL''@|$(GNULIB_STRCHRNUL)|g' \
4561 +             -e 's|@''GNULIB_STRDUP''@|$(GNULIB_STRDUP)|g' \
4562 +             -e 's|@''GNULIB_STRNDUP''@|$(GNULIB_STRNDUP)|g' \
4563 +             -e 's|@''GNULIB_STRNLEN''@|$(GNULIB_STRNLEN)|g' \
4564 +             -e 's|@''GNULIB_STRPBRK''@|$(GNULIB_STRPBRK)|g' \
4565 +             -e 's|@''GNULIB_STRSEP''@|$(GNULIB_STRSEP)|g' \
4566 +             -e 's|@''GNULIB_STRSTR''@|$(GNULIB_STRSTR)|g' \
4567 +             -e 's|@''GNULIB_STRCASESTR''@|$(GNULIB_STRCASESTR)|g' \
4568 +             -e 's|@''GNULIB_STRTOK_R''@|$(GNULIB_STRTOK_R)|g' \
4569 +             -e 's|@''GNULIB_STRERROR''@|$(GNULIB_STRERROR)|g' \
4570 +             -e 's|@''GNULIB_STRSIGNAL''@|$(GNULIB_STRSIGNAL)|g' \
4571 +             -e 's|@''GNULIB_STRVERSCMP''@|$(GNULIB_STRVERSCMP)|g' \
4572 +             -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
4573 +             -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \
4574 +             -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \
4575 +             -e 's|@''HAVE_RAWMEMCHR''@|$(HAVE_RAWMEMCHR)|g' \
4576 +             -e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \
4577 +             -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \
4578 +             -e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \
4579 +             -e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \
4580 +             -e 's|@''HAVE_STRNDUP''@|$(HAVE_STRNDUP)|g' \
4581 +             -e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \
4582 +             -e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \
4583 +             -e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \
4584 +             -e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \
4585 +             -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \
4586 +             -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \
4587 +             -e 's|@''HAVE_DECL_STRERROR''@|$(HAVE_DECL_STRERROR)|g' \
4588 +             -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
4589 +             -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \
4590 +             -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
4591 +             -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \
4592 +             -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
4593 +             -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
4594 +             -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
4595 +             -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
4596 +             -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
4597 +             < $(srcdir)/string.in.h; \
4598 +       } > $@-t
4599 +       mv $@-t $@
4600 +MOSTLYCLEANFILES += string.h string.h-t
4601 +
4602 +EXTRA_DIST += string.in.h
4603 +
4604 +## end   gnulib module string
4605 +
4606 +## begin gnulib module sys_stat
4607 +
4608 +BUILT_SOURCES += $(SYS_STAT_H)
4609 +
4610 +# We need the following in order to create <sys/stat.h> when the system
4611 +# has one that is incomplete.
4612 +sys/stat.h: sys_stat.in.h
4613 +       @MKDIR_P@ sys
4614 +       rm -f $@-t $@
4615 +       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
4616 +         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
4617 +             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
4618 +             -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
4619 +             -e 's|@''GNULIB_LCHMOD''@|$(GNULIB_LCHMOD)|g' \
4620 +             -e 's|@''GNULIB_LSTAT''@|$(GNULIB_LSTAT)|g' \
4621 +             -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \
4622 +             -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \
4623 +             -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \
4624 +             -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \
4625 +             -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
4626 +             < $(srcdir)/sys_stat.in.h; \
4627 +       } > $@-t
4628 +       mv $@-t $@
4629 +MOSTLYCLEANFILES += sys/stat.h sys/stat.h-t
4630 +MOSTLYCLEANDIRS += sys
4631 +
4632 +EXTRA_DIST += sys_stat.in.h
4633 +
4634 +## end   gnulib module sys_stat
4635 +
4636 +## begin gnulib module unistd
4637 +
4638 +BUILT_SOURCES += unistd.h
4639 +
4640 +# We need the following in order to create an empty placeholder for
4641 +# <unistd.h> when the system doesn't have one.
4642 +unistd.h: unistd.in.h
4643 +       rm -f $@-t $@
4644 +       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
4645 +         sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
4646 +             -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
4647 +             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
4648 +             -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \
4649 +             -e 's|@''GNULIB_CHOWN''@|$(GNULIB_CHOWN)|g' \
4650 +             -e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \
4651 +             -e 's|@''GNULIB_DUP2''@|$(GNULIB_DUP2)|g' \
4652 +             -e 's|@''GNULIB_ENVIRON''@|$(GNULIB_ENVIRON)|g' \
4653 +             -e 's|@''GNULIB_EUIDACCESS''@|$(GNULIB_EUIDACCESS)|g' \
4654 +             -e 's|@''GNULIB_FCHDIR''@|$(GNULIB_FCHDIR)|g' \
4655 +             -e 's|@''GNULIB_FSYNC''@|$(GNULIB_FSYNC)|g' \
4656 +             -e 's|@''GNULIB_FTRUNCATE''@|$(GNULIB_FTRUNCATE)|g' \
4657 +             -e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \
4658 +             -e 's|@''GNULIB_GETDOMAINNAME''@|$(GNULIB_GETDOMAINNAME)|g' \
4659 +             -e 's|@''GNULIB_GETDTABLESIZE''@|$(GNULIB_GETDTABLESIZE)|g' \
4660 +             -e 's|@''GNULIB_GETHOSTNAME''@|$(GNULIB_GETHOSTNAME)|g' \
4661 +             -e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \
4662 +             -e 's|@''GNULIB_GETPAGESIZE''@|$(GNULIB_GETPAGESIZE)|g' \
4663 +             -e 's|@''GNULIB_GETUSERSHELL''@|$(GNULIB_GETUSERSHELL)|g' \
4664 +             -e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \
4665 +             -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \
4666 +             -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \
4667 +             -e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \
4668 +             -e 's|@''GNULIB_UNISTD_H_SIGPIPE''@|$(GNULIB_UNISTD_H_SIGPIPE)|g' \
4669 +             -e 's|@''GNULIB_WRITE''@|$(GNULIB_WRITE)|g' \
4670 +             -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \
4671 +             -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \
4672 +             -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \
4673 +             -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \
4674 +             -e 's|@''HAVE_GETDOMAINNAME''@|$(HAVE_GETDOMAINNAME)|g' \
4675 +             -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \
4676 +             -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \
4677 +             -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
4678 +             -e 's|@''HAVE_GETUSERSHELL''@|$(HAVE_GETUSERSHELL)|g' \
4679 +             -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
4680 +             -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
4681 +             -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
4682 +             -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
4683 +             -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \
4684 +             -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \
4685 +             -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \
4686 +             -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \
4687 +             -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
4688 +             -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
4689 +             -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
4690 +             -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
4691 +             -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
4692 +             -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \
4693 +             -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \
4694 +             -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
4695 +             < $(srcdir)/unistd.in.h; \
4696 +       } > $@-t
4697 +       mv $@-t $@
4698 +MOSTLYCLEANFILES += unistd.h unistd.h-t
4699 +
4700 +EXTRA_DIST += unistd.in.h
4701 +
4702 +## end   gnulib module unistd
4703 +
4704 +## begin gnulib module wchar
4705 +
4706 +BUILT_SOURCES += $(WCHAR_H)
4707 +
4708 +# We need the following in order to create <wchar.h> when the system
4709 +# version does not work standalone.
4710 +wchar.h: wchar.in.h
4711 +       rm -f $@-t $@
4712 +       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
4713 +         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
4714 +             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
4715 +             -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \
4716 +             -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \
4717 +             -e 's|@''GNULIB_WCWIDTH''@|$(GNULIB_WCWIDTH)|g' \
4718 +             -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \
4719 +             -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \
4720 +             -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
4721 +             -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
4722 +           < $(srcdir)/wchar.in.h; \
4723 +       } > $@-t
4724 +       mv $@-t $@
4725 +MOSTLYCLEANFILES += wchar.h wchar.h-t
4726 +
4727 +EXTRA_DIST += wchar.in.h
4728 +
4729 +## end   gnulib module wchar
4730 +
4731 +## begin gnulib module wctype
4732 +
4733 +BUILT_SOURCES += $(WCTYPE_H)
4734 +
4735 +# We need the following in order to create <wctype.h> when the system
4736 +# doesn't have one that works with the given compiler.
4737 +wctype.h: wctype.in.h
4738 +       rm -f $@-t $@
4739 +       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
4740 +         sed -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \
4741 +             -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
4742 +             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
4743 +             -e 's|@''NEXT_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \
4744 +             -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \
4745 +             -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \
4746 +             -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \
4747 +             < $(srcdir)/wctype.in.h; \
4748 +       } > $@-t
4749 +       mv $@-t $@
4750 +MOSTLYCLEANFILES += wctype.h wctype.h-t
4751 +
4752 +EXTRA_DIST += wctype.in.h
4753 +
4754 +## end   gnulib module wctype
4755 +
4756 +## begin gnulib module dummy
4757 +
4758 +libgnu_la_SOURCES += dummy.c
4759 +
4760 +## end   gnulib module dummy
4761 +
4762 +
4763 +mostlyclean-local: mostlyclean-generic
4764 +       @for dir in '' $(MOSTLYCLEANDIRS); do \
4765 +         if test -n "$$dir" && test -d $$dir; then \
4766 +           echo "rmdir $$dir"; rmdir $$dir; \
4767 +         fi; \
4768 +       done; \
4769 +       :
4770 diff -urN popt-for-windows/lib/malloc.c popt-for-windows-gnulib/lib/malloc.c
4771 --- popt-for-windows/lib/malloc.c       1970-01-01 01:00:00.000000000 +0100
4772 +++ popt-for-windows-gnulib/lib/malloc.c        2008-10-25 15:17:05.000000000 +0100
4773 @@ -0,0 +1,57 @@
4774 +/* malloc() function that is glibc compatible.
4775 +
4776 +   Copyright (C) 1997, 1998, 2006, 2007 Free Software Foundation, Inc.
4777 +
4778 +   This program is free software; you can redistribute it and/or modify
4779 +   it under the terms of the GNU General Public License as published by
4780 +   the Free Software Foundation; either version 3, or (at your option)
4781 +   any later version.
4782 +
4783 +   This program is distributed in the hope that it will be useful,
4784 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
4785 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4786 +   GNU General Public License for more details.
4787 +
4788 +   You should have received a copy of the GNU General Public License
4789 +   along with this program; if not, write to the Free Software Foundation,
4790 +   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
4791 +
4792 +/* written by Jim Meyering and Bruno Haible */
4793 +
4794 +#include <config.h>
4795 +/* Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h.  */
4796 +#ifdef malloc
4797 +# define NEED_MALLOC_GNU
4798 +# undef malloc
4799 +#endif
4800 +
4801 +/* Specification.  */
4802 +#include <stdlib.h>
4803 +
4804 +#include <errno.h>
4805 +
4806 +/* Call the system's malloc below.  */
4807 +#undef malloc
4808 +
4809 +/* Allocate an N-byte block of memory from the heap.
4810 +   If N is zero, allocate a 1-byte block.  */
4811 +
4812 +void *
4813 +rpl_malloc (size_t n)
4814 +{
4815 +  void *result;
4816 +
4817 +#ifdef NEED_MALLOC_GNU
4818 +  if (n == 0)
4819 +    n = 1;
4820 +#endif
4821 +
4822 +  result = malloc (n);
4823 +
4824 +#if !HAVE_MALLOC_POSIX
4825 +  if (result == NULL)
4826 +    errno = ENOMEM;
4827 +#endif
4828 +
4829 +  return result;
4830 +}
4831 diff -urN popt-for-windows/lib/mempcpy.c popt-for-windows-gnulib/lib/mempcpy.c
4832 --- popt-for-windows/lib/mempcpy.c      1970-01-01 01:00:00.000000000 +0100
4833 +++ popt-for-windows-gnulib/lib/mempcpy.c       2008-10-25 15:17:05.000000000 +0100
4834 @@ -0,0 +1,29 @@
4835 +/* Copy memory area and return pointer after last written byte.
4836 +   Copyright (C) 2003, 2007 Free Software Foundation, Inc.
4837 +
4838 +   This program is free software; you can redistribute it and/or modify
4839 +   it under the terms of the GNU General Public License as published by
4840 +   the Free Software Foundation; either version 3, or (at your option)
4841 +   any later version.
4842 +
4843 +   This program is distributed in the hope that it will be useful,
4844 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
4845 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4846 +   GNU General Public License for more details.
4847 +
4848 +   You should have received a copy of the GNU General Public License
4849 +   along with this program; if not, write to the Free Software Foundation,
4850 +   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
4851 +
4852 +#include <config.h>
4853 +
4854 +/* Specification.  */
4855 +#include <string.h>
4856 +
4857 +/* Copy N bytes of SRC to DEST, return pointer to bytes after the
4858 +   last written byte.  */
4859 +void *
4860 +mempcpy (void *dest, const void *src, size_t n)
4861 +{
4862 +  return (char *) memcpy (dest, src, n) + n;
4863 +}
4864 diff -urN popt-for-windows/lib/stdbool.in.h popt-for-windows-gnulib/lib/stdbool.in.h
4865 --- popt-for-windows/lib/stdbool.in.h   1970-01-01 01:00:00.000000000 +0100
4866 +++ popt-for-windows-gnulib/lib/stdbool.in.h    2008-10-25 15:17:05.000000000 +0100
4867 @@ -0,0 +1,119 @@
4868 +/* Copyright (C) 2001-2003, 2006-2008 Free Software Foundation, Inc.
4869 +   Written by Bruno Haible <haible@clisp.cons.org>, 2001.
4870 +
4871 +   This program is free software; you can redistribute it and/or modify
4872 +   it under the terms of the GNU General Public License as published by
4873 +   the Free Software Foundation; either version 3, or (at your option)
4874 +   any later version.
4875 +
4876 +   This program is distributed in the hope that it will be useful,
4877 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
4878 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4879 +   GNU General Public License for more details.
4880 +
4881 +   You should have received a copy of the GNU General Public License
4882 +   along with this program; if not, write to the Free Software Foundation,
4883 +   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
4884 +
4885 +#ifndef _GL_STDBOOL_H
4886 +#define _GL_STDBOOL_H
4887 +
4888 +/* ISO C 99 <stdbool.h> for platforms that lack it.  */
4889 +
4890 +/* Usage suggestions:
4891 +
4892 +   Programs that use <stdbool.h> should be aware of some limitations
4893 +   and standards compliance issues.
4894 +
4895 +   Standards compliance:
4896 +
4897 +       - <stdbool.h> must be #included before 'bool', 'false', 'true'
4898 +         can be used.
4899 +
4900 +       - You cannot assume that sizeof (bool) == 1.
4901 +
4902 +       - Programs should not undefine the macros bool, true, and false,
4903 +         as C99 lists that as an "obsolescent feature".
4904 +
4905 +   Limitations of this substitute, when used in a C89 environment:
4906 +
4907 +       - <stdbool.h> must be #included before the '_Bool' type can be used.
4908 +
4909 +       - You cannot assume that _Bool is a typedef; it might be a macro.
4910 +
4911 +       - Bit-fields of type 'bool' are not supported.  Portable code
4912 +         should use 'unsigned int foo : 1;' rather than 'bool foo : 1;'.
4913 +
4914 +       - In C99, casts and automatic conversions to '_Bool' or 'bool' are
4915 +         performed in such a way that every nonzero value gets converted
4916 +         to 'true', and zero gets converted to 'false'.  This doesn't work
4917 +         with this substitute.  With this substitute, only the values 0 and 1
4918 +         give the expected result when converted to _Bool' or 'bool'.
4919 +
4920 +   Also, it is suggested that programs use 'bool' rather than '_Bool';
4921 +   this isn't required, but 'bool' is more common.  */
4922 +
4923 +
4924 +/* 7.16. Boolean type and values */
4925 +
4926 +/* BeOS <sys/socket.h> already #defines false 0, true 1.  We use the same
4927 +   definitions below, but temporarily we have to #undef them.  */
4928 +#if defined __BEOS__ && !defined __HAIKU__
4929 +# include <OS.h> /* defines bool but not _Bool */
4930 +# undef false
4931 +# undef true
4932 +#endif
4933 +
4934 +/* For the sake of symbolic names in gdb, we define true and false as
4935 +   enum constants, not only as macros.
4936 +   It is tempting to write
4937 +      typedef enum { false = 0, true = 1 } _Bool;
4938 +   so that gdb prints values of type 'bool' symbolically. But if we do
4939 +   this, values of type '_Bool' may promote to 'int' or 'unsigned int'
4940 +   (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
4941 +   (see ISO C 99 6.3.1.1.(2)).  So we add a negative value to the
4942 +   enum; this ensures that '_Bool' promotes to 'int'.  */
4943 +#if defined __cplusplus || (defined __BEOS__ && !defined __HAIKU__)
4944 +  /* A compiler known to have 'bool'.  */
4945 +  /* If the compiler already has both 'bool' and '_Bool', we can assume they
4946 +     are the same types.  */
4947 +# if !@HAVE__BOOL@
4948 +typedef bool _Bool;
4949 +# endif
4950 +#else
4951 +# if !defined __GNUC__
4952 +   /* If @HAVE__BOOL@:
4953 +        Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when
4954 +        the built-in _Bool type is used.  See
4955 +          http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
4956 +          http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
4957 +          http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
4958 +        Similar bugs are likely with other compilers as well; this file
4959 +        wouldn't be used if <stdbool.h> was working.
4960 +        So we override the _Bool type.
4961 +      If !@HAVE__BOOL@:
4962 +        Need to define _Bool ourselves. As 'signed char' or as an enum type?
4963 +        Use of a typedef, with SunPRO C, leads to a stupid
4964 +          "warning: _Bool is a keyword in ISO C99".
4965 +        Use of an enum type, with IRIX cc, leads to a stupid
4966 +          "warning(1185): enumerated type mixed with another type".
4967 +        Even the existence of an enum type, without a typedef,
4968 +          "Invalid enumerator. (badenum)" with HP-UX cc on Tru64.
4969 +        The only benefit of the enum, debuggability, is not important
4970 +        with these compilers.  So use 'signed char' and no enum.  */
4971 +#  define _Bool signed char
4972 +# else
4973 +   /* With this compiler, trust the _Bool type if the compiler has it.  */
4974 +#  if !@HAVE__BOOL@
4975 +typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
4976 +#  endif
4977 +# endif
4978 +#endif
4979 +#define bool _Bool
4980 +
4981 +/* The other macros must be usable in preprocessor directives.  */
4982 +#define false 0
4983 +#define true 1
4984 +#define __bool_true_false_are_defined 1
4985 +
4986 +#endif /* _GL_STDBOOL_H */
4987 diff -urN popt-for-windows/lib/stdlib.in.h popt-for-windows-gnulib/lib/stdlib.in.h
4988 --- popt-for-windows/lib/stdlib.in.h    1970-01-01 01:00:00.000000000 +0100
4989 +++ popt-for-windows-gnulib/lib/stdlib.in.h     2008-10-25 15:17:05.000000000 +0100
4990 @@ -0,0 +1,486 @@
4991 +/* A GNU-like <stdlib.h>.
4992 +
4993 +   Copyright (C) 1995, 2001-2004, 2006-2008 Free Software Foundation, Inc.
4994 +
4995 +   This program is free software: you can redistribute it and/or modify
4996 +   it under the terms of the GNU General Public License as published by
4997 +   the Free Software Foundation; either version 3 of the License, or
4998 +   (at your option) any later version.
4999 +
5000 +   This program is distributed in the hope that it will be useful,
5001 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
5002 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5003 +   GNU General Public License for more details.
5004 +
5005 +   You should have received a copy of the GNU General Public License
5006 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
5007 +
5008 +#if __GNUC__ >= 3
5009 +@PRAGMA_SYSTEM_HEADER@
5010 +#endif
5011 +
5012 +#if defined __need_malloc_and_calloc
5013 +/* Special invocation convention inside glibc header files.  */
5014 +
5015 +#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
5016 +
5017 +#else
5018 +/* Normal invocation convention.  */
5019 +
5020 +#ifndef _GL_STDLIB_H
5021 +
5022 +/* The include_next requires a split double-inclusion guard.  */
5023 +#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
5024 +
5025 +#ifndef _GL_STDLIB_H
5026 +#define _GL_STDLIB_H
5027 +
5028 +
5029 +/* Solaris declares getloadavg() in <sys/loadavg.h>.  */
5030 +#if @GNULIB_GETLOADAVG@ && @HAVE_SYS_LOADAVG_H@
5031 +# include <sys/loadavg.h>
5032 +#endif
5033 +
5034 +/* The definition of GL_LINK_WARNING is copied here.  */
5035 +
5036 +
5037 +/* Some systems do not define EXIT_*, despite otherwise supporting C89.  */
5038 +#ifndef EXIT_SUCCESS
5039 +# define EXIT_SUCCESS 0
5040 +#endif
5041 +/* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
5042 +   with proper operation of xargs.  */
5043 +#ifndef EXIT_FAILURE
5044 +# define EXIT_FAILURE 1
5045 +#elif EXIT_FAILURE != 1
5046 +# undef EXIT_FAILURE
5047 +# define EXIT_FAILURE 1
5048 +#endif
5049 +
5050 +
5051 +#ifdef __cplusplus
5052 +extern "C" {
5053 +#endif
5054 +
5055 +
5056 +#if @GNULIB_MALLOC_POSIX@
5057 +# if !@HAVE_MALLOC_POSIX@
5058 +#  undef malloc
5059 +#  define malloc rpl_malloc
5060 +extern void * malloc (size_t size);
5061 +# endif
5062 +#elif defined GNULIB_POSIXCHECK
5063 +# undef malloc
5064 +# define malloc(s) \
5065 +    (GL_LINK_WARNING ("malloc is not POSIX compliant everywhere - " \
5066 +                      "use gnulib module malloc-posix for portability"), \
5067 +     malloc (s))
5068 +#endif
5069 +
5070 +
5071 +#if @GNULIB_REALLOC_POSIX@
5072 +# if !@HAVE_REALLOC_POSIX@
5073 +#  undef realloc
5074 +#  define realloc rpl_realloc
5075 +extern void * realloc (void *ptr, size_t size);
5076 +# endif
5077 +#elif defined GNULIB_POSIXCHECK
5078 +# undef realloc
5079 +# define realloc(p,s) \
5080 +    (GL_LINK_WARNING ("realloc is not POSIX compliant everywhere - " \
5081 +                      "use gnulib module realloc-posix for portability"), \
5082 +     realloc (p, s))
5083 +#endif
5084 +
5085 +
5086 +#if @GNULIB_CALLOC_POSIX@
5087 +# if !@HAVE_CALLOC_POSIX@
5088 +#  undef calloc
5089 +#  define calloc rpl_calloc
5090 +extern void * calloc (size_t nmemb, size_t size);
5091 +# endif
5092 +#elif defined GNULIB_POSIXCHECK
5093 +# undef calloc
5094 +# define calloc(n,s) \
5095 +    (GL_LINK_WARNING ("calloc is not POSIX compliant everywhere - " \
5096 +                      "use gnulib module calloc-posix for portability"), \
5097 +     calloc (n, s))
5098 +#endif
5099 +
5100 +
5101 +#if @GNULIB_ATOLL@
5102 +# if !@HAVE_ATOLL@
5103 +/* Parse a signed decimal integer.
5104 +   Returns the value of the integer.  Errors are not detected.  */
5105 +extern long long atoll (const char *string);
5106 +# endif
5107 +#elif defined GNULIB_POSIXCHECK
5108 +# undef atoll
5109 +# define atoll(s) \
5110 +    (GL_LINK_WARNING ("atoll is unportable - " \
5111 +                      "use gnulib module atoll for portability"), \
5112 +     atoll (s))
5113 +#endif
5114 +
5115 +
5116 +#if @GNULIB_GETLOADAVG@
5117 +# if !@HAVE_DECL_GETLOADAVG@
5118 +/* Store max(NELEM,3) load average numbers in LOADAVG[].
5119 +   The three numbers are the load average of the last 1 minute, the last 5
5120 +   minutes, and the last 15 minutes, respectively.
5121 +   LOADAVG is an array of NELEM numbers.  */
5122 +extern int getloadavg (double loadavg[], int nelem);
5123 +# endif
5124 +#elif defined GNULIB_POSIXCHECK
5125 +# undef getloadavg
5126 +# define getloadavg(l,n) \
5127 +    (GL_LINK_WARNING ("getloadavg is not portable - " \
5128 +                      "use gnulib module getloadavg for portability"), \
5129 +     getloadavg (l, n))
5130 +#endif
5131 +
5132 +
5133 +#if @GNULIB_GETSUBOPT@
5134 +/* Assuming *OPTIONP is a comma separated list of elements of the form
5135 +   "token" or "token=value", getsubopt parses the first of these elements.
5136 +   If the first element refers to a "token" that is member of the given
5137 +   NULL-terminated array of tokens:
5138 +     - It replaces the comma with a NUL byte, updates *OPTIONP to point past
5139 +       the first option and the comma, sets *VALUEP to the value of the
5140 +       element (or NULL if it doesn't contain an "=" sign),
5141 +     - It returns the index of the "token" in the given array of tokens.
5142 +   Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
5143 +   For more details see the POSIX:2001 specification.
5144 +   http://www.opengroup.org/susv3xsh/getsubopt.html */
5145 +# if !@HAVE_GETSUBOPT@
5146 +extern int getsubopt (char **optionp, char *const *tokens, char **valuep);
5147 +# endif
5148 +#elif defined GNULIB_POSIXCHECK
5149 +# undef getsubopt
5150 +# define getsubopt(o,t,v) \
5151 +    (GL_LINK_WARNING ("getsubopt is unportable - " \
5152 +                      "use gnulib module getsubopt for portability"), \
5153 +     getsubopt (o, t, v))
5154 +#endif
5155 +
5156 +
5157 +#if @GNULIB_MKDTEMP@
5158 +# if !@HAVE_MKDTEMP@
5159 +/* Create a unique temporary directory from TEMPLATE.
5160 +   The last six characters of TEMPLATE must be "XXXXXX";
5161 +   they are replaced with a string that makes the directory name unique.
5162 +   Returns TEMPLATE, or a null pointer if it cannot get a unique name.
5163 +   The directory is created mode 700.  */
5164 +extern char * mkdtemp (char * /*template*/);
5165 +# endif
5166 +#elif defined GNULIB_POSIXCHECK
5167 +# undef mkdtemp
5168 +# define mkdtemp(t) \
5169 +    (GL_LINK_WARNING ("mkdtemp is unportable - " \
5170 +                      "use gnulib module mkdtemp for portability"), \
5171 +     mkdtemp (t))
5172 +#endif
5173 +
5174 +
5175 +#if @GNULIB_MKSTEMP@
5176 +# if @REPLACE_MKSTEMP@
5177 +/* Create a unique temporary file from TEMPLATE.
5178 +   The last six characters of TEMPLATE must be "XXXXXX";
5179 +   they are replaced with a string that makes the file name unique.
5180 +   The file is then created, ensuring it didn't exist before.
5181 +   The file is created read-write (mask at least 0600 & ~umask), but it may be
5182 +   world-readable and world-writable (mask 0666 & ~umask), depending on the
5183 +   implementation.
5184 +   Returns the open file descriptor if successful, otherwise -1 and errno
5185 +   set.  */
5186 +#  define mkstemp rpl_mkstemp
5187 +extern int mkstemp (char * /*template*/);
5188 +# else
5189 +/* On MacOS X 10.3, only <unistd.h> declares mkstemp.  */
5190 +#  include <unistd.h>
5191 +# endif
5192 +#elif defined GNULIB_POSIXCHECK
5193 +# undef mkstemp
5194 +# define mkstemp(t) \
5195 +    (GL_LINK_WARNING ("mkstemp is unportable - " \
5196 +                      "use gnulib module mkstemp for portability"), \
5197 +     mkstemp (t))
5198 +#endif
5199 +
5200 +
5201 +#if @GNULIB_PUTENV@
5202 +# if @REPLACE_PUTENV@
5203 +#  undef putenv
5204 +#  define putenv rpl_putenv
5205 +extern int putenv (char *string);
5206 +# endif
5207 +#endif
5208 +
5209 +
5210 +#if @GNULIB_RAND48@
5211 +# if !@HAVE_RAND48@
5212 +
5213 +struct drand48_data
5214 +  {
5215 +    unsigned short int __x[3];  /* Current state.  */
5216 +    unsigned short int __old_x[3]; /* Old state.  */
5217 +    unsigned short int __c;     /* Additive const. in congruential formula.  */
5218 +    unsigned short int __init;  /* Flag for initializing.  */
5219 +    unsigned long long int __a; /* Factor in congruential formula.  */
5220 +  };
5221 +
5222 +double drand48 (void);
5223 +int drand48_r (struct drand48_data *buffer, double *result);
5224 +double erand48 ( unsigned short int xsubi[3]);
5225 +int erand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, double *result);
5226 +long int jrand48 (unsigned short int xsubi[3]);
5227 +int jrand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, long int *result);
5228 +void lcong48 (unsigned short int param[7]);
5229 +int lcong48_r (unsigned short int param[7], struct drand48_data *buffer);
5230 +long int lrand48 ();
5231 +int lrand48_r (struct drand48_data *buffer, long int *result);
5232 +long int mrand48 ();
5233 +int mrand48_r (struct drand48_data *buffer, long int *result);
5234 +long int nrand48 (unsigned short int xsubi[3]);
5235 +int nrand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, long int *result);
5236 +unsigned short int *seed48 (unsigned short int seed16v[3]);
5237 +int seed48_r (unsigned short int seed16v[3], struct drand48_data *buffer);
5238 +void srand48 (long seedval);
5239 +int srand48_r (long int seedval, struct drand48_data *buffer);
5240 +
5241 +# endif
5242 +#elif defined GNULIB_POSIXCHECK
5243 +# undef drand48
5244 +# define drand48()                               \
5245 +    (GL_LINK_WARNING ("drand48 is unportable - " \
5246 +                      "use gnulib module rand48 for portability"), \
5247 +     drand48 ())
5248 +# undef drand48_r
5249 +# define drand48_r(b,r)                                 \
5250 +    (GL_LINK_WARNING ("drand48_r is unportable - " \
5251 +                      "use gnulib module rand48 for portability"), \
5252 +     drand48_r (b,r))
5253 +# undef erand48
5254 +# define erand48(a)                              \
5255 +    (GL_LINK_WARNING ("erand48 is unportable - " \
5256 +                      "use gnulib module rand48 for portability"), \
5257 +     erand48 (a))
5258 +# undef erand48_r
5259 +# define erand48_r(a,b,r)                       \
5260 +    (GL_LINK_WARNING ("erand48_r is unportable - " \
5261 +                      "use gnulib module rand48 for portability"), \
5262 +     erand48_r (a,b,r))
5263 +# undef jrand48
5264 +# define jrand48(a)                              \
5265 +    (GL_LINK_WARNING ("jrand48 is unportable - " \
5266 +                      "use gnulib module rand48 for portability"), \
5267 +     jrand48 (a))
5268 +# undef jrand48_r
5269 +# define jrand48_r(a,b,r)                       \
5270 +    (GL_LINK_WARNING ("drand48 is unportable - " \
5271 +                      "use gnulib module rand48 for portability"), \
5272 +     jrand48_r (a,b,r))
5273 +# undef lcong48
5274 +# define lcong48(p)                              \
5275 +    (GL_LINK_WARNING ("lcong48 is unportable - " \
5276 +                      "use gnulib module rand48 for portability"), \
5277 +     lcong48 (p))
5278 +# undef lcong48_r
5279 +# define lcong48_r(p,b)                                 \
5280 +    (GL_LINK_WARNING ("lcong48_r is unportable - " \
5281 +                      "use gnulib module rand48 for portability"), \
5282 +     lcong48_r (p,b))
5283 +# undef lrand48
5284 +# define lrand48()                               \
5285 +    (GL_LINK_WARNING ("lrand48 is unportable - " \
5286 +                      "use gnulib module rand48 for portability"), \
5287 +     lrand48 ())
5288 +# undef lrand48_r
5289 +# define lrand48_r(b,r)                                 \
5290 +    (GL_LINK_WARNING ("lrand48_r is unportable - " \
5291 +                      "use gnulib module rand48 for portability"), \
5292 +     lrand48_r (b,r))
5293 +# undef mrand48
5294 +# define mrand48()                               \
5295 +    (GL_LINK_WARNING ("mrand48 is unportable - " \
5296 +                      "use gnulib module rand48 for portability"), \
5297 +     mrand48 ())
5298 +# undef mrand48_r
5299 +# define mrand48_r(b,r)                                   \
5300 +    (GL_LINK_WARNING ("mrand48_r is unportable - " \
5301 +                      "use gnulib module rand48 for portability"), \
5302 +     mrand48_r (b,r))
5303 +# undef nrand48
5304 +# define nrand48(a)                             \
5305 +    (GL_LINK_WARNING ("nrand48 is unportable - " \
5306 +                      "use gnulib module rand48 for portability"), \
5307 +     nrand48 (a,))
5308 +# undef nrand48_r
5309 +# define nrand48_r(a,b,r)                         \
5310 +    (GL_LINK_WARNING ("nrand48_r is unportable - " \
5311 +                      "use gnulib module rand48 for portability"), \
5312 +     nrand48_r (a,b,r))
5313 +# undef seed48
5314 +# define seed48(s)                               \
5315 +    (GL_LINK_WARNING ("seed48 is unportable - " \
5316 +                      "use gnulib module rand48 for portability"), \
5317 +     seed48 (s))
5318 +# undef seed48_r
5319 +# define seed48_r(s,b)                            \
5320 +    (GL_LINK_WARNING ("seed48_r is unportable - " \
5321 +                      "use gnulib module rand48 for portability"), \
5322 +     seed48_r (s,b))
5323 +# undef srand48
5324 +# define srand48(s)                              \
5325 +    (GL_LINK_WARNING ("srand48 is unportable - " \
5326 +                      "use gnulib module rand48 for portability"), \
5327 +     srand48 (s))
5328 +# undef srand48_r
5329 +# define srand48_r(s,b)                                   \
5330 +    (GL_LINK_WARNING ("srand48_r is unportable - " \
5331 +                      "use gnulib module rand48 for portability"), \
5332 +     srand48_r (s,b))
5333 +#endif
5334 +
5335 +
5336 +#if @GNULIB_RANDOM_R@
5337 +# if !@HAVE_RANDOM_R@
5338 +
5339 +#  ifndef RAND_MAX
5340 +#   define RAND_MAX 2147483647
5341 +#  endif
5342 +
5343 +int srandom_r (unsigned int seed, struct random_data *rand_state);
5344 +int initstate_r (unsigned int seed, char *buf, size_t buf_size,
5345 +                struct random_data *rand_state);
5346 +int setstate_r (char *arg_state, struct random_data *rand_state);
5347 +int random_r (struct random_data *buf, int32_t *result);
5348 +# endif
5349 +#elif defined GNULIB_POSIXCHECK
5350 +# undef random_r
5351 +# define random_r(b,r)                           \
5352 +    (GL_LINK_WARNING ("random_r is unportable - " \
5353 +                      "use gnulib module random_r for portability"), \
5354 +     random_r (b,r))
5355 +# undef initstate_r
5356 +# define initstate_r(s,b,sz,r)                      \
5357 +    (GL_LINK_WARNING ("initstate_r is unportable - " \
5358 +                      "use gnulib module random_r for portability"), \
5359 +     initstate_r (s,b,sz,r))
5360 +# undef srandom_r
5361 +# define srandom_r(s,r)                                   \
5362 +    (GL_LINK_WARNING ("srandom_r is unportable - " \
5363 +                      "use gnulib module random_r for portability"), \
5364 +     srandom_r (s,r))
5365 +# undef setstate_r
5366 +# define setstate_r(a,r)                                   \
5367 +    (GL_LINK_WARNING ("setstate_r is unportable - " \
5368 +                      "use gnulib module random_r for portability"), \
5369 +     setstate_r (a,r))
5370 +#endif
5371 +
5372 +
5373 +#if @GNULIB_RPMATCH@
5374 +# if !@HAVE_RPMATCH@
5375 +/* Test a user response to a question.
5376 +   Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear.  */
5377 +extern int rpmatch (const char *response);
5378 +# endif
5379 +#elif defined GNULIB_POSIXCHECK
5380 +# undef rpmatch
5381 +# define rpmatch(r) \
5382 +    (GL_LINK_WARNING ("rpmatch is unportable - " \
5383 +                      "use gnulib module rpmatch for portability"), \
5384 +     rpmatch (r))
5385 +#endif
5386 +
5387 +
5388 +#if @GNULIB_SETENV@
5389 +# if !@HAVE_SETENV@
5390 +/* Set NAME to VALUE in the environment.
5391 +   If REPLACE is nonzero, overwrite an existing value.  */
5392 +extern int setenv (const char *name, const char *value, int replace);
5393 +# endif
5394 +#endif
5395 +
5396 +
5397 +#if @GNULIB_UNSETENV@
5398 +# if @HAVE_UNSETENV@
5399 +#  if @VOID_UNSETENV@
5400 +/* On some systems, unsetenv() returns void.
5401 +   This is the case for MacOS X 10.3, FreeBSD 4.8, NetBSD 1.6, OpenBSD 3.4.  */
5402 +#   define unsetenv(name) ((unsetenv)(name), 0)
5403 +#  endif
5404 +# else
5405 +/* Remove the variable NAME from the environment.  */
5406 +extern int unsetenv (const char *name);
5407 +# endif
5408 +#endif
5409 +
5410 +
5411 +#if @GNULIB_STRTOD@
5412 +# if @REPLACE_STRTOD@
5413 +#  define strtod rpl_strtod
5414 +# endif
5415 +# if !@HAVE_STRTOD@ || @REPLACE_STRTOD@
5416 + /* Parse a double from STRING, updating ENDP if appropriate.  */
5417 +extern double strtod (const char *str, char **endp);
5418 +# endif
5419 +#elif defined GNULIB_POSIXCHECK
5420 +# undef strtod
5421 +# define strtod(s, e)                           \
5422 +    (GL_LINK_WARNING ("strtod is unportable - " \
5423 +                      "use gnulib module strtod for portability"), \
5424 +     strtod (s, e))
5425 +#endif
5426 +
5427 +
5428 +#if @GNULIB_STRTOLL@
5429 +# if !@HAVE_STRTOLL@
5430 +/* Parse a signed integer whose textual representation starts at STRING.
5431 +   The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
5432 +   it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
5433 +   "0x").
5434 +   If ENDPTR is not NULL, the address of the first byte after the integer is
5435 +   stored in *ENDPTR.
5436 +   Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
5437 +   to ERANGE.  */
5438 +extern long long strtoll (const char *string, char **endptr, int base);
5439 +# endif
5440 +#elif defined GNULIB_POSIXCHECK
5441 +# undef strtoll
5442 +# define strtoll(s,e,b) \
5443 +    (GL_LINK_WARNING ("strtoll is unportable - " \
5444 +                      "use gnulib module strtoll for portability"), \
5445 +     strtoll (s, e, b))
5446 +#endif
5447 +
5448 +
5449 +#if @GNULIB_STRTOULL@
5450 +# if !@HAVE_STRTOULL@
5451 +/* Parse an unsigned integer whose textual representation starts at STRING.
5452 +   The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
5453 +   it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
5454 +   "0x").
5455 +   If ENDPTR is not NULL, the address of the first byte after the integer is
5456 +   stored in *ENDPTR.
5457 +   Upon overflow, the return value is ULLONG_MAX, and errno is set to
5458 +   ERANGE.  */
5459 +extern unsigned long long strtoull (const char *string, char **endptr, int base);
5460 +# endif
5461 +#elif defined GNULIB_POSIXCHECK
5462 +# undef strtoull
5463 +# define strtoull(s,e,b) \
5464 +    (GL_LINK_WARNING ("strtoull is unportable - " \
5465 +                      "use gnulib module strtoull for portability"), \
5466 +     strtoull (s, e, b))
5467 +#endif
5468 +
5469 +
5470 +#ifdef __cplusplus
5471 +}
5472 +#endif
5473 +
5474 +#endif /* _GL_STDLIB_H */
5475 +#endif /* _GL_STDLIB_H */
5476 +#endif
5477 diff -urN popt-for-windows/lib/strdup.c popt-for-windows-gnulib/lib/strdup.c
5478 --- popt-for-windows/lib/strdup.c       1970-01-01 01:00:00.000000000 +0100
5479 +++ popt-for-windows-gnulib/lib/strdup.c        2008-10-25 15:17:05.000000000 +0100
5480 @@ -0,0 +1,55 @@
5481 +/* Copyright (C) 1991, 1996, 1997, 1998, 2002, 2003, 2004, 2006, 2007 Free
5482 +   Software Foundation, Inc.
5483 +
5484 +   This file is part of the GNU C Library.
5485 +
5486 +   This program is free software; you can redistribute it and/or modify
5487 +   it under the terms of the GNU General Public License as published by
5488 +   the Free Software Foundation; either version 3, or (at your option)
5489 +   any later version.
5490 +
5491 +   This program is distributed in the hope that it will be useful,
5492 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
5493 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5494 +   GNU General Public License for more details.
5495 +
5496 +   You should have received a copy of the GNU General Public License along
5497 +   with this program; if not, write to the Free Software Foundation,
5498 +   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
5499 +
5500 +#ifndef _LIBC
5501 +# include <config.h>
5502 +#endif
5503 +
5504 +/* Get specification.  */
5505 +#include <string.h>
5506 +
5507 +#include <stdlib.h>
5508 +
5509 +#undef __strdup
5510 +#ifdef _LIBC
5511 +# undef strdup
5512 +#endif
5513 +
5514 +#ifndef weak_alias
5515 +# define __strdup strdup
5516 +#endif
5517 +
5518 +/* Duplicate S, returning an identical malloc'd string.  */
5519 +char *
5520 +__strdup (const char *s)
5521 +{
5522 +  size_t len = strlen (s) + 1;
5523 +  void *new = malloc (len);
5524 +
5525 +  if (new == NULL)
5526 +    return NULL;
5527 +
5528 +  return (char *) memcpy (new, s, len);
5529 +}
5530 +#ifdef libc_hidden_def
5531 +libc_hidden_def (__strdup)
5532 +#endif
5533 +#ifdef weak_alias
5534 +weak_alias (__strdup, strdup)
5535 +#endif
5536 diff -urN popt-for-windows/lib/string.in.h popt-for-windows-gnulib/lib/string.in.h
5537 --- popt-for-windows/lib/string.in.h    1970-01-01 01:00:00.000000000 +0100
5538 +++ popt-for-windows-gnulib/lib/string.in.h     2008-10-25 15:17:05.000000000 +0100
5539 @@ -0,0 +1,605 @@
5540 +/* A GNU-like <string.h>.
5541 +
5542 +   Copyright (C) 1995-1996, 2001-2008 Free Software Foundation, Inc.
5543 +
5544 +   This program is free software; you can redistribute it and/or modify
5545 +   it under the terms of the GNU General Public License as published by
5546 +   the Free Software Foundation; either version 3, or (at your option)
5547 +   any later version.
5548 +
5549 +   This program is distributed in the hope that it will be useful,
5550 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
5551 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5552 +   GNU General Public License for more details.
5553 +
5554 +   You should have received a copy of the GNU General Public License
5555 +   along with this program; if not, write to the Free Software Foundation,
5556 +   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
5557 +
5558 +#ifndef _GL_STRING_H
5559 +
5560 +#if __GNUC__ >= 3
5561 +@PRAGMA_SYSTEM_HEADER@
5562 +#endif
5563 +
5564 +/* The include_next requires a split double-inclusion guard.  */
5565 +#@INCLUDE_NEXT@ @NEXT_STRING_H@
5566 +
5567 +#ifndef _GL_STRING_H
5568 +#define _GL_STRING_H
5569 +
5570 +
5571 +#ifndef __attribute__
5572 +/* This feature is available in gcc versions 2.5 and later.  */
5573 +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
5574 +#  define __attribute__(Spec) /* empty */
5575 +# endif
5576 +/* The attribute __pure__ was added in gcc 2.96.  */
5577 +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
5578 +#  define __pure__ /* empty */
5579 +# endif
5580 +#endif
5581 +
5582 +
5583 +/* The definition of GL_LINK_WARNING is copied here.  */
5584 +
5585 +
5586 +#ifdef __cplusplus
5587 +extern "C" {
5588 +#endif
5589 +
5590 +
5591 +/* Return the first occurrence of NEEDLE in HAYSTACK.  */
5592 +#if @GNULIB_MEMMEM@
5593 +# if @REPLACE_MEMMEM@
5594 +#  define memmem rpl_memmem
5595 +# endif
5596 +# if ! @HAVE_DECL_MEMMEM@ || @REPLACE_MEMMEM@
5597 +extern void *memmem (void const *__haystack, size_t __haystack_len,
5598 +                    void const *__needle, size_t __needle_len)
5599 +  __attribute__ ((__pure__));
5600 +# endif
5601 +#elif defined GNULIB_POSIXCHECK
5602 +# undef memmem
5603 +# define memmem(a,al,b,bl) \
5604 +    (GL_LINK_WARNING ("memmem is unportable and often quadratic - " \
5605 +                      "use gnulib module memmem-simple for portability, " \
5606 +                      "and module memmem for speed" ), \
5607 +     memmem (a, al, b, bl))
5608 +#endif
5609 +
5610 +/* Copy N bytes of SRC to DEST, return pointer to bytes after the
5611 +   last written byte.  */
5612 +#if @GNULIB_MEMPCPY@
5613 +# if ! @HAVE_MEMPCPY@
5614 +extern void *mempcpy (void *restrict __dest, void const *restrict __src,
5615 +                     size_t __n);
5616 +# endif
5617 +#elif defined GNULIB_POSIXCHECK
5618 +# undef mempcpy
5619 +# define mempcpy(a,b,n) \
5620 +    (GL_LINK_WARNING ("mempcpy is unportable - " \
5621 +                      "use gnulib module mempcpy for portability"), \
5622 +     mempcpy (a, b, n))
5623 +#endif
5624 +
5625 +/* Search backwards through a block for a byte (specified as an int).  */
5626 +#if @GNULIB_MEMRCHR@
5627 +# if ! @HAVE_DECL_MEMRCHR@
5628 +extern void *memrchr (void const *, int, size_t)
5629 +  __attribute__ ((__pure__));
5630 +# endif
5631 +#elif defined GNULIB_POSIXCHECK
5632 +# undef memrchr
5633 +# define memrchr(a,b,c) \
5634 +    (GL_LINK_WARNING ("memrchr is unportable - " \
5635 +                      "use gnulib module memrchr for portability"), \
5636 +     memrchr (a, b, c))
5637 +#endif
5638 +
5639 +/* Find the first occurrence of C in S.  More efficient than
5640 +   memchr(S,C,N), at the expense of undefined behavior if C does not
5641 +   occur within N bytes.  */
5642 +#if @GNULIB_RAWMEMCHR@
5643 +# if ! @HAVE_RAWMEMCHR@
5644 +extern void *rawmemchr (void const *__s, int __c_in)
5645 +  __attribute__ ((__pure__));
5646 +# endif
5647 +#elif defined GNULIB_POSIXCHECK
5648 +# undef rawmemchr
5649 +# define rawmemchr(a,b) \
5650 +    (GL_LINK_WARNING ("rawmemchr is unportable - " \
5651 +                      "use gnulib module rawmemchr for portability"), \
5652 +     rawmemchr (a, b))
5653 +#endif
5654 +
5655 +/* Copy SRC to DST, returning the address of the terminating '\0' in DST.  */
5656 +#if @GNULIB_STPCPY@
5657 +# if ! @HAVE_STPCPY@
5658 +extern char *stpcpy (char *restrict __dst, char const *restrict __src);
5659 +# endif
5660 +#elif defined GNULIB_POSIXCHECK
5661 +# undef stpcpy
5662 +# define stpcpy(a,b) \
5663 +    (GL_LINK_WARNING ("stpcpy is unportable - " \
5664 +                      "use gnulib module stpcpy for portability"), \
5665 +     stpcpy (a, b))
5666 +#endif
5667 +
5668 +/* Copy no more than N bytes of SRC to DST, returning a pointer past the
5669 +   last non-NUL byte written into DST.  */
5670 +#if @GNULIB_STPNCPY@
5671 +# if ! @HAVE_STPNCPY@
5672 +#  define stpncpy gnu_stpncpy
5673 +extern char *stpncpy (char *restrict __dst, char const *restrict __src,
5674 +                     size_t __n);
5675 +# endif
5676 +#elif defined GNULIB_POSIXCHECK
5677 +# undef stpncpy
5678 +# define stpncpy(a,b,n) \
5679 +    (GL_LINK_WARNING ("stpncpy is unportable - " \
5680 +                      "use gnulib module stpncpy for portability"), \
5681 +     stpncpy (a, b, n))
5682 +#endif
5683 +
5684 +#if defined GNULIB_POSIXCHECK
5685 +/* strchr() does not work with multibyte strings if the locale encoding is
5686 +   GB18030 and the character to be searched is a digit.  */
5687 +# undef strchr
5688 +# define strchr(s,c) \
5689 +    (GL_LINK_WARNING ("strchr cannot work correctly on character strings " \
5690 +                      "in some multibyte locales - " \
5691 +                      "use mbschr if you care about internationalization"), \
5692 +     strchr (s, c))
5693 +#endif
5694 +
5695 +/* Find the first occurrence of C in S or the final NUL byte.  */
5696 +#if @GNULIB_STRCHRNUL@
5697 +# if ! @HAVE_STRCHRNUL@
5698 +extern char *strchrnul (char const *__s, int __c_in)
5699 +  __attribute__ ((__pure__));
5700 +# endif
5701 +#elif defined GNULIB_POSIXCHECK
5702 +# undef strchrnul
5703 +# define strchrnul(a,b) \
5704 +    (GL_LINK_WARNING ("strchrnul is unportable - " \
5705 +                      "use gnulib module strchrnul for portability"), \
5706 +     strchrnul (a, b))
5707 +#endif
5708 +
5709 +/* Duplicate S, returning an identical malloc'd string.  */
5710 +#if @GNULIB_STRDUP@
5711 +# if @REPLACE_STRDUP@
5712 +#  undef strdup
5713 +#  define strdup rpl_strdup
5714 +# endif
5715 +# if !(@HAVE_DECL_STRDUP@ || defined strdup) || @REPLACE_STRDUP@
5716 +extern char *strdup (char const *__s);
5717 +# endif
5718 +#elif defined GNULIB_POSIXCHECK
5719 +# undef strdup
5720 +# define strdup(a) \
5721 +    (GL_LINK_WARNING ("strdup is unportable - " \
5722 +                      "use gnulib module strdup for portability"), \
5723 +     strdup (a))
5724 +#endif
5725 +
5726 +/* Return a newly allocated copy of at most N bytes of STRING.  */
5727 +#if @GNULIB_STRNDUP@
5728 +# if ! @HAVE_STRNDUP@
5729 +#  undef strndup
5730 +#  define strndup rpl_strndup
5731 +# endif
5732 +# if ! @HAVE_STRNDUP@ || ! @HAVE_DECL_STRNDUP@
5733 +extern char *strndup (char const *__string, size_t __n);
5734 +# endif
5735 +#elif defined GNULIB_POSIXCHECK
5736 +# undef strndup
5737 +# define strndup(a,n) \
5738 +    (GL_LINK_WARNING ("strndup is unportable - " \
5739 +                      "use gnulib module strndup for portability"), \
5740 +     strndup (a, n))
5741 +#endif
5742 +
5743 +/* Find the length (number of bytes) of STRING, but scan at most
5744 +   MAXLEN bytes.  If no '\0' terminator is found in that many bytes,
5745 +   return MAXLEN.  */
5746 +#if @GNULIB_STRNLEN@
5747 +# if ! @HAVE_DECL_STRNLEN@
5748 +extern size_t strnlen (char const *__string, size_t __maxlen)
5749 +  __attribute__ ((__pure__));
5750 +# endif
5751 +#elif defined GNULIB_POSIXCHECK
5752 +# undef strnlen
5753 +# define strnlen(a,n) \
5754 +    (GL_LINK_WARNING ("strnlen is unportable - " \
5755 +                      "use gnulib module strnlen for portability"), \
5756 +     strnlen (a, n))
5757 +#endif
5758 +
5759 +#if defined GNULIB_POSIXCHECK
5760 +/* strcspn() assumes the second argument is a list of single-byte characters.
5761 +   Even in this simple case, it does not work with multibyte strings if the
5762 +   locale encoding is GB18030 and one of the characters to be searched is a
5763 +   digit.  */
5764 +# undef strcspn
5765 +# define strcspn(s,a) \
5766 +    (GL_LINK_WARNING ("strcspn cannot work correctly on character strings " \
5767 +                      "in multibyte locales - " \
5768 +                      "use mbscspn if you care about internationalization"), \
5769 +     strcspn (s, a))
5770 +#endif
5771 +
5772 +/* Find the first occurrence in S of any character in ACCEPT.  */
5773 +#if @GNULIB_STRPBRK@
5774 +# if ! @HAVE_STRPBRK@
5775 +extern char *strpbrk (char const *__s, char const *__accept)
5776 +  __attribute__ ((__pure__));
5777 +# endif
5778 +# if defined GNULIB_POSIXCHECK
5779 +/* strpbrk() assumes the second argument is a list of single-byte characters.
5780 +   Even in this simple case, it does not work with multibyte strings if the
5781 +   locale encoding is GB18030 and one of the characters to be searched is a
5782 +   digit.  */
5783 +#  undef strpbrk
5784 +#  define strpbrk(s,a) \
5785 +     (GL_LINK_WARNING ("strpbrk cannot work correctly on character strings " \
5786 +                       "in multibyte locales - " \
5787 +                       "use mbspbrk if you care about internationalization"), \
5788 +      strpbrk (s, a))
5789 +# endif
5790 +#elif defined GNULIB_POSIXCHECK
5791 +# undef strpbrk
5792 +# define strpbrk(s,a) \
5793 +    (GL_LINK_WARNING ("strpbrk is unportable - " \
5794 +                      "use gnulib module strpbrk for portability"), \
5795 +     strpbrk (s, a))
5796 +#endif
5797 +
5798 +#if defined GNULIB_POSIXCHECK
5799 +/* strspn() assumes the second argument is a list of single-byte characters.
5800 +   Even in this simple case, it cannot work with multibyte strings.  */
5801 +# undef strspn
5802 +# define strspn(s,a) \
5803 +    (GL_LINK_WARNING ("strspn cannot work correctly on character strings " \
5804 +                      "in multibyte locales - " \
5805 +                      "use mbsspn if you care about internationalization"), \
5806 +     strspn (s, a))
5807 +#endif
5808 +
5809 +#if defined GNULIB_POSIXCHECK
5810 +/* strrchr() does not work with multibyte strings if the locale encoding is
5811 +   GB18030 and the character to be searched is a digit.  */
5812 +# undef strrchr
5813 +# define strrchr(s,c) \
5814 +    (GL_LINK_WARNING ("strrchr cannot work correctly on character strings " \
5815 +                      "in some multibyte locales - " \
5816 +                      "use mbsrchr if you care about internationalization"), \
5817 +     strrchr (s, c))
5818 +#endif
5819 +
5820 +/* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
5821 +   If one is found, overwrite it with a NUL, and advance *STRINGP
5822 +   to point to the next char after it.  Otherwise, set *STRINGP to NULL.
5823 +   If *STRINGP was already NULL, nothing happens.
5824 +   Return the old value of *STRINGP.
5825 +
5826 +   This is a variant of strtok() that is multithread-safe and supports
5827 +   empty fields.
5828 +
5829 +   Caveat: It modifies the original string.
5830 +   Caveat: These functions cannot be used on constant strings.
5831 +   Caveat: The identity of the delimiting character is lost.
5832 +   Caveat: It doesn't work with multibyte strings unless all of the delimiter
5833 +           characters are ASCII characters < 0x30.
5834 +
5835 +   See also strtok_r().  */
5836 +#if @GNULIB_STRSEP@
5837 +# if ! @HAVE_STRSEP@
5838 +extern char *strsep (char **restrict __stringp, char const *restrict __delim);
5839 +# endif
5840 +# if defined GNULIB_POSIXCHECK
5841 +#  undef strsep
5842 +#  define strsep(s,d) \
5843 +     (GL_LINK_WARNING ("strsep cannot work correctly on character strings " \
5844 +                       "in multibyte locales - " \
5845 +                       "use mbssep if you care about internationalization"), \
5846 +      strsep (s, d))
5847 +# endif
5848 +#elif defined GNULIB_POSIXCHECK
5849 +# undef strsep
5850 +# define strsep(s,d) \
5851 +    (GL_LINK_WARNING ("strsep is unportable - " \
5852 +                      "use gnulib module strsep for portability"), \
5853 +     strsep (s, d))
5854 +#endif
5855 +
5856 +#if @GNULIB_STRSTR@
5857 +# if @REPLACE_STRSTR@
5858 +#  define strstr rpl_strstr
5859 +char *strstr (const char *haystack, const char *needle)
5860 +  __attribute__ ((__pure__));
5861 +# endif
5862 +#elif defined GNULIB_POSIXCHECK
5863 +/* strstr() does not work with multibyte strings if the locale encoding is
5864 +   different from UTF-8:
5865 +   POSIX says that it operates on "strings", and "string" in POSIX is defined
5866 +   as a sequence of bytes, not of characters.  */
5867 +# undef strstr
5868 +# define strstr(a,b) \
5869 +    (GL_LINK_WARNING ("strstr is quadratic on many systems, and cannot " \
5870 +                      "work correctly on character strings in most "    \
5871 +                      "multibyte locales - " \
5872 +                      "use mbsstr if you care about internationalization, " \
5873 +                      "or use strstr if you care about speed"), \
5874 +     strstr (a, b))
5875 +#endif
5876 +
5877 +/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
5878 +   comparison.  */
5879 +#if @GNULIB_STRCASESTR@
5880 +# if @REPLACE_STRCASESTR@
5881 +#  define strcasestr rpl_strcasestr
5882 +# endif
5883 +# if ! @HAVE_STRCASESTR@ || @REPLACE_STRCASESTR@
5884 +extern char *strcasestr (const char *haystack, const char *needle)
5885 +  __attribute__ ((__pure__));
5886 +# endif
5887 +#elif defined GNULIB_POSIXCHECK
5888 +/* strcasestr() does not work with multibyte strings:
5889 +   It is a glibc extension, and glibc implements it only for unibyte
5890 +   locales.  */
5891 +# undef strcasestr
5892 +# define strcasestr(a,b) \
5893 +    (GL_LINK_WARNING ("strcasestr does work correctly on character strings " \
5894 +                      "in multibyte locales - " \
5895 +                      "use mbscasestr if you care about " \
5896 +                      "internationalization, or use c-strcasestr if you want " \
5897 +                      "a locale independent function"), \
5898 +     strcasestr (a, b))
5899 +#endif
5900 +
5901 +/* Parse S into tokens separated by characters in DELIM.
5902 +   If S is NULL, the saved pointer in SAVE_PTR is used as
5903 +   the next starting point.  For example:
5904 +       char s[] = "-abc-=-def";
5905 +       char *sp;
5906 +       x = strtok_r(s, "-", &sp);      // x = "abc", sp = "=-def"
5907 +       x = strtok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
5908 +       x = strtok_r(NULL, "=", &sp);   // x = NULL
5909 +               // s = "abc\0-def\0"
5910 +
5911 +   This is a variant of strtok() that is multithread-safe.
5912 +
5913 +   For the POSIX documentation for this function, see:
5914 +   http://www.opengroup.org/susv3xsh/strtok.html
5915 +
5916 +   Caveat: It modifies the original string.
5917 +   Caveat: These functions cannot be used on constant strings.
5918 +   Caveat: The identity of the delimiting character is lost.
5919 +   Caveat: It doesn't work with multibyte strings unless all of the delimiter
5920 +           characters are ASCII characters < 0x30.
5921 +
5922 +   See also strsep().  */
5923 +#if @GNULIB_STRTOK_R@
5924 +# if ! @HAVE_DECL_STRTOK_R@
5925 +extern char *strtok_r (char *restrict s, char const *restrict delim,
5926 +                      char **restrict save_ptr);
5927 +# endif
5928 +# if defined GNULIB_POSIXCHECK
5929 +#  undef strtok_r
5930 +#  define strtok_r(s,d,p) \
5931 +     (GL_LINK_WARNING ("strtok_r cannot work correctly on character strings " \
5932 +                       "in multibyte locales - " \
5933 +                       "use mbstok_r if you care about internationalization"), \
5934 +      strtok_r (s, d, p))
5935 +# endif
5936 +#elif defined GNULIB_POSIXCHECK
5937 +# undef strtok_r
5938 +# define strtok_r(s,d,p) \
5939 +    (GL_LINK_WARNING ("strtok_r is unportable - " \
5940 +                      "use gnulib module strtok_r for portability"), \
5941 +     strtok_r (s, d, p))
5942 +#endif
5943 +
5944 +
5945 +/* The following functions are not specified by POSIX.  They are gnulib
5946 +   extensions.  */
5947 +
5948 +#if @GNULIB_MBSLEN@
5949 +/* Return the number of multibyte characters in the character string STRING.
5950 +   This considers multibyte characters, unlike strlen, which counts bytes.  */
5951 +extern size_t mbslen (const char *string);
5952 +#endif
5953 +
5954 +#if @GNULIB_MBSNLEN@
5955 +/* Return the number of multibyte characters in the character string starting
5956 +   at STRING and ending at STRING + LEN.  */
5957 +extern size_t mbsnlen (const char *string, size_t len);
5958 +#endif
5959 +
5960 +#if @GNULIB_MBSCHR@
5961 +/* Locate the first single-byte character C in the character string STRING,
5962 +   and return a pointer to it.  Return NULL if C is not found in STRING.
5963 +   Unlike strchr(), this function works correctly in multibyte locales with
5964 +   encodings such as GB18030.  */
5965 +# define mbschr rpl_mbschr /* avoid collision with HP-UX function */
5966 +extern char * mbschr (const char *string, int c);
5967 +#endif
5968 +
5969 +#if @GNULIB_MBSRCHR@
5970 +/* Locate the last single-byte character C in the character string STRING,
5971 +   and return a pointer to it.  Return NULL if C is not found in STRING.
5972 +   Unlike strrchr(), this function works correctly in multibyte locales with
5973 +   encodings such as GB18030.  */
5974 +# define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */
5975 +extern char * mbsrchr (const char *string, int c);
5976 +#endif
5977 +
5978 +#if @GNULIB_MBSSTR@
5979 +/* Find the first occurrence of the character string NEEDLE in the character
5980 +   string HAYSTACK.  Return NULL if NEEDLE is not found in HAYSTACK.
5981 +   Unlike strstr(), this function works correctly in multibyte locales with
5982 +   encodings different from UTF-8.  */
5983 +extern char * mbsstr (const char *haystack, const char *needle);
5984 +#endif
5985 +
5986 +#if @GNULIB_MBSCASECMP@
5987 +/* Compare the character strings S1 and S2, ignoring case, returning less than,
5988 +   equal to or greater than zero if S1 is lexicographically less than, equal to
5989 +   or greater than S2.
5990 +   Note: This function may, in multibyte locales, return 0 for strings of
5991 +   different lengths!
5992 +   Unlike strcasecmp(), this function works correctly in multibyte locales.  */
5993 +extern int mbscasecmp (const char *s1, const char *s2);
5994 +#endif
5995 +
5996 +#if @GNULIB_MBSNCASECMP@
5997 +/* Compare the initial segment of the character string S1 consisting of at most
5998 +   N characters with the initial segment of the character string S2 consisting
5999 +   of at most N characters, ignoring case, returning less than, equal to or
6000 +   greater than zero if the initial segment of S1 is lexicographically less
6001 +   than, equal to or greater than the initial segment of S2.
6002 +   Note: This function may, in multibyte locales, return 0 for initial segments
6003 +   of different lengths!
6004 +   Unlike strncasecmp(), this function works correctly in multibyte locales.
6005 +   But beware that N is not a byte count but a character count!  */
6006 +extern int mbsncasecmp (const char *s1, const char *s2, size_t n);
6007 +#endif
6008 +
6009 +#if @GNULIB_MBSPCASECMP@
6010 +/* Compare the initial segment of the character string STRING consisting of
6011 +   at most mbslen (PREFIX) characters with the character string PREFIX,
6012 +   ignoring case, returning less than, equal to or greater than zero if this
6013 +   initial segment is lexicographically less than, equal to or greater than
6014 +   PREFIX.
6015 +   Note: This function may, in multibyte locales, return 0 if STRING is of
6016 +   smaller length than PREFIX!
6017 +   Unlike strncasecmp(), this function works correctly in multibyte
6018 +   locales.  */
6019 +extern char * mbspcasecmp (const char *string, const char *prefix);
6020 +#endif
6021 +
6022 +#if @GNULIB_MBSCASESTR@
6023 +/* Find the first occurrence of the character string NEEDLE in the character
6024 +   string HAYSTACK, using case-insensitive comparison.
6025 +   Note: This function may, in multibyte locales, return success even if
6026 +   strlen (haystack) < strlen (needle) !
6027 +   Unlike strcasestr(), this function works correctly in multibyte locales.  */
6028 +extern char * mbscasestr (const char *haystack, const char *needle);
6029 +#endif
6030 +
6031 +#if @GNULIB_MBSCSPN@
6032 +/* Find the first occurrence in the character string STRING of any character
6033 +   in the character string ACCEPT.  Return the number of bytes from the
6034 +   beginning of the string to this occurrence, or to the end of the string
6035 +   if none exists.
6036 +   Unlike strcspn(), this function works correctly in multibyte locales.  */
6037 +extern size_t mbscspn (const char *string, const char *accept);
6038 +#endif
6039 +
6040 +#if @GNULIB_MBSPBRK@
6041 +/* Find the first occurrence in the character string STRING of any character
6042 +   in the character string ACCEPT.  Return the pointer to it, or NULL if none
6043 +   exists.
6044 +   Unlike strpbrk(), this function works correctly in multibyte locales.  */
6045 +# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
6046 +extern char * mbspbrk (const char *string, const char *accept);
6047 +#endif
6048 +
6049 +#if @GNULIB_MBSSPN@
6050 +/* Find the first occurrence in the character string STRING of any character
6051 +   not in the character string REJECT.  Return the number of bytes from the
6052 +   beginning of the string to this occurrence, or to the end of the string
6053 +   if none exists.
6054 +   Unlike strspn(), this function works correctly in multibyte locales.  */
6055 +extern size_t mbsspn (const char *string, const char *reject);
6056 +#endif
6057 +
6058 +#if @GNULIB_MBSSEP@
6059 +/* Search the next delimiter (multibyte character listed in the character
6060 +   string DELIM) starting at the character string *STRINGP.
6061 +   If one is found, overwrite it with a NUL, and advance *STRINGP to point
6062 +   to the next multibyte character after it.  Otherwise, set *STRINGP to NULL.
6063 +   If *STRINGP was already NULL, nothing happens.
6064 +   Return the old value of *STRINGP.
6065 +
6066 +   This is a variant of mbstok_r() that supports empty fields.
6067 +
6068 +   Caveat: It modifies the original string.
6069 +   Caveat: These functions cannot be used on constant strings.
6070 +   Caveat: The identity of the delimiting character is lost.
6071 +
6072 +   See also mbstok_r().  */
6073 +extern char * mbssep (char **stringp, const char *delim);
6074 +#endif
6075 +
6076 +#if @GNULIB_MBSTOK_R@
6077 +/* Parse the character string STRING into tokens separated by characters in
6078 +   the character string DELIM.
6079 +   If STRING is NULL, the saved pointer in SAVE_PTR is used as
6080 +   the next starting point.  For example:
6081 +       char s[] = "-abc-=-def";
6082 +       char *sp;
6083 +       x = mbstok_r(s, "-", &sp);      // x = "abc", sp = "=-def"
6084 +       x = mbstok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
6085 +       x = mbstok_r(NULL, "=", &sp);   // x = NULL
6086 +               // s = "abc\0-def\0"
6087 +
6088 +   Caveat: It modifies the original string.
6089 +   Caveat: These functions cannot be used on constant strings.
6090 +   Caveat: The identity of the delimiting character is lost.
6091 +
6092 +   See also mbssep().  */
6093 +extern char * mbstok_r (char *string, const char *delim, char **save_ptr);
6094 +#endif
6095 +
6096 +/* Map any int, typically from errno, into an error message.  */
6097 +#if @GNULIB_STRERROR@
6098 +# if @REPLACE_STRERROR@
6099 +#  undef strerror
6100 +#  define strerror rpl_strerror
6101 +extern char *strerror (int);
6102 +# endif
6103 +#elif defined GNULIB_POSIXCHECK
6104 +# undef strerror
6105 +# define strerror(e) \
6106 +    (GL_LINK_WARNING ("strerror is unportable - " \
6107 +                      "use gnulib module strerror to guarantee non-NULL result"), \
6108 +     strerror (e))
6109 +#endif
6110 +
6111 +#if @GNULIB_STRSIGNAL@
6112 +# if @REPLACE_STRSIGNAL@
6113 +#  define strsignal rpl_strsignal
6114 +# endif
6115 +# if ! @HAVE_DECL_STRSIGNAL@ || @REPLACE_STRSIGNAL@
6116 +extern char *strsignal (int __sig);
6117 +# endif
6118 +#elif defined GNULIB_POSIXCHECK
6119 +# undef strsignal
6120 +# define strsignal(a) \
6121 +    (GL_LINK_WARNING ("strsignal is unportable - " \
6122 +                      "use gnulib module strsignal for portability"), \
6123 +     strsignal (a))
6124 +#endif
6125 +
6126 +#if @GNULIB_STRVERSCMP@
6127 +# if !@HAVE_STRVERSCMP@
6128 +extern int strverscmp (const char *, const char *);
6129 +# endif
6130 +#elif defined GNULIB_POSIXCHECK
6131 +# undef strverscmp
6132 +# define strverscmp(a, b) \
6133 +    (GL_LINK_WARNING ("strverscmp is unportable - " \
6134 +                      "use gnulib module strverscmp for portability"), \
6135 +     strverscmp (a, b))
6136 +#endif
6137 +
6138 +
6139 +#ifdef __cplusplus
6140 +}
6141 +#endif
6142 +
6143 +#endif /* _GL_STRING_H */
6144 +#endif /* _GL_STRING_H */
6145 diff -urN popt-for-windows/lib/sys_stat.in.h popt-for-windows-gnulib/lib/sys_stat.in.h
6146 --- popt-for-windows/lib/sys_stat.in.h  1970-01-01 01:00:00.000000000 +0100
6147 +++ popt-for-windows-gnulib/lib/sys_stat.in.h   2008-10-25 15:17:05.000000000 +0100
6148 @@ -0,0 +1,339 @@
6149 +/* Provide a more complete sys/stat header file.
6150 +   Copyright (C) 2005-2008 Free Software Foundation, Inc.
6151 +
6152 +   This program is free software; you can redistribute it and/or modify
6153 +   it under the terms of the GNU General Public License as published by
6154 +   the Free Software Foundation; either version 3, or (at your option)
6155 +   any later version.
6156 +
6157 +   This program is distributed in the hope that it will be useful,
6158 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
6159 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6160 +   GNU General Public License for more details.
6161 +
6162 +   You should have received a copy of the GNU General Public License
6163 +   along with this program; if not, write to the Free Software Foundation,
6164 +   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
6165 +
6166 +/* Written by Eric Blake, Paul Eggert, and Jim Meyering.  */
6167 +
6168 +/* This file is supposed to be used on platforms where <sys/stat.h> is
6169 +   incomplete.  It is intended to provide definitions and prototypes
6170 +   needed by an application.  Start with what the system provides.  */
6171 +
6172 +#if __GNUC__ >= 3
6173 +@PRAGMA_SYSTEM_HEADER@
6174 +#endif
6175 +
6176 +#if defined __need_system_sys_stat_h
6177 +/* Special invocation convention.  */
6178 +
6179 +#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
6180 +
6181 +#else
6182 +/* Normal invocation convention.  */
6183 +
6184 +#ifndef _GL_SYS_STAT_H
6185 +
6186 +/* The include_next requires a split double-inclusion guard.  */
6187 +#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
6188 +
6189 +#ifndef _GL_SYS_STAT_H
6190 +#define _GL_SYS_STAT_H
6191 +
6192 +/* The definition of GL_LINK_WARNING is copied here.  */
6193 +
6194 +/* Before doing "#define mkdir rpl_mkdir" below, we need to include all
6195 +   headers that may declare mkdir().  */
6196 +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
6197 +# include <io.h>
6198 +#endif
6199 +
6200 +#ifndef S_IFMT
6201 +# define S_IFMT 0170000
6202 +#endif
6203 +
6204 +#if STAT_MACROS_BROKEN
6205 +# undef S_ISBLK
6206 +# undef S_ISCHR
6207 +# undef S_ISDIR
6208 +# undef S_ISFIFO
6209 +# undef S_ISLNK
6210 +# undef S_ISNAM
6211 +# undef S_ISMPB
6212 +# undef S_ISMPC
6213 +# undef S_ISNWK
6214 +# undef S_ISREG
6215 +# undef S_ISSOCK
6216 +#endif
6217 +
6218 +#ifndef S_ISBLK
6219 +# ifdef S_IFBLK
6220 +#  define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
6221 +# else
6222 +#  define S_ISBLK(m) 0
6223 +# endif
6224 +#endif
6225 +
6226 +#ifndef S_ISCHR
6227 +# ifdef S_IFCHR
6228 +#  define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
6229 +# else
6230 +#  define S_ISCHR(m) 0
6231 +# endif
6232 +#endif
6233 +
6234 +#ifndef S_ISDIR
6235 +# ifdef S_IFDIR
6236 +#  define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
6237 +# else
6238 +#  define S_ISDIR(m) 0
6239 +# endif
6240 +#endif
6241 +
6242 +#ifndef S_ISDOOR /* Solaris 2.5 and up */
6243 +# define S_ISDOOR(m) 0
6244 +#endif
6245 +
6246 +#ifndef S_ISFIFO
6247 +# ifdef S_IFIFO
6248 +#  define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
6249 +# else
6250 +#  define S_ISFIFO(m) 0
6251 +# endif
6252 +#endif
6253 +
6254 +#ifndef S_ISLNK
6255 +# ifdef S_IFLNK
6256 +#  define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
6257 +# else
6258 +#  define S_ISLNK(m) 0
6259 +# endif
6260 +#endif
6261 +
6262 +#ifndef S_ISMPB /* V7 */
6263 +# ifdef S_IFMPB
6264 +#  define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
6265 +#  define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
6266 +# else
6267 +#  define S_ISMPB(m) 0
6268 +#  define S_ISMPC(m) 0
6269 +# endif
6270 +#endif
6271 +
6272 +#ifndef S_ISNAM /* Xenix */
6273 +# ifdef S_IFNAM
6274 +#  define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
6275 +# else
6276 +#  define S_ISNAM(m) 0
6277 +# endif
6278 +#endif
6279 +
6280 +#ifndef S_ISNWK /* HP/UX */
6281 +# ifdef S_IFNWK
6282 +#  define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
6283 +# else
6284 +#  define S_ISNWK(m) 0
6285 +# endif
6286 +#endif
6287 +
6288 +#ifndef S_ISPORT /* Solaris 10 and up */
6289 +# define S_ISPORT(m) 0
6290 +#endif
6291 +
6292 +#ifndef S_ISREG
6293 +# ifdef S_IFREG
6294 +#  define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
6295 +# else
6296 +#  define S_ISREG(m) 0
6297 +# endif
6298 +#endif
6299 +
6300 +#ifndef S_ISSOCK
6301 +# ifdef S_IFSOCK
6302 +#  define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
6303 +# else
6304 +#  define S_ISSOCK(m) 0
6305 +# endif
6306 +#endif
6307 +
6308 +
6309 +#ifndef S_TYPEISMQ
6310 +# define S_TYPEISMQ(p) 0
6311 +#endif
6312 +
6313 +#ifndef S_TYPEISTMO
6314 +# define S_TYPEISTMO(p) 0
6315 +#endif
6316 +
6317 +
6318 +#ifndef S_TYPEISSEM
6319 +# ifdef S_INSEM
6320 +#  define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
6321 +# else
6322 +#  define S_TYPEISSEM(p) 0
6323 +# endif
6324 +#endif
6325 +
6326 +#ifndef S_TYPEISSHM
6327 +# ifdef S_INSHD
6328 +#  define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
6329 +# else
6330 +#  define S_TYPEISSHM(p) 0
6331 +# endif
6332 +#endif
6333 +
6334 +/* high performance ("contiguous data") */
6335 +#ifndef S_ISCTG
6336 +# define S_ISCTG(p) 0
6337 +#endif
6338 +
6339 +/* Cray DMF (data migration facility): off line, with data  */
6340 +#ifndef S_ISOFD
6341 +# define S_ISOFD(p) 0
6342 +#endif
6343 +
6344 +/* Cray DMF (data migration facility): off line, with no data  */
6345 +#ifndef S_ISOFL
6346 +# define S_ISOFL(p) 0
6347 +#endif
6348 +
6349 +/* 4.4BSD whiteout */
6350 +#ifndef S_ISWHT
6351 +# define S_ISWHT(m) 0
6352 +#endif
6353 +
6354 +/* If any of the following are undefined,
6355 +   define them to their de facto standard values.  */
6356 +#if !S_ISUID
6357 +# define S_ISUID 04000
6358 +#endif
6359 +#if !S_ISGID
6360 +# define S_ISGID 02000
6361 +#endif
6362 +
6363 +/* S_ISVTX is a common extension to POSIX.  */
6364 +#ifndef S_ISVTX
6365 +# define S_ISVTX 01000
6366 +#endif
6367 +
6368 +#if !S_IRUSR && S_IREAD
6369 +# define S_IRUSR S_IREAD
6370 +#endif
6371 +#if !S_IRUSR
6372 +# define S_IRUSR 00400
6373 +#endif
6374 +#if !S_IRGRP
6375 +# define S_IRGRP (S_IRUSR >> 3)
6376 +#endif
6377 +#if !S_IROTH
6378 +# define S_IROTH (S_IRUSR >> 6)
6379 +#endif
6380 +
6381 +#if !S_IWUSR && S_IWRITE
6382 +# define S_IWUSR S_IWRITE
6383 +#endif
6384 +#if !S_IWUSR
6385 +# define S_IWUSR 00200
6386 +#endif
6387 +#if !S_IWGRP
6388 +# define S_IWGRP (S_IWUSR >> 3)
6389 +#endif
6390 +#if !S_IWOTH
6391 +# define S_IWOTH (S_IWUSR >> 6)
6392 +#endif
6393 +
6394 +#if !S_IXUSR && S_IEXEC
6395 +# define S_IXUSR S_IEXEC
6396 +#endif
6397 +#if !S_IXUSR
6398 +# define S_IXUSR 00100
6399 +#endif
6400 +#if !S_IXGRP
6401 +# define S_IXGRP (S_IXUSR >> 3)
6402 +#endif
6403 +#if !S_IXOTH
6404 +# define S_IXOTH (S_IXUSR >> 6)
6405 +#endif
6406 +
6407 +#if !S_IRWXU
6408 +# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
6409 +#endif
6410 +#if !S_IRWXG
6411 +# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
6412 +#endif
6413 +#if !S_IRWXO
6414 +# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
6415 +#endif
6416 +
6417 +/* S_IXUGO is a common extension to POSIX.  */
6418 +#if !S_IXUGO
6419 +# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
6420 +#endif
6421 +
6422 +#ifndef S_IRWXUGO
6423 +# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
6424 +#endif
6425 +
6426 +/* mingw does not support symlinks, therefore it does not have lstat.  But
6427 +   without links, stat does just fine.  */
6428 +#if ! @HAVE_LSTAT@
6429 +# define lstat stat
6430 +#endif
6431 +#if @GNULIB_LSTAT@ && @REPLACE_LSTAT@
6432 +# undef lstat
6433 +# define lstat rpl_lstat
6434 +extern int rpl_lstat (const char *name, struct stat *buf);
6435 +#endif
6436 +
6437 +
6438 +#if @REPLACE_MKDIR@
6439 +# undef mkdir
6440 +# define mkdir rpl_mkdir
6441 +extern int mkdir (char const *name, mode_t mode);
6442 +#else
6443 +/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
6444 +   Additionally, it declares _mkdir (and depending on compile flags, an
6445 +   alias mkdir), only in the nonstandard <io.h>, which is included above.  */
6446 +# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
6447 +
6448 +static inline int
6449 +rpl_mkdir (char const *name, mode_t mode)
6450 +{
6451 +  return _mkdir (name);
6452 +}
6453 +
6454 +#  define mkdir rpl_mkdir
6455 +# endif
6456 +#endif
6457 +
6458 +
6459 +/* Declare BSD extensions.  */
6460 +
6461 +#if @GNULIB_LCHMOD@
6462 +/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
6463 +   denotes a symbolic link.  */
6464 +# if !@HAVE_LCHMOD@
6465 +/* The lchmod replacement follows symbolic links.  Callers should take
6466 +   this into account; lchmod should be applied only to arguments that
6467 +   are known to not be symbolic links.  On hosts that lack lchmod,
6468 +   this can lead to race conditions between the check and the
6469 +   invocation of lchmod, but we know of no workarounds that are
6470 +   reliable in general.  You might try requesting support for lchmod
6471 +   from your operating system supplier.  */
6472 +#  define lchmod chmod
6473 +# endif
6474 +# if 0 /* assume already declared */
6475 +extern int lchmod (const char *filename, mode_t mode);
6476 +# endif
6477 +#elif defined GNULIB_POSIXCHECK
6478 +# undef lchmod
6479 +# define lchmod(f,m) \
6480 +    (GL_LINK_WARNING ("lchmod is unportable - " \
6481 +                      "use gnulib module lchmod for portability"), \
6482 +     lchmod (f, m))
6483 +#endif
6484 +
6485 +#endif /* _GL_SYS_STAT_H */
6486 +#endif /* _GL_SYS_STAT_H */
6487 +#endif
6488 diff -urN popt-for-windows/lib/unistd.in.h popt-for-windows-gnulib/lib/unistd.in.h
6489 --- popt-for-windows/lib/unistd.in.h    1970-01-01 01:00:00.000000000 +0100
6490 +++ popt-for-windows-gnulib/lib/unistd.in.h     2008-10-25 15:17:05.000000000 +0100
6491 @@ -0,0 +1,501 @@
6492 +/* Substitute for and wrapper around <unistd.h>.
6493 +   Copyright (C) 2003-2008 Free Software Foundation, Inc.
6494 +
6495 +   This program is free software; you can redistribute it and/or modify
6496 +   it under the terms of the GNU General Public License as published by
6497 +   the Free Software Foundation; either version 3, or (at your option)
6498 +   any later version.
6499 +
6500 +   This program is distributed in the hope that it will be useful,
6501 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
6502 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6503 +   GNU General Public License for more details.
6504 +
6505 +   You should have received a copy of the GNU General Public License
6506 +   along with this program; if not, write to the Free Software Foundation,
6507 +   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
6508 +
6509 +#ifndef _GL_UNISTD_H
6510 +
6511 +#if __GNUC__ >= 3
6512 +@PRAGMA_SYSTEM_HEADER@
6513 +#endif
6514 +
6515 +/* The include_next requires a split double-inclusion guard.  */
6516 +#if @HAVE_UNISTD_H@
6517 +# @INCLUDE_NEXT@ @NEXT_UNISTD_H@
6518 +#endif
6519 +
6520 +#ifndef _GL_UNISTD_H
6521 +#define _GL_UNISTD_H
6522 +
6523 +/* mingw doesn't define the SEEK_* macros in <unistd.h>.  */
6524 +#if !(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET)
6525 +# include <stdio.h>
6526 +#endif
6527 +
6528 +/* mingw fails to declare _exit in <unistd.h>.  */
6529 +#include <stdlib.h>
6530 +
6531 +#if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
6532 +/* Get ssize_t.  */
6533 +# include <sys/types.h>
6534 +#endif
6535 +
6536 +/* The definition of GL_LINK_WARNING is copied here.  */
6537 +
6538 +
6539 +/* Declare overridden functions.  */
6540 +
6541 +#ifdef __cplusplus
6542 +extern "C" {
6543 +#endif
6544 +
6545 +
6546 +#if @GNULIB_CHOWN@
6547 +# if @REPLACE_CHOWN@
6548 +#  ifndef REPLACE_CHOWN
6549 +#   define REPLACE_CHOWN 1
6550 +#  endif
6551 +#  if REPLACE_CHOWN
6552 +/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
6553 +   to GID (if GID is not -1).  Follow symbolic links.
6554 +   Return 0 if successful, otherwise -1 and errno set.
6555 +   See the POSIX:2001 specification
6556 +   <http://www.opengroup.org/susv3xsh/chown.html>.  */
6557 +#   define chown rpl_chown
6558 +extern int chown (const char *file, uid_t uid, gid_t gid);
6559 +#  endif
6560 +# endif
6561 +#elif defined GNULIB_POSIXCHECK
6562 +# undef chown
6563 +# define chown(f,u,g) \
6564 +    (GL_LINK_WARNING ("chown fails to follow symlinks on some systems and " \
6565 +                      "doesn't treat a uid or gid of -1 on some systems - " \
6566 +                      "use gnulib module chown for portability"), \
6567 +     chown (f, u, g))
6568 +#endif
6569 +
6570 +
6571 +#if @GNULIB_CLOSE@
6572 +# if @REPLACE_CLOSE@
6573 +/* Automatically included by modules that need a replacement for close.  */
6574 +#  undef close
6575 +#  define close rpl_close
6576 +extern int close (int);
6577 +# endif
6578 +#elif @UNISTD_H_HAVE_WINSOCK2_H@
6579 +# undef close
6580 +# define close close_used_without_requesting_gnulib_module_close
6581 +#elif defined GNULIB_POSIXCHECK
6582 +# undef close
6583 +# define close(f) \
6584 +    (GL_LINK_WARNING ("close does not portably work on sockets - " \
6585 +                      "use gnulib module close for portability"), \
6586 +     close (f))
6587 +#endif
6588 +
6589 +
6590 +#if @GNULIB_DUP2@
6591 +# if !@HAVE_DUP2@
6592 +/* Copy the file descriptor OLDFD into file descriptor NEWFD.  Do nothing if
6593 +   NEWFD = OLDFD, otherwise close NEWFD first if it is open.
6594 +   Return 0 if successful, otherwise -1 and errno set.
6595 +   See the POSIX:2001 specification
6596 +   <http://www.opengroup.org/susv3xsh/dup2.html>.  */
6597 +extern int dup2 (int oldfd, int newfd);
6598 +# endif
6599 +#elif defined GNULIB_POSIXCHECK
6600 +# undef dup2
6601 +# define dup2(o,n) \
6602 +    (GL_LINK_WARNING ("dup2 is unportable - " \
6603 +                      "use gnulib module dup2 for portability"), \
6604 +     dup2 (o, n))
6605 +#endif
6606 +
6607 +
6608 +#if @GNULIB_ENVIRON@
6609 +# if !@HAVE_DECL_ENVIRON@
6610 +/* Set of environment variables and values.  An array of strings of the form
6611 +   "VARIABLE=VALUE", terminated with a NULL.  */
6612 +#  if defined __APPLE__ && defined __MACH__
6613 +#   include <crt_externs.h>
6614 +#   define environ (*_NSGetEnviron ())
6615 +#  else
6616 +extern char **environ;
6617 +#  endif
6618 +# endif
6619 +#elif defined GNULIB_POSIXCHECK
6620 +# undef environ
6621 +# define environ \
6622 +    (GL_LINK_WARNING ("environ is unportable - " \
6623 +                      "use gnulib module environ for portability"), \
6624 +     environ)
6625 +#endif
6626 +
6627 +
6628 +#if @GNULIB_EUIDACCESS@
6629 +# if !@HAVE_EUIDACCESS@
6630 +/* Like access(), except that is uses the effective user id and group id of
6631 +   the current process.  */
6632 +extern int euidaccess (const char *filename, int mode);
6633 +# endif
6634 +#elif defined GNULIB_POSIXCHECK
6635 +# undef euidaccess
6636 +# define euidaccess(f,m) \
6637 +    (GL_LINK_WARNING ("euidaccess is unportable - " \
6638 +                      "use gnulib module euidaccess for portability"), \
6639 +     euidaccess (f, m))
6640 +#endif
6641 +
6642 +
6643 +#if @GNULIB_FCHDIR@
6644 +# if @REPLACE_FCHDIR@
6645 +
6646 +/* Change the process' current working directory to the directory on which
6647 +   the given file descriptor is open.
6648 +   Return 0 if successful, otherwise -1 and errno set.
6649 +   See the POSIX:2001 specification
6650 +   <http://www.opengroup.org/susv3xsh/fchdir.html>.  */
6651 +extern int fchdir (int /*fd*/);
6652 +
6653 +#  define dup rpl_dup
6654 +extern int dup (int);
6655 +#  define dup2 rpl_dup2
6656 +extern int dup2 (int, int);
6657 +
6658 +# endif
6659 +#elif defined GNULIB_POSIXCHECK
6660 +# undef fchdir
6661 +# define fchdir(f) \
6662 +    (GL_LINK_WARNING ("fchdir is unportable - " \
6663 +                      "use gnulib module fchdir for portability"), \
6664 +     fchdir (f))
6665 +#endif
6666 +
6667 +
6668 +#if @GNULIB_FSYNC@
6669 +/* Synchronize changes to a file.
6670 +   Return 0 if successful, otherwise -1 and errno set.
6671 +   See POSIX:2001 specification
6672 +   <http://www.opengroup.org/susv3xsh/fsync.html>.  */
6673 +# if !@HAVE_FSYNC@
6674 +extern int fsync (int fd);
6675 +# endif
6676 +#elif defined GNULIB_POSIXCHECK
6677 +# undef fsync
6678 +# define fsync(fd) \
6679 +    (GL_LINK_WARNING ("fsync is unportable - " \
6680 +                      "use gnulib module fsync for portability"), \
6681 +     fsync (fd))
6682 +#endif
6683 +
6684 +
6685 +#if @GNULIB_FTRUNCATE@
6686 +# if !@HAVE_FTRUNCATE@
6687 +/* Change the size of the file to which FD is opened to become equal to LENGTH.
6688 +   Return 0 if successful, otherwise -1 and errno set.
6689 +   See the POSIX:2001 specification
6690 +   <http://www.opengroup.org/susv3xsh/ftruncate.html>.  */
6691 +extern int ftruncate (int fd, off_t length);
6692 +# endif
6693 +#elif defined GNULIB_POSIXCHECK
6694 +# undef ftruncate
6695 +# define ftruncate(f,l) \
6696 +    (GL_LINK_WARNING ("ftruncate is unportable - " \
6697 +                      "use gnulib module ftruncate for portability"), \
6698 +     ftruncate (f, l))
6699 +#endif
6700 +
6701 +
6702 +#if @GNULIB_GETCWD@
6703 +/* Include the headers that might declare getcwd so that they will not
6704 +   cause confusion if included after this file.  */
6705 +# include <stdlib.h>
6706 +# if @REPLACE_GETCWD@
6707 +/* Get the name of the current working directory, and put it in SIZE bytes
6708 +   of BUF.
6709 +   Return BUF if successful, or NULL if the directory couldn't be determined
6710 +   or SIZE was too small.
6711 +   See the POSIX:2001 specification
6712 +   <http://www.opengroup.org/susv3xsh/getcwd.html>.
6713 +   Additionally, the gnulib module 'getcwd' guarantees the following GNU
6714 +   extension: If BUF is NULL, an array is allocated with 'malloc'; the array
6715 +   is SIZE bytes long, unless SIZE == 0, in which case it is as big as
6716 +   necessary.  */
6717 +#  define getcwd rpl_getcwd
6718 +extern char * getcwd (char *buf, size_t size);
6719 +# endif
6720 +#elif defined GNULIB_POSIXCHECK
6721 +# undef getcwd
6722 +# define getcwd(b,s) \
6723 +    (GL_LINK_WARNING ("getcwd is unportable - " \
6724 +                      "use gnulib module getcwd for portability"), \
6725 +     getcwd (b, s))
6726 +#endif
6727 +
6728 +
6729 +#if @GNULIB_GETDOMAINNAME@
6730 +/* Return the NIS domain name of the machine.
6731 +   WARNING! The NIS domain name is unrelated to the fully qualified host name
6732 +            of the machine.  It is also unrelated to email addresses.
6733 +   WARNING! The NIS domain name is usually the empty string or "(none)" when
6734 +            not using NIS.
6735 +
6736 +   Put up to LEN bytes of the NIS domain name into NAME.
6737 +   Null terminate it if the name is shorter than LEN.
6738 +   If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
6739 +   Return 0 if successful, otherwise set errno and return -1.  */
6740 +# if !@HAVE_GETDOMAINNAME@
6741 +extern int getdomainname(char *name, size_t len);
6742 +# endif
6743 +#elif defined GNULIB_POSIXCHECK
6744 +# undef getdomainname
6745 +# define getdomainname(n,l) \
6746 +    (GL_LINK_WARNING ("getdomainname is unportable - " \
6747 +                      "use gnulib module getdomainname for portability"), \
6748 +     getdomainname (n, l))
6749 +#endif
6750 +
6751 +
6752 +#if @GNULIB_GETDTABLESIZE@
6753 +# if !@HAVE_GETDTABLESIZE@
6754 +/* Return the maximum number of file descriptors in the current process.  */
6755 +extern int getdtablesize (void);
6756 +# endif
6757 +#elif defined GNULIB_POSIXCHECK
6758 +# undef getdtablesize
6759 +# define getdtablesize() \
6760 +    (GL_LINK_WARNING ("getdtablesize is unportable - " \
6761 +                      "use gnulib module getdtablesize for portability"), \
6762 +     getdtablesize ())
6763 +#endif
6764 +
6765 +
6766 +#if @GNULIB_GETHOSTNAME@
6767 +/* Return the standard host name of the machine.
6768 +   WARNING! The host name may or may not be fully qualified.
6769 +
6770 +   Put up to LEN bytes of the host name into NAME.
6771 +   Null terminate it if the name is shorter than LEN.
6772 +   If the host name is longer than LEN, set errno = EINVAL and return -1.
6773 +   Return 0 if successful, otherwise set errno and return -1.  */
6774 +# if !@HAVE_GETHOSTNAME@
6775 +extern int gethostname(char *name, size_t len);
6776 +# endif
6777 +#elif defined GNULIB_POSIXCHECK
6778 +# undef gethostname
6779 +# define gethostname(n,l) \
6780 +    (GL_LINK_WARNING ("gethostname is unportable - " \
6781 +                      "use gnulib module gethostname for portability"), \
6782 +     gethostname (n, l))
6783 +#endif
6784 +
6785 +
6786 +#if @GNULIB_GETLOGIN_R@
6787 +/* Copies the user's login name to NAME.
6788 +   The array pointed to by NAME has room for SIZE bytes.
6789 +
6790 +   Returns 0 if successful.  Upon error, an error number is returned, or -1 in
6791 +   the case that the login name cannot be found but no specific error is
6792 +   provided (this case is hopefully rare but is left open by the POSIX spec).
6793 +
6794 +   See <http://www.opengroup.org/susv3xsh/getlogin.html>.
6795 + */
6796 +# if !@HAVE_DECL_GETLOGIN_R@
6797 +#  include <stddef.h>
6798 +extern int getlogin_r (char *name, size_t size);
6799 +# endif
6800 +#elif defined GNULIB_POSIXCHECK
6801 +# undef getlogin_r
6802 +# define getlogin_r(n,s) \
6803 +    (GL_LINK_WARNING ("getlogin_r is unportable - " \
6804 +                      "use gnulib module getlogin_r for portability"), \
6805 +     getlogin_r (n, s))
6806 +#endif
6807 +
6808 +
6809 +#if @GNULIB_GETPAGESIZE@
6810 +# if @REPLACE_GETPAGESIZE@
6811 +#  define getpagesize rpl_getpagesize
6812 +extern int getpagesize (void);
6813 +# elif !@HAVE_GETPAGESIZE@
6814 +/* This is for POSIX systems.  */
6815 +#  if !defined getpagesize && defined _SC_PAGESIZE
6816 +#   if ! (defined __VMS && __VMS_VER < 70000000)
6817 +#    define getpagesize() sysconf (_SC_PAGESIZE)
6818 +#   endif
6819 +#  endif
6820 +/* This is for older VMS.  */
6821 +#  if !defined getpagesize && defined __VMS
6822 +#   ifdef __ALPHA
6823 +#    define getpagesize() 8192
6824 +#   else
6825 +#    define getpagesize() 512
6826 +#   endif
6827 +#  endif
6828 +/* This is for BeOS.  */
6829 +#  if !defined getpagesize && @HAVE_OS_H@
6830 +#   include <OS.h>
6831 +#   if defined B_PAGE_SIZE
6832 +#    define getpagesize() B_PAGE_SIZE
6833 +#   endif
6834 +#  endif
6835 +/* This is for AmigaOS4.0.  */
6836 +#  if !defined getpagesize && defined __amigaos4__
6837 +#   define getpagesize() 2048
6838 +#  endif
6839 +/* This is for older Unix systems.  */
6840 +#  if !defined getpagesize && @HAVE_SYS_PARAM_H@
6841 +#   include <sys/param.h>
6842 +#   ifdef EXEC_PAGESIZE
6843 +#    define getpagesize() EXEC_PAGESIZE
6844 +#   else
6845 +#    ifdef NBPG
6846 +#     ifndef CLSIZE
6847 +#      define CLSIZE 1
6848 +#     endif
6849 +#     define getpagesize() (NBPG * CLSIZE)
6850 +#    else
6851 +#     ifdef NBPC
6852 +#      define getpagesize() NBPC
6853 +#     endif
6854 +#    endif
6855 +#   endif
6856 +#  endif
6857 +# endif
6858 +#elif defined GNULIB_POSIXCHECK
6859 +# undef getpagesize
6860 +# define getpagesize() \
6861 +    (GL_LINK_WARNING ("getpagesize is unportable - " \
6862 +                      "use gnulib module getpagesize for portability"), \
6863 +     getpagesize ())
6864 +#endif
6865 +
6866 +
6867 +#if @GNULIB_GETUSERSHELL@
6868 +# if !@HAVE_GETUSERSHELL@
6869 +/* Return the next valid login shell on the system, or NULL when the end of
6870 +   the list has been reached.  */
6871 +extern char *getusershell (void);
6872 +/* Rewind to pointer that is advanced at each getusershell() call.  */
6873 +extern void setusershell (void);
6874 +/* Free the pointer that is advanced at each getusershell() call and
6875 +   associated resources.  */
6876 +extern void endusershell (void);
6877 +# endif
6878 +#elif defined GNULIB_POSIXCHECK
6879 +# undef getusershell
6880 +# define getusershell() \
6881 +    (GL_LINK_WARNING ("getusershell is unportable - " \
6882 +                      "use gnulib module getusershell for portability"), \
6883 +     getusershell ())
6884 +# undef setusershell
6885 +# define setusershell() \
6886 +    (GL_LINK_WARNING ("setusershell is unportable - " \
6887 +                      "use gnulib module getusershell for portability"), \
6888 +     setusershell ())
6889 +# undef endusershell
6890 +# define endusershell() \
6891 +    (GL_LINK_WARNING ("endusershell is unportable - " \
6892 +                      "use gnulib module getusershell for portability"), \
6893 +     endusershell ())
6894 +#endif
6895 +
6896 +
6897 +#if @GNULIB_LCHOWN@
6898 +# if @REPLACE_LCHOWN@
6899 +/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
6900 +   to GID (if GID is not -1).  Do not follow symbolic links.
6901 +   Return 0 if successful, otherwise -1 and errno set.
6902 +   See the POSIX:2001 specification
6903 +   <http://www.opengroup.org/susv3xsh/lchown.html>.  */
6904 +#  define lchown rpl_lchown
6905 +extern int lchown (char const *file, uid_t owner, gid_t group);
6906 +# endif
6907 +#elif defined GNULIB_POSIXCHECK
6908 +# undef lchown
6909 +# define lchown(f,u,g) \
6910 +    (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \
6911 +                      "systems - use gnulib module lchown for portability"), \
6912 +     lchown (f, u, g))
6913 +#endif
6914 +
6915 +
6916 +#if @GNULIB_LSEEK@
6917 +# if @REPLACE_LSEEK@
6918 +/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
6919 +   Return the new offset if successful, otherwise -1 and errno set.
6920 +   See the POSIX:2001 specification
6921 +   <http://www.opengroup.org/susv3xsh/lseek.html>.  */
6922 +#  define lseek rpl_lseek
6923 +   extern off_t lseek (int fd, off_t offset, int whence);
6924 +# endif
6925 +#elif defined GNULIB_POSIXCHECK
6926 +# undef lseek
6927 +# define lseek(f,o,w) \
6928 +    (GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \
6929 +                      "systems - use gnulib module lseek for portability"), \
6930 +     lseek (f, o, w))
6931 +#endif
6932 +
6933 +
6934 +#if @GNULIB_READLINK@
6935 +/* Read the contents of the symbolic link FILE and place the first BUFSIZE
6936 +   bytes of it into BUF.  Return the number of bytes placed into BUF if
6937 +   successful, otherwise -1 and errno set.
6938 +   See the POSIX:2001 specification
6939 +   <http://www.opengroup.org/susv3xsh/readlink.html>.  */
6940 +# if !@HAVE_READLINK@
6941 +#  include <stddef.h>
6942 +extern int readlink (const char *file, char *buf, size_t bufsize);
6943 +# endif
6944 +#elif defined GNULIB_POSIXCHECK
6945 +# undef readlink
6946 +# define readlink(f,b,s) \
6947 +    (GL_LINK_WARNING ("readlink is unportable - " \
6948 +                      "use gnulib module readlink for portability"), \
6949 +     readlink (f, b, s))
6950 +#endif
6951 +
6952 +
6953 +#if @GNULIB_SLEEP@
6954 +/* Pause the execution of the current thread for N seconds.
6955 +   Returns the number of seconds left to sleep.
6956 +   See the POSIX:2001 specification
6957 +   <http://www.opengroup.org/susv3xsh/sleep.html>.  */
6958 +# if !@HAVE_SLEEP@
6959 +extern unsigned int sleep (unsigned int n);
6960 +# endif
6961 +#elif defined GNULIB_POSIXCHECK
6962 +# undef sleep
6963 +# define sleep(n) \
6964 +    (GL_LINK_WARNING ("sleep is unportable - " \
6965 +                      "use gnulib module sleep for portability"), \
6966 +     sleep (n))
6967 +#endif
6968 +
6969 +
6970 +#if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
6971 +/* Write up to COUNT bytes starting at BUF to file descriptor FD.
6972 +   See the POSIX:2001 specification
6973 +   <http://www.opengroup.org/susv3xsh/write.html>.  */
6974 +# undef write
6975 +# define write rpl_write
6976 +extern ssize_t write (int fd, const void *buf, size_t count);
6977 +#endif
6978 +
6979 +
6980 +#ifdef FCHDIR_REPLACEMENT
6981 +/* gnulib internal function.  */
6982 +extern void _gl_unregister_fd (int fd);
6983 +#endif
6984 +
6985 +
6986 +#ifdef __cplusplus
6987 +}
6988 +#endif
6989 +
6990 +
6991 +#endif /* _GL_UNISTD_H */
6992 +#endif /* _GL_UNISTD_H */
6993 diff -urN popt-for-windows/lib/wchar.in.h popt-for-windows-gnulib/lib/wchar.in.h
6994 --- popt-for-windows/lib/wchar.in.h     1970-01-01 01:00:00.000000000 +0100
6995 +++ popt-for-windows-gnulib/lib/wchar.in.h      2008-10-25 15:17:05.000000000 +0100
6996 @@ -0,0 +1,101 @@
6997 +/* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
6998 +
6999 +   Copyright (C) 2007-2008 Free Software Foundation, Inc.
7000 +
7001 +   This program is free software; you can redistribute it and/or modify
7002 +   it under the terms of the GNU General Public License as published by
7003 +   the Free Software Foundation; either version 3, or (at your option)
7004 +   any later version.
7005 +
7006 +   This program is distributed in the hope that it will be useful,
7007 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
7008 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7009 +   GNU General Public License for more details.
7010 +
7011 +   You should have received a copy of the GNU General Public License
7012 +   along with this program; if not, write to the Free Software Foundation,
7013 +   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
7014 +
7015 +/* Written by Eric Blake.  */
7016 +
7017 +/*
7018 + * ISO C 99 <wchar.h> for platforms that have issues.
7019 + * <http://www.opengroup.org/susv3xbd/wchar.h.html>
7020 + *
7021 + * For now, this just ensures proper prerequisite inclusion order and
7022 + * the declaration of wcwidth().
7023 + */
7024 +
7025 +#if __GNUC__ >= 3
7026 +@PRAGMA_SYSTEM_HEADER@
7027 +#endif
7028 +
7029 +#ifdef __need_mbstate_t
7030 +/* Special invocation convention inside uClibc header files.  */
7031 +
7032 +#@INCLUDE_NEXT@ @NEXT_WCHAR_H@
7033 +
7034 +#else
7035 +/* Normal invocation convention.  */
7036 +
7037 +#ifndef _GL_WCHAR_H
7038 +
7039 +/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
7040 +   <wchar.h>.
7041 +   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
7042 +   included before <wchar.h>.  */
7043 +#include <stddef.h>
7044 +#include <stdio.h>
7045 +#include <time.h>
7046 +
7047 +/* Include the original <wchar.h> if it exists.
7048 +   Some builds of uClibc lack it.  */
7049 +/* The include_next requires a split double-inclusion guard.  */
7050 +#if @HAVE_WCHAR_H@
7051 +# @INCLUDE_NEXT@ @NEXT_WCHAR_H@
7052 +#endif
7053 +
7054 +#ifndef _GL_WCHAR_H
7055 +#define _GL_WCHAR_H
7056 +
7057 +/* The definition of GL_LINK_WARNING is copied here.  */
7058 +
7059 +#ifdef __cplusplus
7060 +extern "C" {
7061 +#endif
7062 +
7063 +
7064 +/* Define wint_t.  (Also done in wctype.in.h.)  */
7065 +#if !@HAVE_WINT_T@ && !defined wint_t
7066 +# define wint_t int
7067 +#endif
7068 +
7069 +
7070 +/* Return the number of screen columns needed for WC.  */
7071 +#if @GNULIB_WCWIDTH@
7072 +# if @REPLACE_WCWIDTH@
7073 +#  undef wcwidth
7074 +#  define wcwidth rpl_wcwidth
7075 +extern int wcwidth (wchar_t);
7076 +# else
7077 +#  if !defined wcwidth && !@HAVE_DECL_WCWIDTH@
7078 +/* wcwidth exists but is not declared.  */
7079 +extern int wcwidth (int /* actually wchar_t */);
7080 +#  endif
7081 +# endif
7082 +#elif defined GNULIB_POSIXCHECK
7083 +# undef wcwidth
7084 +# define wcwidth(w) \
7085 +    (GL_LINK_WARNING ("wcwidth is unportable - " \
7086 +                      "use gnulib module wcwidth for portability"), \
7087 +     wcwidth (w))
7088 +#endif
7089 +
7090 +
7091 +#ifdef __cplusplus
7092 +}
7093 +#endif
7094 +
7095 +#endif /* _GL_WCHAR_H */
7096 +#endif /* _GL_WCHAR_H */
7097 +#endif
7098 diff -urN popt-for-windows/lib/wctype.in.h popt-for-windows-gnulib/lib/wctype.in.h
7099 --- popt-for-windows/lib/wctype.in.h    1970-01-01 01:00:00.000000000 +0100
7100 +++ popt-for-windows-gnulib/lib/wctype.in.h     2008-10-25 15:17:05.000000000 +0100
7101 @@ -0,0 +1,181 @@
7102 +/* A substitute for ISO C99 <wctype.h>, for platforms that lack it.
7103 +
7104 +   Copyright (C) 2006-2008 Free Software Foundation, Inc.
7105 +
7106 +   This program is free software; you can redistribute it and/or modify
7107 +   it under the terms of the GNU General Public License as published by
7108 +   the Free Software Foundation; either version 3, or (at your option)
7109 +   any later version.
7110 +
7111 +   This program is distributed in the hope that it will be useful,
7112 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
7113 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7114 +   GNU General Public License for more details.
7115 +
7116 +   You should have received a copy of the GNU General Public License
7117 +   along with this program; if not, write to the Free Software Foundation,
7118 +   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
7119 +
7120 +/* Written by Bruno Haible and Paul Eggert.  */
7121 +
7122 +/*
7123 + * ISO C 99 <wctype.h> for platforms that lack it.
7124 + * <http://www.opengroup.org/susv3xbd/wctype.h.html>
7125 + *
7126 + * iswctype, towctrans, towlower, towupper, wctrans, wctype,
7127 + * wctrans_t, and wctype_t are not yet implemented.
7128 + */
7129 +
7130 +#ifndef _GL_WCTYPE_H
7131 +
7132 +#if __GNUC__ >= 3
7133 +@PRAGMA_SYSTEM_HEADER@
7134 +#endif
7135 +
7136 +#if @HAVE_WINT_T@
7137 +/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>.
7138 +   Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
7139 +   <wchar.h>.
7140 +   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
7141 +   included before <wchar.h>.  */
7142 +# include <stddef.h>
7143 +# include <stdio.h>
7144 +# include <time.h>
7145 +# include <wchar.h>
7146 +#endif
7147 +
7148 +/* Include the original <wctype.h> if it exists.
7149 +   BeOS 5 has the functions but no <wctype.h>.  */
7150 +/* The include_next requires a split double-inclusion guard.  */
7151 +#if @HAVE_WCTYPE_H@
7152 +# @INCLUDE_NEXT@ @NEXT_WCTYPE_H@
7153 +#endif
7154 +
7155 +#ifndef _GL_WCTYPE_H
7156 +#define _GL_WCTYPE_H
7157 +
7158 +/* Define wint_t.  (Also done in wchar.in.h.)  */
7159 +#if !@HAVE_WINT_T@ && !defined wint_t
7160 +# define wint_t int
7161 +#endif
7162 +
7163 +/* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
7164 +   Linux libc5 has <wctype.h> and the functions but they are broken.
7165 +   Assume all 12 functions are implemented the same way, or not at all.  */
7166 +#if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@
7167 +
7168 +/* IRIX 5.3 has macros but no functions, its isw* macros refer to an
7169 +   undefined variable _ctmp_ and to <ctype.h> macros like _P, and they
7170 +   refer to system functions like _iswctype that are not in the
7171 +   standard C library.  Rather than try to get ancient buggy
7172 +   implementations like this to work, just disable them.  */
7173 +#  undef iswalnum
7174 +#  undef iswalpha
7175 +#  undef iswblank
7176 +#  undef iswcntrl
7177 +#  undef iswdigit
7178 +#  undef iswgraph
7179 +#  undef iswlower
7180 +#  undef iswprint
7181 +#  undef iswpunct
7182 +#  undef iswspace
7183 +#  undef iswupper
7184 +#  undef iswxdigit
7185 +
7186 +/* Linux libc5 has <wctype.h> and the functions but they are broken.  */
7187 +#  if @REPLACE_ISWCNTRL@
7188 +#   define iswalnum rpl_iswalnum
7189 +#   define iswalpha rpl_iswalpha
7190 +#   define iswblank rpl_iswblank
7191 +#   define iswcntrl rpl_iswcntrl
7192 +#   define iswdigit rpl_iswdigit
7193 +#   define iswgraph rpl_iswgraph
7194 +#   define iswlower rpl_iswlower
7195 +#   define iswprint rpl_iswprint
7196 +#   define iswpunct rpl_iswpunct
7197 +#   define iswspace rpl_iswspace
7198 +#   define iswupper rpl_iswupper
7199 +#   define iswxdigit rpl_iswxdigit
7200 +#  endif
7201 +
7202 +static inline int
7203 +iswalnum (wint_t wc)
7204 +{
7205 +  return ((wc >= '0' && wc <= '9')
7206 +         || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
7207 +}
7208 +
7209 +static inline int
7210 +iswalpha (wint_t wc)
7211 +{
7212 +  return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
7213 +}
7214 +
7215 +static inline int
7216 +iswblank (wint_t wc)
7217 +{
7218 +  return wc == ' ' || wc == '\t';
7219 +}
7220 +
7221 +static inline int
7222 +iswcntrl (wint_t wc)
7223 +{
7224 +  return (wc & ~0x1f) == 0 || wc == 0x7f;
7225 +}
7226 +
7227 +static inline int
7228 +iswdigit (wint_t wc)
7229 +{
7230 +  return wc >= '0' && wc <= '9';
7231 +}
7232 +
7233 +static inline int
7234 +iswgraph (wint_t wc)
7235 +{
7236 +  return wc >= '!' && wc <= '~';
7237 +}
7238 +
7239 +static inline int
7240 +iswlower (wint_t wc)
7241 +{
7242 +  return wc >= 'a' && wc <= 'z';
7243 +}
7244 +
7245 +static inline int
7246 +iswprint (wint_t wc)
7247 +{
7248 +  return wc >= ' ' && wc <= '~';
7249 +}
7250 +
7251 +static inline int
7252 +iswpunct (wint_t wc)
7253 +{
7254 +  return (wc >= '!' && wc <= '~'
7255 +         && !((wc >= '0' && wc <= '9')
7256 +              || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')));
7257 +}
7258 +
7259 +static inline int
7260 +iswspace (wint_t wc)
7261 +{
7262 +  return (wc == ' ' || wc == '\t'
7263 +         || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
7264 +}
7265 +
7266 +static inline int
7267 +iswupper (wint_t wc)
7268 +{
7269 +  return wc >= 'A' && wc <= 'Z';
7270 +}
7271 +
7272 +static inline int
7273 +iswxdigit (wint_t wc)
7274 +{
7275 +  return ((wc >= '0' && wc <= '9')
7276 +         || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));
7277 +}
7278 +
7279 +# endif /* ! HAVE_ISWCNTRL */
7280 +
7281 +#endif /* _GL_WCTYPE_H */
7282 +#endif /* _GL_WCTYPE_H */
7283 diff -urN popt-for-windows/link-warning.h popt-for-windows-gnulib/link-warning.h
7284 --- popt-for-windows/link-warning.h     1970-01-01 01:00:00.000000000 +0100
7285 +++ popt-for-windows-gnulib/link-warning.h      2008-10-25 15:17:05.000000000 +0100
7286 @@ -0,0 +1,28 @@
7287 +/* GL_LINK_WARNING("literal string") arranges to emit the literal string as
7288 +   a linker warning on most glibc systems.
7289 +   We use a linker warning rather than a preprocessor warning, because
7290 +   #warning cannot be used inside macros.  */
7291 +#ifndef GL_LINK_WARNING
7292 +  /* This works on platforms with GNU ld and ELF object format.
7293 +     Testing __GLIBC__ is sufficient for asserting that GNU ld is in use.
7294 +     Testing __ELF__ guarantees the ELF object format.
7295 +     Testing __GNUC__ is necessary for the compound expression syntax.  */
7296 +# if defined __GLIBC__ && defined __ELF__ && defined __GNUC__
7297 +#  define GL_LINK_WARNING(message) \
7298 +     GL_LINK_WARNING1 (__FILE__, __LINE__, message)
7299 +#  define GL_LINK_WARNING1(file, line, message) \
7300 +     GL_LINK_WARNING2 (file, line, message)  /* macroexpand file and line */
7301 +#  define GL_LINK_WARNING2(file, line, message) \
7302 +     GL_LINK_WARNING3 (file ":" #line ": warning: " message)
7303 +#  define GL_LINK_WARNING3(message) \
7304 +     ({ static const char warning[sizeof (message)]            \
7305 +          __attribute__ ((__unused__,                          \
7306 +                          __section__ (".gnu.warning"),                \
7307 +                          __aligned__ (1)))                    \
7308 +          = message "\n";                                      \
7309 +        (void)0;                                               \
7310 +     })
7311 +# else
7312 +#  define GL_LINK_WARNING(message) ((void) 0)
7313 +# endif
7314 +#endif
7315 diff -urN popt-for-windows/m4/alloca.m4 popt-for-windows-gnulib/m4/alloca.m4
7316 --- popt-for-windows/m4/alloca.m4       1970-01-01 01:00:00.000000000 +0100
7317 +++ popt-for-windows-gnulib/m4/alloca.m4        2008-10-25 15:17:05.000000000 +0100
7318 @@ -0,0 +1,46 @@
7319 +# alloca.m4 serial 8
7320 +dnl Copyright (C) 2002-2004, 2006, 2007 Free Software Foundation, Inc.
7321 +dnl This file is free software; the Free Software Foundation
7322 +dnl gives unlimited permission to copy and/or distribute it,
7323 +dnl with or without modifications, as long as this notice is preserved.
7324 +
7325 +AC_DEFUN([gl_FUNC_ALLOCA],
7326 +[
7327 +  dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57.
7328 +  AC_REQUIRE([AC_PROG_CPP])
7329 +  AC_REQUIRE([AC_PROG_EGREP])
7330 +
7331 +  AC_REQUIRE([AC_FUNC_ALLOCA])
7332 +  if test $ac_cv_func_alloca_works = no; then
7333 +    gl_PREREQ_ALLOCA
7334 +  fi
7335 +
7336 +  # Define an additional variable used in the Makefile substitution.
7337 +  if test $ac_cv_working_alloca_h = yes; then
7338 +    AC_CACHE_CHECK([for alloca as a compiler built-in], [gl_cv_rpl_alloca], [
7339 +      AC_EGREP_CPP([Need own alloca], [
7340 +#if defined __GNUC__ || defined _AIX || defined _MSC_VER
7341 +        Need own alloca
7342 +#endif
7343 +        ], [gl_cv_rpl_alloca=yes], [gl_cv_rpl_alloca=no])
7344 +    ])
7345 +    if test $gl_cv_rpl_alloca = yes; then
7346 +      dnl OK, alloca can be implemented through a compiler built-in.
7347 +      AC_DEFINE([HAVE_ALLOCA], 1,
7348 +        [Define to 1 if you have 'alloca' after including <alloca.h>,
7349 +         a header that may be supplied by this distribution.])
7350 +      ALLOCA_H=alloca.h
7351 +    else
7352 +      dnl alloca exists as a library function, i.e. it is slow and probably
7353 +      dnl a memory leak. Don't define HAVE_ALLOCA in this case.
7354 +      ALLOCA_H=
7355 +    fi
7356 +  else
7357 +    ALLOCA_H=alloca.h
7358 +  fi
7359 +  AC_SUBST([ALLOCA_H])
7360 +])
7361 +
7362 +# Prerequisites of lib/alloca.c.
7363 +# STACK_DIRECTION is already handled by AC_FUNC_ALLOCA.
7364 +AC_DEFUN([gl_PREREQ_ALLOCA], [:])
7365 diff -urN popt-for-windows/m4/.cvsignore popt-for-windows-gnulib/m4/.cvsignore
7366 --- popt-for-windows/m4/.cvsignore      2008-02-11 17:06:13.000000000 +0000
7367 +++ popt-for-windows-gnulib/m4/.cvsignore       2008-10-25 15:17:06.000000000 +0100
7368 @@ -1 +1,26 @@
7369  *.m4
7370 +alloca.m4
7371 +d-type.m4
7372 +dirent_h.m4
7373 +dirfd.m4
7374 +extensions.m4
7375 +fnmatch.m4
7376 +getlogin_r.m4
7377 +glob.m4
7378 +gnulib-common.m4
7379 +gnulib-comp.m4
7380 +gnulib-tool.m4
7381 +include_next.m4
7382 +malloc.m4
7383 +mbstate_t.m4
7384 +mempcpy.m4
7385 +onceonly.m4
7386 +stdbool.m4
7387 +stdlib_h.m4
7388 +strdup.m4
7389 +string_h.m4
7390 +sys_stat_h.m4
7391 +unistd_h.m4
7392 +wchar.m4
7393 +wctype.m4
7394 +wint_t.m4
7395 diff -urN popt-for-windows/m4/.cvsignore~ popt-for-windows-gnulib/m4/.cvsignore~
7396 --- popt-for-windows/m4/.cvsignore~     1970-01-01 01:00:00.000000000 +0100
7397 +++ popt-for-windows-gnulib/m4/.cvsignore~      2008-02-11 17:06:13.000000000 +0000
7398 @@ -0,0 +1 @@
7399 +*.m4
7400 diff -urN popt-for-windows/m4/dirent_h.m4 popt-for-windows-gnulib/m4/dirent_h.m4
7401 --- popt-for-windows/m4/dirent_h.m4     1970-01-01 01:00:00.000000000 +0100
7402 +++ popt-for-windows-gnulib/m4/dirent_h.m4      2008-10-25 15:17:05.000000000 +0100
7403 @@ -0,0 +1,39 @@
7404 +# dirent_h.m4 serial 2
7405 +dnl Copyright (C) 2008 Free Software Foundation, Inc.
7406 +dnl This file is free software; the Free Software Foundation
7407 +dnl gives unlimited permission to copy and/or distribute it,
7408 +dnl with or without modifications, as long as this notice is preserved.
7409 +
7410 +dnl Written by Bruno Haible.
7411 +
7412 +AC_DEFUN([gl_DIRENT_H],
7413 +[
7414 +  dnl Use AC_REQUIRE here, so that the default behavior below is expanded
7415 +  dnl once only, before all statements that occur in other macros.
7416 +  AC_REQUIRE([gl_DIRENT_H_DEFAULTS])
7417 +
7418 +  gl_CHECK_NEXT_HEADERS([dirent.h])
7419 +])
7420 +
7421 +dnl Unconditionally enables the replacement of <dirent.h>.
7422 +AC_DEFUN([gl_REPLACE_DIRENT_H],
7423 +[
7424 +  AC_REQUIRE([gl_DIRENT_H_DEFAULTS])
7425 +  DIRENT_H='dirent.h'
7426 +])
7427 +
7428 +AC_DEFUN([gl_DIRENT_MODULE_INDICATOR],
7429 +[
7430 +  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
7431 +  AC_REQUIRE([gl_DIRENT_H_DEFAULTS])
7432 +  GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
7433 +])
7434 +
7435 +AC_DEFUN([gl_DIRENT_H_DEFAULTS],
7436 +[
7437 +  AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) dnl for REPLACE_FCHDIR
7438 +  GNULIB_DIRFD=0;    AC_SUBST([GNULIB_DIRFD])
7439 +  dnl Assume proper GNU behavior unless another module says otherwise.
7440 +  HAVE_DECL_DIRFD=1; AC_SUBST([HAVE_DECL_DIRFD])
7441 +  DIRENT_H='';       AC_SUBST([DIRENT_H])
7442 +])
7443 diff -urN popt-for-windows/m4/dirfd.m4 popt-for-windows-gnulib/m4/dirfd.m4
7444 --- popt-for-windows/m4/dirfd.m4        1970-01-01 01:00:00.000000000 +0100
7445 +++ popt-for-windows-gnulib/m4/dirfd.m4 2008-10-25 15:17:05.000000000 +0100
7446 @@ -0,0 +1,84 @@
7447 +#serial 15   -*- Autoconf -*-
7448 +
7449 +dnl Find out how to get the file descriptor associated with an open DIR*.
7450 +
7451 +# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008 Free Software
7452 +# Foundation, Inc.
7453 +# This file is free software; the Free Software Foundation
7454 +# gives unlimited permission to copy and/or distribute it,
7455 +# with or without modifications, as long as this notice is preserved.
7456 +
7457 +dnl From Jim Meyering
7458 +
7459 +AC_DEFUN([gl_FUNC_DIRFD],
7460 +[
7461 +  AC_REQUIRE([gl_DIRENT_H_DEFAULTS])
7462 +  gl_REPLACE_DIRENT_H
7463 +
7464 +  dnl Persuade glibc <dirent.h> to declare dirfd().
7465 +  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
7466 +
7467 +  dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57.
7468 +  AC_REQUIRE([AC_PROG_CPP])
7469 +  AC_REQUIRE([AC_PROG_EGREP])
7470 +
7471 +  AC_CHECK_FUNCS(dirfd)
7472 +  AC_CHECK_DECLS([dirfd], , ,
7473 +    [#include <sys/types.h>
7474 +     #include <dirent.h>])
7475 +  if test $ac_cv_have_decl_dirfd = no; then
7476 +    HAVE_DECL_DIRFD=0
7477 +  fi
7478 +
7479 +  AC_CACHE_CHECK([whether dirfd is a macro],
7480 +    gl_cv_func_dirfd_macro,
7481 +    [AC_EGREP_CPP([dirent_header_defines_dirfd], [
7482 +#include <sys/types.h>
7483 +#include <dirent.h>
7484 +#ifdef dirfd
7485 + dirent_header_defines_dirfd
7486 +#endif],
7487 +       gl_cv_func_dirfd_macro=yes,
7488 +       gl_cv_func_dirfd_macro=no)])
7489 +
7490 +  # Use the replacement only if we have no function, macro,
7491 +  # or declaration with that name.
7492 +  if test $ac_cv_func_dirfd,$ac_cv_have_decl_dirfd,$gl_cv_func_dirfd_macro \
7493 +      = no,no,no; then
7494 +    AC_REPLACE_FUNCS([dirfd])
7495 +    AC_CACHE_CHECK(
7496 +             [how to get the file descriptor associated with an open DIR*],
7497 +                  gl_cv_sys_dir_fd_member_name,
7498 +      [
7499 +       dirfd_save_CFLAGS=$CFLAGS
7500 +       for ac_expr in d_fd dd_fd; do
7501 +
7502 +         CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr"
7503 +         AC_TRY_COMPILE(
7504 +           [#include <sys/types.h>
7505 +            #include <dirent.h>],
7506 +           [DIR *dir_p = opendir("."); (void) dir_p->DIR_FD_MEMBER_NAME;],
7507 +           dir_fd_found=yes
7508 +         )
7509 +         CFLAGS=$dirfd_save_CFLAGS
7510 +         test "$dir_fd_found" = yes && break
7511 +       done
7512 +       test "$dir_fd_found" = yes || ac_expr=no_such_member
7513 +
7514 +       gl_cv_sys_dir_fd_member_name=$ac_expr
7515 +      ]
7516 +    )
7517 +    if test $gl_cv_sys_dir_fd_member_name != no_such_member; then
7518 +      AC_DEFINE_UNQUOTED(DIR_FD_MEMBER_NAME,
7519 +       $gl_cv_sys_dir_fd_member_name,
7520 +       [the name of the file descriptor member of DIR])
7521 +    fi
7522 +    AH_VERBATIM(DIR_TO_FD,
7523 +               [#ifdef DIR_FD_MEMBER_NAME
7524 +# define DIR_TO_FD(Dir_p) ((Dir_p)->DIR_FD_MEMBER_NAME)
7525 +#else
7526 +# define DIR_TO_FD(Dir_p) -1
7527 +#endif
7528 +])
7529 +  fi
7530 +])
7531 diff -urN popt-for-windows/m4/d-type.m4 popt-for-windows-gnulib/m4/d-type.m4
7532 --- popt-for-windows/m4/d-type.m4       1970-01-01 01:00:00.000000000 +0100
7533 +++ popt-for-windows-gnulib/m4/d-type.m4        2008-10-25 15:17:05.000000000 +0100
7534 @@ -0,0 +1,35 @@
7535 +#serial 9
7536 +
7537 +dnl From Jim Meyering.
7538 +dnl
7539 +dnl Check whether struct dirent has a member named d_type.
7540 +dnl
7541 +
7542 +# Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2006 Free Software
7543 +# Foundation, Inc.
7544 +#
7545 +# This file is free software; the Free Software Foundation
7546 +# gives unlimited permission to copy and/or distribute it,
7547 +# with or without modifications, as long as this notice is preserved.
7548 +
7549 +AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE],
7550 +  [AC_CACHE_CHECK([for d_type member in directory struct],
7551 +                 gl_cv_struct_dirent_d_type,
7552 +     [AC_TRY_LINK(dnl
7553 +       [
7554 +#include <sys/types.h>
7555 +#include <dirent.h>
7556 +       ],
7557 +       [struct dirent dp; dp.d_type = 0;],
7558 +
7559 +       gl_cv_struct_dirent_d_type=yes,
7560 +       gl_cv_struct_dirent_d_type=no)
7561 +     ]
7562 +   )
7563 +   if test $gl_cv_struct_dirent_d_type = yes; then
7564 +     AC_DEFINE(HAVE_STRUCT_DIRENT_D_TYPE, 1,
7565 +       [Define if there is a member named d_type in the struct describing
7566 +        directory headers.])
7567 +   fi
7568 +  ]
7569 +)
7570 diff -urN popt-for-windows/m4/extensions.m4 popt-for-windows-gnulib/m4/extensions.m4
7571 --- popt-for-windows/m4/extensions.m4   1970-01-01 01:00:00.000000000 +0100
7572 +++ popt-for-windows-gnulib/m4/extensions.m4    2008-10-25 15:17:05.000000000 +0100
7573 @@ -0,0 +1,82 @@
7574 +# serial 5  -*- Autoconf -*-
7575 +# Enable extensions on systems that normally disable them.
7576 +
7577 +# Copyright (C) 2003, 2006-2008 Free Software Foundation, Inc.
7578 +# This file is free software; the Free Software Foundation
7579 +# gives unlimited permission to copy and/or distribute it,
7580 +# with or without modifications, as long as this notice is preserved.
7581 +
7582 +# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from CVS
7583 +# Autoconf.  Perhaps we can remove this once we can assume Autoconf
7584 +# 2.62 or later everywhere, but since CVS Autoconf mutates rapidly
7585 +# enough in this area it's likely we'll need to redefine
7586 +# AC_USE_SYSTEM_EXTENSIONS for quite some time.
7587 +
7588 +# AC_USE_SYSTEM_EXTENSIONS
7589 +# ------------------------
7590 +# Enable extensions on systems that normally disable them,
7591 +# typically due to standards-conformance issues.
7592 +# Remember that #undef in AH_VERBATIM gets replaced with #define by
7593 +# AC_DEFINE.  The goal here is to define all known feature-enabling
7594 +# macros, then, if reports of conflicts are made, disable macros that
7595 +# cause problems on some platforms (such as __EXTENSIONS__).
7596 +AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS],
7597 +[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
7598 +AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
7599 +
7600 +  AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=])
7601 +  if test "$MINIX" = yes; then
7602 +    AC_DEFINE([_POSIX_SOURCE], [1],
7603 +      [Define to 1 if you need to in order for `stat' and other
7604 +       things to work.])
7605 +    AC_DEFINE([_POSIX_1_SOURCE], [2],
7606 +      [Define to 2 if the system does not provide POSIX.1 features
7607 +       except with this defined.])
7608 +    AC_DEFINE([_MINIX], [1],
7609 +      [Define to 1 if on MINIX.])
7610 +  fi
7611 +
7612 +  AH_VERBATIM([__EXTENSIONS__],
7613 +[/* Enable extensions on AIX 3, Interix.  */
7614 +#ifndef _ALL_SOURCE
7615 +# undef _ALL_SOURCE
7616 +#endif
7617 +/* Enable GNU extensions on systems that have them.  */
7618 +#ifndef _GNU_SOURCE
7619 +# undef _GNU_SOURCE
7620 +#endif
7621 +/* Enable threading extensions on Solaris.  */
7622 +#ifndef _POSIX_PTHREAD_SEMANTICS
7623 +# undef _POSIX_PTHREAD_SEMANTICS
7624 +#endif
7625 +/* Enable extensions on HP NonStop.  */
7626 +#ifndef _TANDEM_SOURCE
7627 +# undef _TANDEM_SOURCE
7628 +#endif
7629 +/* Enable general extensions on Solaris.  */
7630 +#ifndef __EXTENSIONS__
7631 +# undef __EXTENSIONS__
7632 +#endif
7633 +])
7634 +  AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
7635 +    [ac_cv_safe_to_define___extensions__],
7636 +    [AC_COMPILE_IFELSE(
7637 +       [AC_LANG_PROGRAM([[
7638 +#        define __EXTENSIONS__ 1
7639 +         ]AC_INCLUDES_DEFAULT])],
7640 +       [ac_cv_safe_to_define___extensions__=yes],
7641 +       [ac_cv_safe_to_define___extensions__=no])])
7642 +  test $ac_cv_safe_to_define___extensions__ = yes &&
7643 +    AC_DEFINE([__EXTENSIONS__])
7644 +  AC_DEFINE([_ALL_SOURCE])
7645 +  AC_DEFINE([_GNU_SOURCE])
7646 +  AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
7647 +  AC_DEFINE([_TANDEM_SOURCE])
7648 +])# AC_USE_SYSTEM_EXTENSIONS
7649 +
7650 +# gl_USE_SYSTEM_EXTENSIONS
7651 +# ------------------------
7652 +# Enable extensions on systems that normally disable them,
7653 +# typically due to standards-conformance issues.
7654 +AC_DEFUN([gl_USE_SYSTEM_EXTENSIONS],
7655 +  [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])])
7656 diff -urN popt-for-windows/m4/fnmatch.m4 popt-for-windows-gnulib/m4/fnmatch.m4
7657 --- popt-for-windows/m4/fnmatch.m4      1970-01-01 01:00:00.000000000 +0100
7658 +++ popt-for-windows-gnulib/m4/fnmatch.m4       2008-10-25 15:17:05.000000000 +0100
7659 @@ -0,0 +1,127 @@
7660 +# Check for fnmatch - serial 2.
7661 +
7662 +# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
7663 +# Foundation, Inc.
7664 +# This file is free software; the Free Software Foundation
7665 +# gives unlimited permission to copy and/or distribute it,
7666 +# with or without modifications, as long as this notice is preserved.
7667 +
7668 +# Autoconf defines AC_FUNC_FNMATCH, but that is obsolescent.
7669 +# New applications should use the macros below instead.
7670 +
7671 +# _AC_FUNC_FNMATCH_IF(STANDARD = GNU | POSIX, CACHE_VAR, IF-TRUE, IF-FALSE)
7672 +# -------------------------------------------------------------------------
7673 +# If a STANDARD compliant fnmatch is found, run IF-TRUE, otherwise
7674 +# IF-FALSE.  Use CACHE_VAR.
7675 +AC_DEFUN([_AC_FUNC_FNMATCH_IF],
7676 +[AC_CACHE_CHECK(
7677 +   [for working $1 fnmatch],
7678 +   [$2],
7679 +  [dnl Some versions of Solaris, SCO, and the GNU C Library
7680 +   dnl have a broken or incompatible fnmatch.
7681 +   dnl So we run a test program.  If we are cross-compiling, take no chance.
7682 +   dnl Thanks to John Oleynick, François Pinard, and Paul Eggert for this test.
7683 +   AC_RUN_IFELSE(
7684 +      [AC_LANG_PROGRAM(
7685 +        [[#include <fnmatch.h>
7686 +          static int
7687 +          y (char const *pattern, char const *string, int flags)
7688 +          {
7689 +            return fnmatch (pattern, string, flags) == 0;
7690 +          }
7691 +          static int
7692 +          n (char const *pattern, char const *string, int flags)
7693 +          {
7694 +            return fnmatch (pattern, string, flags) == FNM_NOMATCH;
7695 +          }
7696 +        ]],
7697 +        [[char const *Apat = 'A' < '\\\\' ? "[A-\\\\\\\\]" : "[\\\\\\\\-A]";
7698 +          char const *apat = 'a' < '\\\\' ? "[a-\\\\\\\\]" : "[\\\\\\\\-a]";
7699 +          static char const A_1[] = { 'A' - 1, 0 };
7700 +          static char const A01[] = { 'A' + 1, 0 };
7701 +          static char const a_1[] = { 'a' - 1, 0 };
7702 +          static char const a01[] = { 'a' + 1, 0 };
7703 +          static char const bs_1[] = { '\\\\' - 1, 0 };
7704 +          static char const bs01[] = { '\\\\' + 1, 0 };
7705 +          return
7706 +           !(n ("a*", "", 0)
7707 +             && y ("a*", "abc", 0)
7708 +             && n ("d*/*1", "d/s/1", FNM_PATHNAME)
7709 +             && y ("a\\\\bc", "abc", 0)
7710 +             && n ("a\\\\bc", "abc", FNM_NOESCAPE)
7711 +             && y ("*x", ".x", 0)
7712 +             && n ("*x", ".x", FNM_PERIOD)
7713 +             && y (Apat, "\\\\", 0) && y (Apat, "A", 0)
7714 +             && y (apat, "\\\\", 0) && y (apat, "a", 0)
7715 +             && n (Apat, A_1, 0) == ('A' < '\\\\')
7716 +             && n (apat, a_1, 0) == ('a' < '\\\\')
7717 +             && y (Apat, A01, 0) == ('A' < '\\\\')
7718 +             && y (apat, a01, 0) == ('a' < '\\\\')
7719 +             && y (Apat, bs_1, 0) == ('A' < '\\\\')
7720 +             && y (apat, bs_1, 0) == ('a' < '\\\\')
7721 +             && n (Apat, bs01, 0) == ('A' < '\\\\')
7722 +             && n (apat, bs01, 0) == ('a' < '\\\\')
7723 +             && ]m4_if([$1], [GNU],
7724 +                  [y ("xxXX", "xXxX", FNM_CASEFOLD)
7725 +                   && y ("a++(x|yy)b", "a+xyyyyxb", FNM_EXTMATCH)
7726 +                   && n ("d*/*1", "d/s/1", FNM_FILE_NAME)
7727 +                   && y ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR)
7728 +                   && y ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR)
7729 +                   && y ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR)],
7730 +                  1))[;]])],
7731 +      [$2=yes],
7732 +      [$2=no],
7733 +      [$2=cross])])
7734 +AS_IF([test $$2 = yes], [$3], [$4])
7735 +])# _AC_FUNC_FNMATCH_IF
7736 +
7737 +
7738 +# _AC_LIBOBJ_FNMATCH
7739 +# ------------------
7740 +# Prepare the replacement of fnmatch.
7741 +AC_DEFUN([_AC_LIBOBJ_FNMATCH],
7742 +[AC_REQUIRE([AC_FUNC_ALLOCA])dnl
7743 +AC_REQUIRE([AC_TYPE_MBSTATE_T])dnl
7744 +AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>])
7745 +AC_CHECK_FUNCS_ONCE([btowc isblank iswctype mbsrtowcs mempcpy wmemchr wmemcpy wmempcpy])
7746 +AC_CHECK_HEADERS_ONCE([wctype.h])
7747 +AC_LIBOBJ([fnmatch])
7748 +FNMATCH_H=fnmatch.h
7749 +])# _AC_LIBOBJ_FNMATCH
7750 +
7751 +
7752 +AC_DEFUN([gl_FUNC_FNMATCH_POSIX],
7753 +[
7754 +  FNMATCH_H=
7755 +  _AC_FUNC_FNMATCH_IF([POSIX], [ac_cv_func_fnmatch_posix],
7756 +                     [rm -f lib/fnmatch.h],
7757 +                     [_AC_LIBOBJ_FNMATCH])
7758 +  if test $ac_cv_func_fnmatch_posix != yes; then
7759 +    dnl We must choose a different name for our function, since on ELF systems
7760 +    dnl a broken fnmatch() in libc.so would override our fnmatch() if it is
7761 +    dnl compiled into a shared library.
7762 +    AC_DEFINE([fnmatch], [posix_fnmatch],
7763 +      [Define to a replacement function name for fnmatch().])
7764 +  fi
7765 +  AC_SUBST([FNMATCH_H])
7766 +])
7767 +
7768 +
7769 +AC_DEFUN([gl_FUNC_FNMATCH_GNU],
7770 +[
7771 +  dnl Persuade glibc <fnmatch.h> to declare FNM_CASEFOLD etc.
7772 +  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
7773 +
7774 +  FNMATCH_H=
7775 +  _AC_FUNC_FNMATCH_IF([GNU], [ac_cv_func_fnmatch_gnu],
7776 +                     [rm -f lib/fnmatch.h],
7777 +                     [_AC_LIBOBJ_FNMATCH])
7778 +  if test $ac_cv_func_fnmatch_gnu != yes; then
7779 +    dnl We must choose a different name for our function, since on ELF systems
7780 +    dnl a broken fnmatch() in libc.so would override our fnmatch() if it is
7781 +    dnl compiled into a shared library.
7782 +    AC_DEFINE([fnmatch], [gnu_fnmatch],
7783 +      [Define to a replacement function name for fnmatch().])
7784 +  fi
7785 +  AC_SUBST([FNMATCH_H])
7786 +])
7787 diff -urN popt-for-windows/m4/getlogin_r.m4 popt-for-windows-gnulib/m4/getlogin_r.m4
7788 --- popt-for-windows/m4/getlogin_r.m4   1970-01-01 01:00:00.000000000 +0100
7789 +++ popt-for-windows-gnulib/m4/getlogin_r.m4    2008-10-25 15:17:05.000000000 +0100
7790 @@ -0,0 +1,33 @@
7791 +#serial 4
7792 +
7793 +# Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
7794 +#
7795 +# This file is free software; the Free Software Foundation
7796 +# gives unlimited permission to copy and/or distribute it,
7797 +# with or without modifications, as long as this notice is preserved.
7798 +
7799 +dnl From Derek Price
7800 +dnl
7801 +dnl Provide getlogin_r when the system lacks it.
7802 +dnl
7803 +
7804 +AC_DEFUN([gl_GETLOGIN_R],
7805 +[
7806 +  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
7807 +  AC_CHECK_FUNCS_ONCE([getlogin_r])
7808 +  if test $ac_cv_func_getlogin_r = no; then
7809 +    AC_LIBOBJ([getlogin_r])
7810 +    gl_PREREQ_GETLOGIN_R
7811 +    if test $ac_cv_have_decl_getlogin_r = yes; then
7812 +      HAVE_DECL_GETLOGIN_R=1
7813 +    else
7814 +      HAVE_DECL_GETLOGIN_R=0
7815 +    fi
7816 +  fi
7817 +])
7818 +
7819 +AC_DEFUN([gl_PREREQ_GETLOGIN_R],
7820 +[
7821 +  AC_CHECK_DECLS_ONCE([getlogin])
7822 +  AC_CHECK_DECLS_ONCE([getlogin_r])
7823 +])
7824 diff -urN popt-for-windows/m4/glob.m4 popt-for-windows-gnulib/m4/glob.m4
7825 --- popt-for-windows/m4/glob.m4 1970-01-01 01:00:00.000000000 +0100
7826 +++ popt-for-windows-gnulib/m4/glob.m4  2008-10-25 15:17:05.000000000 +0100
7827 @@ -0,0 +1,86 @@
7828 +# glob.m4 serial 10
7829 +dnl Copyright (C) 2005-2007 Free Software Foundation, Inc.
7830 +dnl This file is free software; the Free Software Foundation
7831 +dnl gives unlimited permission to copy and/or distribute it,
7832 +dnl with or without modifications, as long as this notice is preserved.
7833 +
7834 +# The glob module assumes you want GNU glob, with glob_pattern_p etc,
7835 +# rather than vanilla POSIX glob.  This means your code should
7836 +# always include <glob.h> for the glob prototypes.
7837 +
7838 +AC_DEFUN([gl_GLOB_SUBSTITUTE],
7839 +[
7840 +  gl_PREREQ_GLOB
7841 +
7842 +  GLOB_H=glob.h
7843 +  AC_LIBOBJ([glob])
7844 +  AC_SUBST([GLOB_H])
7845 +])
7846 +
7847 +AC_DEFUN([gl_GLOB],
7848 +[ GLOB_H=
7849 +  AC_CHECK_HEADERS([glob.h], [], [GLOB_H=glob.h])
7850 +
7851 +  if test -z "$GLOB_H"; then
7852 +    AC_CACHE_CHECK([for GNU glob interface version 1],
7853 +      [gl_cv_gnu_glob_interface_version_1],
7854 +[     AC_COMPILE_IFELSE(
7855 +[[#include <gnu-versions.h>
7856 +char a[_GNU_GLOB_INTERFACE_VERSION == 1 ? 1 : -1];]],
7857 +       [gl_cv_gnu_glob_interface_version_1=yes],
7858 +       [gl_cv_gnu_glob_interface_version_1=no])])
7859 +
7860 +    if test "$gl_cv_gnu_glob_interface_version_1" = "no"; then
7861 +      GLOB_H=glob.h
7862 +    fi
7863 +  fi
7864 +
7865 +  if test -z "$GLOB_H"; then
7866 +    AC_CACHE_CHECK([whether glob lists broken symlinks],
7867 +                   [gl_cv_glob_lists_symlinks],
7868 +[     if ln -s conf-doesntexist conf$$-globtest 2>/dev/null; then
7869 +        gl_cv_glob_lists_symlinks=maybe
7870 +      else
7871 +        # If we can't make a symlink, then we cannot test this issue.  Be
7872 +        # pessimistic about this.
7873 +        gl_cv_glob_lists_symlinks=no
7874 +      fi
7875 +
7876 +      if test $gl_cv_glob_lists_symlinks = maybe; then
7877 +        AC_RUN_IFELSE(
7878 +AC_LANG_PROGRAM(
7879 +[[#include <stddef.h>
7880 +#include <glob.h>]],
7881 +[[glob_t found;
7882 +if (glob ("conf*-globtest", 0, NULL, &found) == GLOB_NOMATCH) return 1;]]),
7883 +          [gl_cv_glob_lists_symlinks=yes],
7884 +          [gl_cv_glob_lists_symlinks=no], [gl_cv_glob_lists_symlinks=no])
7885 +      fi])
7886 +
7887 +    if test $gl_cv_glob_lists_symlinks = no; then
7888 +      GLOB_H=glob.h
7889 +    fi
7890 +  fi
7891 +
7892 +  rm -f conf$$-globtest
7893 +
7894 +  if test -n "$GLOB_H"; then
7895 +    gl_GLOB_SUBSTITUTE
7896 +  fi
7897 +])
7898 +
7899 +# Prerequisites of lib/glob.*.
7900 +AC_DEFUN([gl_PREREQ_GLOB],
7901 +[
7902 +  AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])dnl
7903 +  AC_REQUIRE([AC_C_RESTRICT])dnl
7904 +  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])dnl
7905 +  AC_CHECK_HEADERS_ONCE([sys/cdefs.h unistd.h])dnl
7906 +  if test $ac_cv_header_sys_cdefs_h = yes; then
7907 +    HAVE_SYS_CDEFS_H=1
7908 +  else
7909 +    HAVE_SYS_CDEFS_H=0
7910 +  fi
7911 +  AC_SUBST([HAVE_SYS_CDEFS_H])
7912 +  AC_CHECK_FUNCS_ONCE([fstatat getlogin_r getpwnam_r])dnl
7913 +])
7914 diff -urN popt-for-windows/m4/gnulib-common.m4 popt-for-windows-gnulib/m4/gnulib-common.m4
7915 --- popt-for-windows/m4/gnulib-common.m4        1970-01-01 01:00:00.000000000 +0100
7916 +++ popt-for-windows-gnulib/m4/gnulib-common.m4 2008-10-25 15:17:05.000000000 +0100
7917 @@ -0,0 +1,101 @@
7918 +# gnulib-common.m4 serial 6
7919 +dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
7920 +dnl This file is free software; the Free Software Foundation
7921 +dnl gives unlimited permission to copy and/or distribute it,
7922 +dnl with or without modifications, as long as this notice is preserved.
7923 +
7924 +# gl_COMMON
7925 +# is expanded unconditionally through gnulib-tool magic.
7926 +AC_DEFUN([gl_COMMON], [
7927 +  dnl Use AC_REQUIRE here, so that the code is expanded once only.
7928 +  AC_REQUIRE([gl_COMMON_BODY])
7929 +])
7930 +AC_DEFUN([gl_COMMON_BODY], [
7931 +  AH_VERBATIM([isoc99_inline],
7932 +[/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports
7933 +   the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of
7934 +   earlier versions), but does not display it by setting __GNUC_STDC_INLINE__.
7935 +   __APPLE__ && __MACH__ test for MacOS X.
7936 +   __APPLE_CC__ tests for the Apple compiler and its version.
7937 +   __STDC_VERSION__ tests for the C99 mode.  */
7938 +#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__
7939 +# define __GNUC_STDC_INLINE__ 1
7940 +#endif])
7941 +  AH_VERBATIM([unused_parameter],
7942 +[/* Define as a marker that can be attached to function parameter declarations
7943 +   for parameters that are not used.  This helps to reduce warnings, such as
7944 +   from GCC -Wunused-parameter.  */
7945 +#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
7946 +# define _UNUSED_PARAMETER_ __attribute__ ((__unused__))
7947 +#else
7948 +# define _UNUSED_PARAMETER_
7949 +#endif
7950 +])
7951 +])
7952 +
7953 +# gl_MODULE_INDICATOR([modulename])
7954 +# defines a C macro indicating the presence of the given module.
7955 +AC_DEFUN([gl_MODULE_INDICATOR],
7956 +[
7957 +  AC_DEFINE([GNULIB_]translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), [1],
7958 +    [Define to 1 when using the gnulib module ]$1[.])
7959 +])
7960 +
7961 +# m4_foreach_w
7962 +# is a backport of autoconf-2.59c's m4_foreach_w.
7963 +# Remove this macro when we can assume autoconf >= 2.60.
7964 +m4_ifndef([m4_foreach_w],
7965 +  [m4_define([m4_foreach_w],
7966 +    [m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])])
7967 +
7968 +# AC_PROG_MKDIR_P
7969 +# is a backport of autoconf-2.60's AC_PROG_MKDIR_P.
7970 +# Remove this macro when we can assume autoconf >= 2.60.
7971 +m4_ifdef([AC_PROG_MKDIR_P], [], [
7972 +  AC_DEFUN([AC_PROG_MKDIR_P],
7973 +    [AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
7974 +     MKDIR_P='$(mkdir_p)'
7975 +     AC_SUBST([MKDIR_P])])])
7976 +
7977 +# AC_C_RESTRICT
7978 +# This definition overrides the AC_C_RESTRICT macro from autoconf 2.60..2.61,
7979 +# so that mixed use of GNU C and GNU C++ and mixed use of Sun C and Sun C++
7980 +# works.
7981 +# This definition can be removed once autoconf >= 2.62 can be assumed.
7982 +AC_DEFUN([AC_C_RESTRICT],
7983 +[AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict,
7984 +  [ac_cv_c_restrict=no
7985 +   # The order here caters to the fact that C++ does not require restrict.
7986 +   for ac_kw in __restrict __restrict__ _Restrict restrict; do
7987 +     AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
7988 +      [[typedef int * int_ptr;
7989 +       int foo (int_ptr $ac_kw ip) {
7990 +       return ip[0];
7991 +       }]],
7992 +      [[int s[1];
7993 +       int * $ac_kw t = s;
7994 +       t[0] = 0;
7995 +       return foo(t)]])],
7996 +      [ac_cv_c_restrict=$ac_kw])
7997 +     test "$ac_cv_c_restrict" != no && break
7998 +   done
7999 +  ])
8000 + AH_VERBATIM([restrict],
8001 +[/* Define to the equivalent of the C99 'restrict' keyword, or to
8002 +   nothing if this is not supported.  Do not define if restrict is
8003 +   supported directly.  */
8004 +#undef restrict
8005 +/* Work around a bug in Sun C++: it does not support _Restrict, even
8006 +   though the corresponding Sun C compiler does, which causes
8007 +   "#define restrict _Restrict" in the previous line.  Perhaps some future
8008 +   version of Sun C++ will work with _Restrict; if so, it'll probably
8009 +   define __RESTRICT, just as Sun C does.  */
8010 +#if defined __SUNPRO_CC && !defined __RESTRICT
8011 +# define _Restrict
8012 +#endif])
8013 + case $ac_cv_c_restrict in
8014 +   restrict) ;;
8015 +   no) AC_DEFINE([restrict], []) ;;
8016 +   *)  AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
8017 + esac
8018 +])
8019 diff -urN popt-for-windows/m4/gnulib-comp.m4 popt-for-windows-gnulib/m4/gnulib-comp.m4
8020 --- popt-for-windows/m4/gnulib-comp.m4  1970-01-01 01:00:00.000000000 +0100
8021 +++ popt-for-windows-gnulib/m4/gnulib-comp.m4   2008-10-25 15:17:05.000000000 +0100
8022 @@ -0,0 +1,245 @@
8023 +# DO NOT EDIT! GENERATED AUTOMATICALLY!
8024 +# Copyright (C) 2002-2008 Free Software Foundation, Inc.
8025 +#
8026 +# This file is free software, distributed under the terms of the GNU
8027 +# General Public License.  As a special exception to the GNU General
8028 +# Public License, this file may be distributed as part of a program
8029 +# that contains a configuration script generated by Autoconf, under
8030 +# the same distribution terms as the rest of that program.
8031 +#
8032 +# Generated by gnulib-tool.
8033 +#
8034 +# This file represents the compiled summary of the specification in
8035 +# gnulib-cache.m4. It lists the computed macro invocations that need
8036 +# to be invoked from configure.ac.
8037 +# In projects using CVS, this file can be treated like other built files.
8038 +
8039 +
8040 +# This macro should be invoked from ./configure.ac, in the section
8041 +# "Checks for programs", right after AC_PROG_CC, and certainly before
8042 +# any checks for libraries, header files, types and library functions.
8043 +AC_DEFUN([gl_EARLY],
8044 +[
8045 +  m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace
8046 +  m4_pattern_allow([^gl_ES$])dnl a valid locale name
8047 +  m4_pattern_allow([^gl_LIBOBJS$])dnl a variable
8048 +  m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable
8049 +  AC_REQUIRE([AC_PROG_RANLIB])
8050 +  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
8051 +])
8052 +
8053 +# This macro should be invoked from ./configure.ac, in the section
8054 +# "Check for header files, types and library functions".
8055 +AC_DEFUN([gl_INIT],
8056 +[
8057 +  AM_CONDITIONAL([GL_COND_LIBTOOL], [true])
8058 +  gl_cond_libtool=true
8059 +  m4_pushdef([AC_LIBOBJ], m4_defn([gl_LIBOBJ]))
8060 +  m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gl_REPLACE_FUNCS]))
8061 +  m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES]))
8062 +  m4_pushdef([gl_LIBSOURCES_LIST], [])
8063 +  m4_pushdef([gl_LIBSOURCES_DIR], [])
8064 +  gl_COMMON
8065 +  gl_source_base='lib'
8066 +changequote(,)dnl
8067 +LTALLOCA=`echo "$ALLOCA" | sed 's/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'`
8068 +changequote([, ])dnl
8069 +AC_SUBST([LTALLOCA])
8070 +  gl_FUNC_ALLOCA
8071 +  gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE
8072 +  gl_DIRENT_H
8073 +  gl_FUNC_DIRFD
8074 +  gl_DIRENT_MODULE_INDICATOR([dirfd])
8075 +  # No macro. You should also use one of fnmatch-posix or fnmatch-gnu.
8076 +  gl_GETLOGIN_R
8077 +  gl_UNISTD_MODULE_INDICATOR([getlogin_r])
8078 +  gl_GLOB
8079 +  gl_FUNC_MALLOC_POSIX
8080 +  gl_STDLIB_MODULE_INDICATOR([malloc-posix])
8081 +  gl_FUNC_MEMPCPY
8082 +  gl_STRING_MODULE_INDICATOR([mempcpy])
8083 +  AM_STDBOOL_H
8084 +  gl_STDLIB_H
8085 +  gl_FUNC_STRDUP
8086 +  gl_STRING_MODULE_INDICATOR([strdup])
8087 +  gl_HEADER_STRING_H
8088 +  gl_HEADER_SYS_STAT_H
8089 +  AC_PROG_MKDIR_P
8090 +  gl_UNISTD_H
8091 +  gl_WCHAR_H
8092 +  gl_WCTYPE_H
8093 +  m4_ifval(gl_LIBSOURCES_LIST, [
8094 +    m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ ||
8095 +      for gl_file in ]gl_LIBSOURCES_LIST[ ; do
8096 +        if test ! -r ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file ; then
8097 +          echo "missing file ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file" >&2
8098 +          exit 1
8099 +        fi
8100 +      done])dnl
8101 +      m4_if(m4_sysval, [0], [],
8102 +        [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])
8103 +  ])
8104 +  m4_popdef([gl_LIBSOURCES_DIR])
8105 +  m4_popdef([gl_LIBSOURCES_LIST])
8106 +  m4_popdef([AC_LIBSOURCES])
8107 +  m4_popdef([AC_REPLACE_FUNCS])
8108 +  m4_popdef([AC_LIBOBJ])
8109 +  AC_CONFIG_COMMANDS_PRE([
8110 +    gl_libobjs=
8111 +    gl_ltlibobjs=
8112 +    if test -n "$gl_LIBOBJS"; then
8113 +      # Remove the extension.
8114 +      sed_drop_objext='s/\.o$//;s/\.obj$//'
8115 +      for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed "$sed_drop_objext" | sort | uniq`; do
8116 +        gl_libobjs="$gl_libobjs $i.$ac_objext"
8117 +        gl_ltlibobjs="$gl_ltlibobjs $i.lo"
8118 +      done
8119 +    fi
8120 +    AC_SUBST([gl_LIBOBJS], [$gl_libobjs])
8121 +    AC_SUBST([gl_LTLIBOBJS], [$gl_ltlibobjs])
8122 +  ])
8123 +  gltests_libdeps=
8124 +  gltests_ltlibdeps=
8125 +  m4_pushdef([AC_LIBOBJ], m4_defn([gltests_LIBOBJ]))
8126 +  m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gltests_REPLACE_FUNCS]))
8127 +  m4_pushdef([AC_LIBSOURCES], m4_defn([gltests_LIBSOURCES]))
8128 +  m4_pushdef([gltests_LIBSOURCES_LIST], [])
8129 +  m4_pushdef([gltests_LIBSOURCES_DIR], [])
8130 +  gl_COMMON
8131 +  gl_source_base='tests'
8132 +  m4_ifval(gltests_LIBSOURCES_LIST, [
8133 +    m4_syscmd([test ! -d ]m4_defn([gltests_LIBSOURCES_DIR])[ ||
8134 +      for gl_file in ]gltests_LIBSOURCES_LIST[ ; do
8135 +        if test ! -r ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file ; then
8136 +          echo "missing file ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file" >&2
8137 +          exit 1
8138 +        fi
8139 +      done])dnl
8140 +      m4_if(m4_sysval, [0], [],
8141 +        [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])
8142 +  ])
8143 +  m4_popdef([gltests_LIBSOURCES_DIR])
8144 +  m4_popdef([gltests_LIBSOURCES_LIST])
8145 +  m4_popdef([AC_LIBSOURCES])
8146 +  m4_popdef([AC_REPLACE_FUNCS])
8147 +  m4_popdef([AC_LIBOBJ])
8148 +  AC_CONFIG_COMMANDS_PRE([
8149 +    gltests_libobjs=
8150 +    gltests_ltlibobjs=
8151 +    if test -n "$gltests_LIBOBJS"; then
8152 +      # Remove the extension.
8153 +      sed_drop_objext='s/\.o$//;s/\.obj$//'
8154 +      for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed "$sed_drop_objext" | sort | uniq`; do
8155 +        gltests_libobjs="$gltests_libobjs $i.$ac_objext"
8156 +        gltests_ltlibobjs="$gltests_ltlibobjs $i.lo"
8157 +      done
8158 +    fi
8159 +    AC_SUBST([gltests_LIBOBJS], [$gltests_libobjs])
8160 +    AC_SUBST([gltests_LTLIBOBJS], [$gltests_ltlibobjs])
8161 +  ])
8162 +])
8163 +
8164 +# Like AC_LIBOBJ, except that the module name goes
8165 +# into gl_LIBOBJS instead of into LIBOBJS.
8166 +AC_DEFUN([gl_LIBOBJ], [
8167 +  AS_LITERAL_IF([$1], [gl_LIBSOURCES([$1.c])])dnl
8168 +  gl_LIBOBJS="$gl_LIBOBJS $1.$ac_objext"
8169 +])
8170 +
8171 +# Like AC_REPLACE_FUNCS, except that the module name goes
8172 +# into gl_LIBOBJS instead of into LIBOBJS.
8173 +AC_DEFUN([gl_REPLACE_FUNCS], [
8174 +  m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl
8175 +  AC_CHECK_FUNCS([$1], , [gl_LIBOBJ($ac_func)])
8176 +])
8177 +
8178 +# Like AC_LIBSOURCES, except the directory where the source file is
8179 +# expected is derived from the gnulib-tool parameterization,
8180 +# and alloca is special cased (for the alloca-opt module).
8181 +# We could also entirely rely on EXTRA_lib..._SOURCES.
8182 +AC_DEFUN([gl_LIBSOURCES], [
8183 +  m4_foreach([_gl_NAME], [$1], [
8184 +    m4_if(_gl_NAME, [alloca.c], [], [
8185 +      m4_define([gl_LIBSOURCES_DIR], [lib])
8186 +      m4_append([gl_LIBSOURCES_LIST], _gl_NAME, [ ])
8187 +    ])
8188 +  ])
8189 +])
8190 +
8191 +# Like AC_LIBOBJ, except that the module name goes
8192 +# into gltests_LIBOBJS instead of into LIBOBJS.
8193 +AC_DEFUN([gltests_LIBOBJ], [
8194 +  AS_LITERAL_IF([$1], [gltests_LIBSOURCES([$1.c])])dnl
8195 +  gltests_LIBOBJS="$gltests_LIBOBJS $1.$ac_objext"
8196 +])
8197 +
8198 +# Like AC_REPLACE_FUNCS, except that the module name goes
8199 +# into gltests_LIBOBJS instead of into LIBOBJS.
8200 +AC_DEFUN([gltests_REPLACE_FUNCS], [
8201 +  m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl
8202 +  AC_CHECK_FUNCS([$1], , [gltests_LIBOBJ($ac_func)])
8203 +])
8204 +
8205 +# Like AC_LIBSOURCES, except the directory where the source file is
8206 +# expected is derived from the gnulib-tool parameterization,
8207 +# and alloca is special cased (for the alloca-opt module).
8208 +# We could also entirely rely on EXTRA_lib..._SOURCES.
8209 +AC_DEFUN([gltests_LIBSOURCES], [
8210 +  m4_foreach([_gl_NAME], [$1], [
8211 +    m4_if(_gl_NAME, [alloca.c], [], [
8212 +      m4_define([gltests_LIBSOURCES_DIR], [tests])
8213 +      m4_append([gltests_LIBSOURCES_LIST], _gl_NAME, [ ])
8214 +    ])
8215 +  ])
8216 +])
8217 +
8218 +# This macro records the list of files which have been installed by
8219 +# gnulib-tool and may be removed by future gnulib-tool invocations.
8220 +AC_DEFUN([gl_FILE_LIST], [
8221 +  build-aux/link-warning.h
8222 +  lib/alloca.c
8223 +  lib/alloca.in.h
8224 +  lib/dirent.in.h
8225 +  lib/dirfd.c
8226 +  lib/dummy.c
8227 +  lib/fnmatch.c
8228 +  lib/fnmatch.in.h
8229 +  lib/fnmatch_loop.c
8230 +  lib/getlogin_r.c
8231 +  lib/glob-libc.h
8232 +  lib/glob.c
8233 +  lib/glob.in.h
8234 +  lib/malloc.c
8235 +  lib/mempcpy.c
8236 +  lib/stdbool.in.h
8237 +  lib/stdlib.in.h
8238 +  lib/strdup.c
8239 +  lib/string.in.h
8240 +  lib/sys_stat.in.h
8241 +  lib/unistd.in.h
8242 +  lib/wchar.in.h
8243 +  lib/wctype.in.h
8244 +  m4/alloca.m4
8245 +  m4/d-type.m4
8246 +  m4/dirent_h.m4
8247 +  m4/dirfd.m4
8248 +  m4/extensions.m4
8249 +  m4/fnmatch.m4
8250 +  m4/getlogin_r.m4
8251 +  m4/glob.m4
8252 +  m4/gnulib-common.m4
8253 +  m4/include_next.m4
8254 +  m4/malloc.m4
8255 +  m4/mbstate_t.m4
8256 +  m4/mempcpy.m4
8257 +  m4/onceonly.m4
8258 +  m4/stdbool.m4
8259 +  m4/stdlib_h.m4
8260 +  m4/strdup.m4
8261 +  m4/string_h.m4
8262 +  m4/sys_stat_h.m4
8263 +  m4/unistd_h.m4
8264 +  m4/wchar.m4
8265 +  m4/wctype.m4
8266 +  m4/wint_t.m4
8267 +])
8268 diff -urN popt-for-windows/m4/gnulib-tool.m4 popt-for-windows-gnulib/m4/gnulib-tool.m4
8269 --- popt-for-windows/m4/gnulib-tool.m4  1970-01-01 01:00:00.000000000 +0100
8270 +++ popt-for-windows-gnulib/m4/gnulib-tool.m4   2008-10-25 15:17:05.000000000 +0100
8271 @@ -0,0 +1,57 @@
8272 +# gnulib-tool.m4 serial 2
8273 +dnl Copyright (C) 2004-2005 Free Software Foundation, Inc.
8274 +dnl This file is free software; the Free Software Foundation
8275 +dnl gives unlimited permission to copy and/or distribute it,
8276 +dnl with or without modifications, as long as this notice is preserved.
8277 +
8278 +dnl The following macros need not be invoked explicitly.
8279 +dnl Invoking them does nothing except to declare default arguments
8280 +dnl for "gnulib-tool --import".
8281 +
8282 +dnl Usage: gl_LOCAL_DIR([DIR])
8283 +AC_DEFUN([gl_LOCAL_DIR], [])
8284 +
8285 +dnl Usage: gl_MODULES([module1 module2 ...])
8286 +AC_DEFUN([gl_MODULES], [])
8287 +
8288 +dnl Usage: gl_AVOID([module1 module2 ...])
8289 +AC_DEFUN([gl_AVOID], [])
8290 +
8291 +dnl Usage: gl_SOURCE_BASE([DIR])
8292 +AC_DEFUN([gl_SOURCE_BASE], [])
8293 +
8294 +dnl Usage: gl_M4_BASE([DIR])
8295 +AC_DEFUN([gl_M4_BASE], [])
8296 +
8297 +dnl Usage: gl_PO_BASE([DIR])
8298 +AC_DEFUN([gl_PO_BASE], [])
8299 +
8300 +dnl Usage: gl_DOC_BASE([DIR])
8301 +AC_DEFUN([gl_DOC_BASE], [])
8302 +
8303 +dnl Usage: gl_TESTS_BASE([DIR])
8304 +AC_DEFUN([gl_TESTS_BASE], [])
8305 +
8306 +dnl Usage: gl_WITH_TESTS
8307 +AC_DEFUN([gl_WITH_TESTS], [])
8308 +
8309 +dnl Usage: gl_LIB([LIBNAME])
8310 +AC_DEFUN([gl_LIB], [])
8311 +
8312 +dnl Usage: gl_LGPL or gl_LGPL([VERSION])
8313 +AC_DEFUN([gl_LGPL], [])
8314 +
8315 +dnl Usage: gl_MAKEFILE_NAME([FILENAME])
8316 +AC_DEFUN([gl_MAKEFILE_NAME], [])
8317 +
8318 +dnl Usage: gl_LIBTOOL
8319 +AC_DEFUN([gl_LIBTOOL], [])
8320 +
8321 +dnl Usage: gl_MACRO_PREFIX([PREFIX])
8322 +AC_DEFUN([gl_MACRO_PREFIX], [])
8323 +
8324 +dnl Usage: gl_PO_DOMAIN([DOMAIN])
8325 +AC_DEFUN([gl_PO_DOMAIN], [])
8326 +
8327 +dnl Usage: gl_VC_FILES([BOOLEAN])
8328 +AC_DEFUN([gl_VC_FILES], [])
8329 diff -urN popt-for-windows/m4/include_next.m4 popt-for-windows-gnulib/m4/include_next.m4
8330 --- popt-for-windows/m4/include_next.m4 1970-01-01 01:00:00.000000000 +0100
8331 +++ popt-for-windows-gnulib/m4/include_next.m4  2008-10-25 15:17:05.000000000 +0100
8332 @@ -0,0 +1,128 @@
8333 +# include_next.m4 serial 8
8334 +dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
8335 +dnl This file is free software; the Free Software Foundation
8336 +dnl gives unlimited permission to copy and/or distribute it,
8337 +dnl with or without modifications, as long as this notice is preserved.
8338 +
8339 +dnl From Paul Eggert and Derek Price.
8340 +
8341 +dnl Sets INCLUDE_NEXT and PRAGMA_SYSTEM_HEADER.
8342 +dnl
8343 +dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to
8344 +dnl 'include' otherwise.
8345 +dnl
8346 +dnl PRAGMA_SYSTEM_HEADER can be used in files that contain #include_next,
8347 +dnl so as to avoid GCC warnings when the gcc option -pedantic is used.
8348 +dnl '#pragma GCC system_header' has the same effect as if the file was found
8349 +dnl through the include search path specified with '-isystem' options (as
8350 +dnl opposed to the search path specified with '-I' options). Namely, gcc
8351 +dnl does not warn about some things, and on some systems (Solaris and Interix)
8352 +dnl __STDC__ evaluates to 0 instead of to 1. The latter is an undesired side
8353 +dnl effect; we are therefore careful to use 'defined __STDC__' or '1' instead
8354 +dnl of plain '__STDC__'.
8355 +
8356 +AC_DEFUN([gl_INCLUDE_NEXT],
8357 +[
8358 +  AC_LANG_PREPROC_REQUIRE()
8359 +  AC_CACHE_CHECK([whether the preprocessor supports include_next],
8360 +    [gl_cv_have_include_next],
8361 +    [rm -rf conftestd1 conftestd2
8362 +     mkdir conftestd1 conftestd2
8363 +     dnl The include of <stdio.h> is because IBM C 9.0 on AIX 6.1 supports
8364 +     dnl include_next when used as first preprocessor directive in a file,
8365 +     dnl but not when preceded by another include directive.
8366 +     cat <<EOF > conftestd1/conftest.h
8367 +#define DEFINED_IN_CONFTESTD1
8368 +#include <stdio.h>
8369 +#include_next <conftest.h>
8370 +#ifdef DEFINED_IN_CONFTESTD2
8371 +int foo;
8372 +#else
8373 +#error "include_next doesn't work"
8374 +#endif
8375 +EOF
8376 +     cat <<EOF > conftestd2/conftest.h
8377 +#ifndef DEFINED_IN_CONFTESTD1
8378 +#error "include_next test doesn't work"
8379 +#endif
8380 +#define DEFINED_IN_CONFTESTD2
8381 +EOF
8382 +     save_CPPFLAGS="$CPPFLAGS"
8383 +     CPPFLAGS="$CPPFLAGS -Iconftestd1 -Iconftestd2"
8384 +     AC_COMPILE_IFELSE([#include <conftest.h>],
8385 +       [gl_cv_have_include_next=yes],
8386 +       [gl_cv_have_include_next=no])
8387 +     CPPFLAGS="$save_CPPFLAGS"
8388 +     rm -rf conftestd1 conftestd2
8389 +    ])
8390 +  PRAGMA_SYSTEM_HEADER=
8391 +  if test $gl_cv_have_include_next = yes; then
8392 +    INCLUDE_NEXT=include_next
8393 +    if test -n "$GCC"; then
8394 +      PRAGMA_SYSTEM_HEADER='#pragma GCC system_header'
8395 +    fi
8396 +  else
8397 +    INCLUDE_NEXT=include
8398 +  fi
8399 +  AC_SUBST([INCLUDE_NEXT])
8400 +  AC_SUBST([PRAGMA_SYSTEM_HEADER])
8401 +])
8402 +
8403 +# gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...)
8404 +# ------------------------------------------
8405 +# For each arg foo.h, if #include_next works, define NEXT_FOO_H to be
8406 +# '<foo.h>'; otherwise define it to be
8407 +# '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
8408 +# That way, a header file with the following line:
8409 +#      #@INCLUDE_NEXT@ @NEXT_FOO_H@
8410 +# behaves (after sed substitution) as if it contained
8411 +#      #include_next <foo.h>
8412 +# even if the compiler does not support include_next.
8413 +# The three "///" are to pacify Sun C 5.8, which otherwise would say
8414 +# "warning: #include of /usr/include/... may be non-portable".
8415 +# Use `""', not `<>', so that the /// cannot be confused with a C99 comment.
8416 +# Note: This macro assumes that the header file is not empty after
8417 +# preprocessing, i.e. it does not only define preprocessor macros but also
8418 +# provides some type/enum definitions or function/variable declarations.
8419 +AC_DEFUN([gl_CHECK_NEXT_HEADERS],
8420 +[
8421 +  AC_REQUIRE([gl_INCLUDE_NEXT])
8422 +  AC_CHECK_HEADERS_ONCE([$1])
8423 +
8424 +  m4_foreach_w([gl_HEADER_NAME], [$1],
8425 +    [AS_VAR_PUSHDEF([gl_next_header],
8426 +                   [gl_cv_next_]m4_quote(m4_defn([gl_HEADER_NAME])))
8427 +     if test $gl_cv_have_include_next = yes; then
8428 +       AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
8429 +     else
8430 +       AC_CACHE_CHECK(
8431 +        [absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>],
8432 +        m4_quote(m4_defn([gl_next_header])),
8433 +        [AS_VAR_PUSHDEF([gl_header_exists],
8434 +                        [ac_cv_header_]m4_quote(m4_defn([gl_HEADER_NAME])))
8435 +         if test AS_VAR_GET(gl_header_exists) = yes; then
8436 +           AC_LANG_CONFTEST(
8437 +             [AC_LANG_SOURCE(
8438 +                [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
8439 +              )])
8440 +           dnl eval is necessary to expand ac_cpp.
8441 +           dnl Ultrix and Pyramid sh refuse to redirect output of eval,
8442 +           dnl so use subshell.
8443 +           AS_VAR_SET([gl_next_header],
8444 +             ['"'`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
8445 +              sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{
8446 +                s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#
8447 +                s#^/[^/]#//&#
8448 +                p
8449 +                q
8450 +              }'`'"'])
8451 +         else
8452 +           AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
8453 +         fi
8454 +         AS_VAR_POPDEF([gl_header_exists])])
8455 +     fi
8456 +     AC_SUBST(
8457 +       AS_TR_CPP([NEXT_]m4_quote(m4_defn([gl_HEADER_NAME]))),
8458 +       [AS_VAR_GET([gl_next_header])])
8459 +     AS_VAR_POPDEF([gl_next_header])])
8460 +])
8461 diff -urN popt-for-windows/m4/malloc.m4 popt-for-windows-gnulib/m4/malloc.m4
8462 --- popt-for-windows/m4/malloc.m4       1970-01-01 01:00:00.000000000 +0100
8463 +++ popt-for-windows-gnulib/m4/malloc.m4        2008-10-25 15:17:05.000000000 +0100
8464 @@ -0,0 +1,41 @@
8465 +# malloc.m4 serial 8
8466 +dnl Copyright (C) 2007 Free Software Foundation, Inc.
8467 +dnl This file is free software; the Free Software Foundation
8468 +dnl gives unlimited permission to copy and/or distribute it,
8469 +dnl with or without modifications, as long as this notice is preserved.
8470 +
8471 +# gl_FUNC_MALLOC_POSIX
8472 +# --------------------
8473 +# Test whether 'malloc' is POSIX compliant (sets errno to ENOMEM when it
8474 +# fails), and replace malloc if it is not.
8475 +AC_DEFUN([gl_FUNC_MALLOC_POSIX],
8476 +[
8477 +  AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
8478 +  if test $gl_cv_func_malloc_posix = yes; then
8479 +    HAVE_MALLOC_POSIX=1
8480 +    AC_DEFINE([HAVE_MALLOC_POSIX], 1,
8481 +      [Define if the 'malloc' function is POSIX compliant.])
8482 +  else
8483 +    AC_LIBOBJ([malloc])
8484 +    HAVE_MALLOC_POSIX=0
8485 +  fi
8486 +  AC_SUBST([HAVE_MALLOC_POSIX])
8487 +])
8488 +
8489 +# Test whether malloc, realloc, calloc are POSIX compliant,
8490 +# Set gl_cv_func_malloc_posix to yes or no accordingly.
8491 +AC_DEFUN([gl_CHECK_MALLOC_POSIX],
8492 +[
8493 +  AC_CACHE_CHECK([whether malloc, realloc, calloc are POSIX compliant],
8494 +    [gl_cv_func_malloc_posix],
8495 +    [
8496 +      dnl It is too dangerous to try to allocate a large amount of memory:
8497 +      dnl some systems go to their knees when you do that. So assume that
8498 +      dnl all Unix implementations of the function are POSIX compliant.
8499 +      AC_TRY_COMPILE([],
8500 +        [#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
8501 +         choke me
8502 +         #endif
8503 +        ], [gl_cv_func_malloc_posix=yes], [gl_cv_func_malloc_posix=no])
8504 +    ])
8505 +])
8506 diff -urN popt-for-windows/m4/mbstate_t.m4 popt-for-windows-gnulib/m4/mbstate_t.m4
8507 --- popt-for-windows/m4/mbstate_t.m4    1970-01-01 01:00:00.000000000 +0100
8508 +++ popt-for-windows-gnulib/m4/mbstate_t.m4     2008-10-25 15:17:05.000000000 +0100
8509 @@ -0,0 +1,30 @@
8510 +# mbstate_t.m4 serial 10
8511 +dnl Copyright (C) 2000-2002, 2008 Free Software Foundation, Inc.
8512 +dnl This file is free software; the Free Software Foundation
8513 +dnl gives unlimited permission to copy and/or distribute it,
8514 +dnl with or without modifications, as long as this notice is preserved.
8515 +
8516 +# From Paul Eggert.
8517 +
8518 +# BeOS 5 has <wchar.h> but does not define mbstate_t,
8519 +# so you can't declare an object of that type.
8520 +# Check for this incompatibility with Standard C.
8521 +
8522 +# AC_TYPE_MBSTATE_T
8523 +# -----------------
8524 +AC_DEFUN([AC_TYPE_MBSTATE_T],
8525 +  [AC_CACHE_CHECK([for mbstate_t], ac_cv_type_mbstate_t,
8526 +     [AC_COMPILE_IFELSE(
8527 +       [AC_LANG_PROGRAM(
8528 +          [AC_INCLUDES_DEFAULT[
8529 +#          include <wchar.h>]],
8530 +          [[mbstate_t x; return sizeof x;]])],
8531 +       [ac_cv_type_mbstate_t=yes],
8532 +       [ac_cv_type_mbstate_t=no])])
8533 +   if test $ac_cv_type_mbstate_t = yes; then
8534 +     AC_DEFINE([HAVE_MBSTATE_T], 1,
8535 +              [Define to 1 if <wchar.h> declares mbstate_t.])
8536 +   else
8537 +     AC_DEFINE([mbstate_t], int,
8538 +              [Define to a type if <wchar.h> does not define.])
8539 +   fi])
8540 diff -urN popt-for-windows/m4/mempcpy.m4 popt-for-windows-gnulib/m4/mempcpy.m4
8541 --- popt-for-windows/m4/mempcpy.m4      1970-01-01 01:00:00.000000000 +0100
8542 +++ popt-for-windows-gnulib/m4/mempcpy.m4       2008-10-25 15:17:05.000000000 +0100
8543 @@ -0,0 +1,26 @@
8544 +# mempcpy.m4 serial 9
8545 +dnl Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
8546 +dnl This file is free software; the Free Software Foundation
8547 +dnl gives unlimited permission to copy and/or distribute it,
8548 +dnl with or without modifications, as long as this notice is preserved.
8549 +
8550 +AC_DEFUN([gl_FUNC_MEMPCPY],
8551 +[
8552 +  dnl Persuade glibc <string.h> to declare mempcpy().
8553 +  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
8554 +
8555 +  dnl The mempcpy() declaration in lib/string.in.h uses 'restrict'.
8556 +  AC_REQUIRE([AC_C_RESTRICT])
8557 +
8558 +  AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
8559 +  AC_REPLACE_FUNCS(mempcpy)
8560 +  if test $ac_cv_func_mempcpy = no; then
8561 +    HAVE_MEMPCPY=0
8562 +    gl_PREREQ_MEMPCPY
8563 +  fi
8564 +])
8565 +
8566 +# Prerequisites of lib/mempcpy.c.
8567 +AC_DEFUN([gl_PREREQ_MEMPCPY], [
8568 +  :
8569 +])
8570 diff -urN popt-for-windows/m4/onceonly.m4 popt-for-windows-gnulib/m4/onceonly.m4
8571 --- popt-for-windows/m4/onceonly.m4     1970-01-01 01:00:00.000000000 +0100
8572 +++ popt-for-windows-gnulib/m4/onceonly.m4      2008-10-25 15:17:05.000000000 +0100
8573 @@ -0,0 +1,90 @@
8574 +# onceonly.m4 serial 6
8575 +dnl Copyright (C) 2002-2003, 2005-2006, 2008 Free Software Foundation, Inc.
8576 +dnl This file is free software, distributed under the terms of the GNU
8577 +dnl General Public License.  As a special exception to the GNU General
8578 +dnl Public License, this file may be distributed as part of a program
8579 +dnl that contains a configuration script generated by Autoconf, under
8580 +dnl the same distribution terms as the rest of that program.
8581 +
8582 +dnl This file defines some "once only" variants of standard autoconf macros.
8583 +dnl   AC_CHECK_HEADERS_ONCE          like  AC_CHECK_HEADERS
8584 +dnl   AC_CHECK_FUNCS_ONCE            like  AC_CHECK_FUNCS
8585 +dnl   AC_CHECK_DECLS_ONCE            like  AC_CHECK_DECLS
8586 +dnl   AC_REQUIRE([AC_FUNC_STRCOLL])  like  AC_FUNC_STRCOLL
8587 +dnl The advantage is that the check for each of the headers/functions/decls
8588 +dnl will be put only once into the 'configure' file. It keeps the size of
8589 +dnl the 'configure' file down, and avoids redundant output when 'configure'
8590 +dnl is run.
8591 +dnl The drawback is that the checks cannot be conditionalized. If you write
8592 +dnl   if some_condition; then gl_CHECK_HEADERS(stdlib.h); fi
8593 +dnl inside an AC_DEFUNed function, the gl_CHECK_HEADERS macro call expands to
8594 +dnl empty, and the check will be inserted before the body of the AC_DEFUNed
8595 +dnl function.
8596 +
8597 +dnl The original code implemented AC_CHECK_HEADERS_ONCE and AC_CHECK_FUNCS_ONCE
8598 +dnl in terms of AC_DEFUN and AC_REQUIRE. This implementation uses diversions to
8599 +dnl named sections DEFAULTS and INIT_PREPARE in order to check all requested
8600 +dnl headers at once, thus reducing the size of 'configure'. It is known to work
8601 +dnl with autoconf 2.57..2.62 at least . The size reduction is ca. 9%.
8602 +
8603 +dnl Autoconf version 2.59 plus gnulib is required; this file is not needed
8604 +dnl with Autoconf 2.60 or greater. But note that autoconf's implementation of
8605 +dnl AC_CHECK_DECLS_ONCE expects a comma-separated list of symbols as first
8606 +dnl argument!
8607 +AC_PREREQ([2.59])
8608 +
8609 +# AC_CHECK_HEADERS_ONCE(HEADER1 HEADER2 ...) is a once-only variant of
8610 +# AC_CHECK_HEADERS(HEADER1 HEADER2 ...).
8611 +AC_DEFUN([AC_CHECK_HEADERS_ONCE], [
8612 +  :
8613 +  m4_foreach_w([gl_HEADER_NAME], [$1], [
8614 +    AC_DEFUN([gl_CHECK_HEADER_]m4_quote(translit(gl_HEADER_NAME,
8615 +                                                 [./-], [___])), [
8616 +      m4_divert_text([INIT_PREPARE],
8617 +        [gl_header_list="$gl_header_list gl_HEADER_NAME"])
8618 +      gl_HEADERS_EXPANSION
8619 +      AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_HEADER_NAME])),
8620 +        [Define to 1 if you have the <]m4_defn([gl_HEADER_NAME])[> header file.])
8621 +    ])
8622 +    AC_REQUIRE([gl_CHECK_HEADER_]m4_quote(translit(gl_HEADER_NAME,
8623 +                                                   [./-], [___])))
8624 +  ])
8625 +])
8626 +m4_define([gl_HEADERS_EXPANSION], [
8627 +  m4_divert_text([DEFAULTS], [gl_header_list=])
8628 +  AC_CHECK_HEADERS([$gl_header_list])
8629 +  m4_define([gl_HEADERS_EXPANSION], [])
8630 +])
8631 +
8632 +# AC_CHECK_FUNCS_ONCE(FUNC1 FUNC2 ...) is a once-only variant of
8633 +# AC_CHECK_FUNCS(FUNC1 FUNC2 ...).
8634 +AC_DEFUN([AC_CHECK_FUNCS_ONCE], [
8635 +  :
8636 +  m4_foreach_w([gl_FUNC_NAME], [$1], [
8637 +    AC_DEFUN([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]), [
8638 +      m4_divert_text([INIT_PREPARE],
8639 +        [gl_func_list="$gl_func_list gl_FUNC_NAME"])
8640 +      gl_FUNCS_EXPANSION
8641 +      AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_FUNC_NAME])),
8642 +        [Define to 1 if you have the `]m4_defn([gl_FUNC_NAME])[' function.])
8643 +    ])
8644 +    AC_REQUIRE([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]))
8645 +  ])
8646 +])
8647 +m4_define([gl_FUNCS_EXPANSION], [
8648 +  m4_divert_text([DEFAULTS], [gl_func_list=])
8649 +  AC_CHECK_FUNCS([$gl_func_list])
8650 +  m4_define([gl_FUNCS_EXPANSION], [])
8651 +])
8652 +
8653 +# AC_CHECK_DECLS_ONCE(DECL1 DECL2 ...) is a once-only variant of
8654 +# AC_CHECK_DECLS(DECL1, DECL2, ...).
8655 +AC_DEFUN([AC_CHECK_DECLS_ONCE], [
8656 +  :
8657 +  m4_foreach_w([gl_DECL_NAME], [$1], [
8658 +    AC_DEFUN([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]), [
8659 +      AC_CHECK_DECLS(m4_defn([gl_DECL_NAME]))
8660 +    ])
8661 +    AC_REQUIRE([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]))
8662 +  ])
8663 +])
8664 diff -urN popt-for-windows/m4/stdbool.m4 popt-for-windows-gnulib/m4/stdbool.m4
8665 --- popt-for-windows/m4/stdbool.m4      1970-01-01 01:00:00.000000000 +0100
8666 +++ popt-for-windows-gnulib/m4/stdbool.m4       2008-10-25 15:17:05.000000000 +0100
8667 @@ -0,0 +1,115 @@
8668 +# Check for stdbool.h that conforms to C99.
8669 +
8670 +dnl Copyright (C) 2002-2006 Free Software Foundation, Inc.
8671 +dnl This file is free software; the Free Software Foundation
8672 +dnl gives unlimited permission to copy and/or distribute it,
8673 +dnl with or without modifications, as long as this notice is preserved.
8674 +
8675 +# Prepare for substituting <stdbool.h> if it is not supported.
8676 +
8677 +AC_DEFUN([AM_STDBOOL_H],
8678 +[
8679 +  AC_REQUIRE([AC_HEADER_STDBOOL])
8680 +
8681 +  # Define two additional variables used in the Makefile substitution.
8682 +
8683 +  if test "$ac_cv_header_stdbool_h" = yes; then
8684 +    STDBOOL_H=''
8685 +  else
8686 +    STDBOOL_H='stdbool.h'
8687 +  fi
8688 +  AC_SUBST([STDBOOL_H])
8689 +
8690 +  if test "$ac_cv_type__Bool" = yes; then
8691 +    HAVE__BOOL=1
8692 +  else
8693 +    HAVE__BOOL=0
8694 +  fi
8695 +  AC_SUBST([HAVE__BOOL])
8696 +])
8697 +
8698 +# AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future.
8699 +AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H])
8700 +
8701 +# This macro is only needed in autoconf <= 2.59.  Newer versions of autoconf
8702 +# have this macro built-in.
8703 +
8704 +AC_DEFUN([AC_HEADER_STDBOOL],
8705 +  [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
8706 +     [ac_cv_header_stdbool_h],
8707 +     [AC_TRY_COMPILE(
8708 +       [
8709 +         #include <stdbool.h>
8710 +         #ifndef bool
8711 +          "error: bool is not defined"
8712 +         #endif
8713 +         #ifndef false
8714 +          "error: false is not defined"
8715 +         #endif
8716 +         #if false
8717 +          "error: false is not 0"
8718 +         #endif
8719 +         #ifndef true
8720 +          "error: true is not defined"
8721 +         #endif
8722 +         #if true != 1
8723 +          "error: true is not 1"
8724 +         #endif
8725 +         #ifndef __bool_true_false_are_defined
8726 +          "error: __bool_true_false_are_defined is not defined"
8727 +         #endif
8728 +
8729 +         struct s { _Bool s: 1; _Bool t; } s;
8730 +
8731 +         char a[true == 1 ? 1 : -1];
8732 +         char b[false == 0 ? 1 : -1];
8733 +         char c[__bool_true_false_are_defined == 1 ? 1 : -1];
8734 +         char d[(bool) 0.5 == true ? 1 : -1];
8735 +         bool e = &s;
8736 +         char f[(_Bool) 0.0 == false ? 1 : -1];
8737 +         char g[true];
8738 +         char h[sizeof (_Bool)];
8739 +         char i[sizeof s.t];
8740 +         enum { j = false, k = true, l = false * true, m = true * 256 };
8741 +         _Bool n[m];
8742 +         char o[sizeof n == m * sizeof n[0] ? 1 : -1];
8743 +         char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
8744 +         #if defined __xlc__ || defined __GNUC__
8745 +          /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
8746 +             reported by James Lemley on 2005-10-05; see
8747 +             http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
8748 +             This test is not quite right, since xlc is allowed to
8749 +             reject this program, as the initializer for xlcbug is
8750 +             not one of the forms that C requires support for.
8751 +             However, doing the test right would require a run-time
8752 +             test, and that would make cross-compilation harder.
8753 +             Let us hope that IBM fixes the xlc bug, and also adds
8754 +             support for this kind of constant expression.  In the
8755 +             meantime, this test will reject xlc, which is OK, since
8756 +             our stdbool.h substitute should suffice.  We also test
8757 +             this with GCC, where it should work, to detect more
8758 +             quickly whether someone messes up the test in the
8759 +             future.  */
8760 +          char digs[] = "0123456789";
8761 +          int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
8762 +         #endif
8763 +         /* Catch a bug in an HP-UX C compiler.  See
8764 +            http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
8765 +            http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
8766 +          */
8767 +         _Bool q = true;
8768 +         _Bool *pq = &q;
8769 +       ],
8770 +       [
8771 +         *pq |= q;
8772 +         *pq |= ! q;
8773 +         /* Refer to every declared value, to avoid compiler optimizations.  */
8774 +         return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
8775 +                 + !m + !n + !o + !p + !q + !pq);
8776 +       ],
8777 +       [ac_cv_header_stdbool_h=yes],
8778 +       [ac_cv_header_stdbool_h=no])])
8779 +   AC_CHECK_TYPES([_Bool])
8780 +   if test $ac_cv_header_stdbool_h = yes; then
8781 +     AC_DEFINE(HAVE_STDBOOL_H, 1, [Define to 1 if stdbool.h conforms to C99.])
8782 +   fi])
8783 diff -urN popt-for-windows/m4/stdlib_h.m4 popt-for-windows-gnulib/m4/stdlib_h.m4
8784 --- popt-for-windows/m4/stdlib_h.m4     1970-01-01 01:00:00.000000000 +0100
8785 +++ popt-for-windows-gnulib/m4/stdlib_h.m4      2008-10-25 15:17:05.000000000 +0100
8786 @@ -0,0 +1,60 @@
8787 +# stdlib_h.m4 serial 11
8788 +dnl Copyright (C) 2007, 2008 Free Software Foundation, Inc.
8789 +dnl This file is free software; the Free Software Foundation
8790 +dnl gives unlimited permission to copy and/or distribute it,
8791 +dnl with or without modifications, as long as this notice is preserved.
8792 +
8793 +AC_DEFUN([gl_STDLIB_H],
8794 +[
8795 +  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
8796 +  gl_CHECK_NEXT_HEADERS([stdlib.h])
8797 +])
8798 +
8799 +AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],
8800 +[
8801 +  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
8802 +  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
8803 +  GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
8804 +])
8805 +
8806 +AC_DEFUN([gl_STDLIB_H_DEFAULTS],
8807 +[
8808 +  GNULIB_MALLOC_POSIX=0;  AC_SUBST([GNULIB_MALLOC_POSIX])
8809 +  GNULIB_REALLOC_POSIX=0; AC_SUBST([GNULIB_REALLOC_POSIX])
8810 +  GNULIB_CALLOC_POSIX=0;  AC_SUBST([GNULIB_CALLOC_POSIX])
8811 +  GNULIB_ATOLL=0;         AC_SUBST([GNULIB_ATOLL])
8812 +  GNULIB_GETLOADAVG=0;    AC_SUBST([GNULIB_GETLOADAVG])
8813 +  GNULIB_GETSUBOPT=0;     AC_SUBST([GNULIB_GETSUBOPT])
8814 +  GNULIB_MKDTEMP=0;       AC_SUBST([GNULIB_MKDTEMP])
8815 +  GNULIB_MKSTEMP=0;       AC_SUBST([GNULIB_MKSTEMP])
8816 +  GNULIB_PUTENV=0;        AC_SUBST([GNULIB_PUTENV])
8817 +  GNULIB_RAND48=0;        AC_SUBST([GNULIB_RAND48])
8818 +  GNULIB_RANDOM_R=0;      AC_SUBST([GNULIB_RANDOM_R])
8819 +  GNULIB_RPMATCH=0;       AC_SUBST([GNULIB_RPMATCH])
8820 +  GNULIB_SETENV=0;        AC_SUBST([GNULIB_SETENV])
8821 +  GNULIB_STRTOD=0;        AC_SUBST([GNULIB_STRTOD])
8822 +  GNULIB_STRTOLL=0;       AC_SUBST([GNULIB_STRTOLL])
8823 +  GNULIB_STRTOULL=0;      AC_SUBST([GNULIB_STRTOULL])
8824 +  GNULIB_UNSETENV=0;      AC_SUBST([GNULIB_UNSETENV])
8825 +  dnl Assume proper GNU behavior unless another module says otherwise.
8826 +  HAVE_ATOLL=1;           AC_SUBST([HAVE_ATOLL])
8827 +  HAVE_CALLOC_POSIX=1;    AC_SUBST([HAVE_CALLOC_POSIX])
8828 +  HAVE_GETSUBOPT=1;       AC_SUBST([HAVE_GETSUBOPT])
8829 +  HAVE_MALLOC_POSIX=1;    AC_SUBST([HAVE_MALLOC_POSIX])
8830 +  HAVE_MKDTEMP=1;         AC_SUBST([HAVE_MKDTEMP])
8831 +  HAVE_REALLOC_POSIX=1;   AC_SUBST([HAVE_REALLOC_POSIX])
8832 +  HAVE_RAND48=1;          AC_SUBST([HAVE_RAND48])
8833 +  HAVE_RANDOM_R=1;        AC_SUBST([HAVE_RANDOM_R])
8834 +  HAVE_RPMATCH=1;         AC_SUBST([HAVE_RPMATCH])
8835 +  HAVE_SETENV=1;          AC_SUBST([HAVE_SETENV])
8836 +  HAVE_STRTOD=1;          AC_SUBST([HAVE_STRTOD])
8837 +  HAVE_STRTOLL=1;         AC_SUBST([HAVE_STRTOLL])
8838 +  HAVE_STRTOULL=1;        AC_SUBST([HAVE_STRTOULL])
8839 +  HAVE_SYS_LOADAVG_H=0;   AC_SUBST([HAVE_SYS_LOADAVG_H])
8840 +  HAVE_UNSETENV=1;        AC_SUBST([HAVE_UNSETENV])
8841 +  HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG])
8842 +  REPLACE_MKSTEMP=0;      AC_SUBST([REPLACE_MKSTEMP])
8843 +  REPLACE_PUTENV=0;       AC_SUBST([REPLACE_PUTENV])
8844 +  REPLACE_STRTOD=0;       AC_SUBST([REPLACE_STRTOD])
8845 +  VOID_UNSETENV=0;        AC_SUBST([VOID_UNSETENV])
8846 +])
8847 diff -urN popt-for-windows/m4/strdup.m4 popt-for-windows-gnulib/m4/strdup.m4
8848 --- popt-for-windows/m4/strdup.m4       1970-01-01 01:00:00.000000000 +0100
8849 +++ popt-for-windows-gnulib/m4/strdup.m4        2008-10-25 15:17:05.000000000 +0100
8850 @@ -0,0 +1,38 @@
8851 +# strdup.m4 serial 10
8852 +
8853 +dnl Copyright (C) 2002-2008 Free Software Foundation, Inc.
8854 +
8855 +dnl This file is free software; the Free Software Foundation
8856 +dnl gives unlimited permission to copy and/or distribute it,
8857 +dnl with or without modifications, as long as this notice is preserved.
8858 +
8859 +AC_DEFUN([gl_FUNC_STRDUP],
8860 +[
8861 +  AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
8862 +  AC_REPLACE_FUNCS(strdup)
8863 +  AC_CHECK_DECLS_ONCE(strdup)
8864 +  if test $ac_cv_have_decl_strdup = no; then
8865 +    HAVE_DECL_STRDUP=0
8866 +  fi
8867 +  gl_PREREQ_STRDUP
8868 +])
8869 +
8870 +AC_DEFUN([gl_FUNC_STRDUP_POSIX],
8871 +[
8872 +  AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
8873 +  AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
8874 +  if test $gl_cv_func_malloc_posix != yes; then
8875 +    REPLACE_STRDUP=1
8876 +    AC_LIBOBJ([strdup])
8877 +  else
8878 +    AC_REPLACE_FUNCS(strdup)
8879 +  fi
8880 +  AC_CHECK_DECLS_ONCE(strdup)
8881 +  if test $ac_cv_have_decl_strdup = no; then
8882 +    HAVE_DECL_STRDUP=0
8883 +  fi
8884 +  gl_PREREQ_STRDUP
8885 +])
8886 +
8887 +# Prerequisites of lib/strdup.c.
8888 +AC_DEFUN([gl_PREREQ_STRDUP], [:])
8889 diff -urN popt-for-windows/m4/string_h.m4 popt-for-windows-gnulib/m4/string_h.m4
8890 --- popt-for-windows/m4/string_h.m4     1970-01-01 01:00:00.000000000 +0100
8891 +++ popt-for-windows-gnulib/m4/string_h.m4      2008-10-25 15:17:05.000000000 +0100
8892 @@ -0,0 +1,92 @@
8893 +# Configure a GNU-like replacement for <string.h>.
8894 +
8895 +# Copyright (C) 2007, 2008 Free Software Foundation, Inc.
8896 +# This file is free software; the Free Software Foundation
8897 +# gives unlimited permission to copy and/or distribute it,
8898 +# with or without modifications, as long as this notice is preserved.
8899 +
8900 +# serial 6
8901 +
8902 +# Written by Paul Eggert.
8903 +
8904 +AC_DEFUN([gl_HEADER_STRING_H],
8905 +[
8906 +  dnl Use AC_REQUIRE here, so that the default behavior below is expanded
8907 +  dnl once only, before all statements that occur in other macros.
8908 +  AC_REQUIRE([gl_HEADER_STRING_H_BODY])
8909 +])
8910 +
8911 +AC_DEFUN([gl_HEADER_STRING_H_BODY],
8912 +[
8913 +  AC_REQUIRE([AC_C_RESTRICT])
8914 +  AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
8915 +  gl_CHECK_NEXT_HEADERS([string.h])
8916 +])
8917 +
8918 +AC_DEFUN([gl_STRING_MODULE_INDICATOR],
8919 +[
8920 +  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
8921 +  AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
8922 +  GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
8923 +])
8924 +
8925 +AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
8926 +[
8927 +  GNULIB_MEMMEM=0;      AC_SUBST([GNULIB_MEMMEM])
8928 +  GNULIB_MEMPCPY=0;     AC_SUBST([GNULIB_MEMPCPY])
8929 +  GNULIB_MEMRCHR=0;     AC_SUBST([GNULIB_MEMRCHR])
8930 +  GNULIB_RAWMEMCHR=0;   AC_SUBST([GNULIB_RAWMEMCHR])
8931 +  GNULIB_STPCPY=0;      AC_SUBST([GNULIB_STPCPY])
8932 +  GNULIB_STPNCPY=0;     AC_SUBST([GNULIB_STPNCPY])
8933 +  GNULIB_STRCHRNUL=0;   AC_SUBST([GNULIB_STRCHRNUL])
8934 +  GNULIB_STRDUP=0;      AC_SUBST([GNULIB_STRDUP])
8935 +  GNULIB_STRNDUP=0;     AC_SUBST([GNULIB_STRNDUP])
8936 +  GNULIB_STRNLEN=0;     AC_SUBST([GNULIB_STRNLEN])
8937 +  GNULIB_STRPBRK=0;     AC_SUBST([GNULIB_STRPBRK])
8938 +  GNULIB_STRSEP=0;      AC_SUBST([GNULIB_STRSEP])
8939 +  GNULIB_STRSTR=0;      AC_SUBST([GNULIB_STRSTR])
8940 +  GNULIB_STRCASESTR=0;  AC_SUBST([GNULIB_STRCASESTR])
8941 +  GNULIB_STRTOK_R=0;    AC_SUBST([GNULIB_STRTOK_R])
8942 +  GNULIB_MBSLEN=0;      AC_SUBST([GNULIB_MBSLEN])
8943 +  GNULIB_MBSNLEN=0;     AC_SUBST([GNULIB_MBSNLEN])
8944 +  GNULIB_MBSCHR=0;      AC_SUBST([GNULIB_MBSCHR])
8945 +  GNULIB_MBSRCHR=0;     AC_SUBST([GNULIB_MBSRCHR])
8946 +  GNULIB_MBSSTR=0;      AC_SUBST([GNULIB_MBSSTR])
8947 +  GNULIB_MBSCASECMP=0;  AC_SUBST([GNULIB_MBSCASECMP])
8948 +  GNULIB_MBSNCASECMP=0; AC_SUBST([GNULIB_MBSNCASECMP])
8949 +  GNULIB_MBSPCASECMP=0; AC_SUBST([GNULIB_MBSPCASECMP])
8950 +  GNULIB_MBSCASESTR=0;  AC_SUBST([GNULIB_MBSCASESTR])
8951 +  GNULIB_MBSCSPN=0;     AC_SUBST([GNULIB_MBSCSPN])
8952 +  GNULIB_MBSPBRK=0;     AC_SUBST([GNULIB_MBSPBRK])
8953 +  GNULIB_MBSSPN=0;      AC_SUBST([GNULIB_MBSSPN])
8954 +  GNULIB_MBSSEP=0;      AC_SUBST([GNULIB_MBSSEP])
8955 +  GNULIB_MBSTOK_R=0;    AC_SUBST([GNULIB_MBSTOK_R])
8956 +  GNULIB_STRERROR=0;    AC_SUBST([GNULIB_STRERROR])
8957 +  GNULIB_STRSIGNAL=0;   AC_SUBST([GNULIB_STRSIGNAL])
8958 +  GNULIB_STRVERSCMP=0;   AC_SUBST([GNULIB_STRVERSCMP])
8959 +  dnl Assume proper GNU behavior unless another module says otherwise.
8960 +  HAVE_DECL_MEMMEM=1;          AC_SUBST([HAVE_DECL_MEMMEM])
8961 +  HAVE_MEMPCPY=1;              AC_SUBST([HAVE_MEMPCPY])
8962 +  HAVE_DECL_MEMRCHR=1;         AC_SUBST([HAVE_DECL_MEMRCHR])
8963 +  HAVE_RAWMEMCHR=1;            AC_SUBST([HAVE_RAWMEMCHR])
8964 +  HAVE_STPCPY=1;               AC_SUBST([HAVE_STPCPY])
8965 +  HAVE_STPNCPY=1;              AC_SUBST([HAVE_STPNCPY])
8966 +  HAVE_STRCHRNUL=1;            AC_SUBST([HAVE_STRCHRNUL])
8967 +  HAVE_DECL_STRDUP=1;          AC_SUBST([HAVE_DECL_STRDUP])
8968 +  HAVE_STRNDUP=1;              AC_SUBST([HAVE_STRNDUP])
8969 +  HAVE_DECL_STRNDUP=1;         AC_SUBST([HAVE_DECL_STRNDUP])
8970 +  HAVE_DECL_STRNLEN=1;         AC_SUBST([HAVE_DECL_STRNLEN])
8971 +  HAVE_STRPBRK=1;              AC_SUBST([HAVE_STRPBRK])
8972 +  HAVE_STRSEP=1;               AC_SUBST([HAVE_STRSEP])
8973 +  HAVE_STRCASESTR=1;           AC_SUBST([HAVE_STRCASESTR])
8974 +  HAVE_DECL_STRTOK_R=1;                AC_SUBST([HAVE_DECL_STRTOK_R])
8975 +  HAVE_DECL_STRERROR=1;                AC_SUBST([HAVE_DECL_STRERROR])
8976 +  HAVE_DECL_STRSIGNAL=1;       AC_SUBST([HAVE_DECL_STRSIGNAL])
8977 +  HAVE_STRVERSCMP=1;           AC_SUBST([HAVE_STRVERSCMP])
8978 +  REPLACE_MEMMEM=0;            AC_SUBST([REPLACE_MEMMEM])
8979 +  REPLACE_STRDUP=0;            AC_SUBST([REPLACE_STRDUP])
8980 +  REPLACE_STRSTR=0;            AC_SUBST([REPLACE_STRSTR])
8981 +  REPLACE_STRCASESTR=0;                AC_SUBST([REPLACE_STRCASESTR])
8982 +  REPLACE_STRERROR=0;          AC_SUBST([REPLACE_STRERROR])
8983 +  REPLACE_STRSIGNAL=0;         AC_SUBST([REPLACE_STRSIGNAL])
8984 +])
8985 diff -urN popt-for-windows/m4/sys_stat_h.m4 popt-for-windows-gnulib/m4/sys_stat_h.m4
8986 --- popt-for-windows/m4/sys_stat_h.m4   1970-01-01 01:00:00.000000000 +0100
8987 +++ popt-for-windows-gnulib/m4/sys_stat_h.m4    2008-10-25 15:17:05.000000000 +0100
8988 @@ -0,0 +1,59 @@
8989 +# sys_stat_h.m4 serial 10   -*- Autoconf -*-
8990 +dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
8991 +dnl This file is free software; the Free Software Foundation
8992 +dnl gives unlimited permission to copy and/or distribute it,
8993 +dnl with or without modifications, as long as this notice is preserved.
8994 +
8995 +dnl From Eric Blake.
8996 +dnl Test whether <sys/stat.h> contains lstat and mkdir or must be substituted.
8997 +
8998 +AC_DEFUN([gl_HEADER_SYS_STAT_H],
8999 +[
9000 +  AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
9001 +
9002 +  dnl Check for lstat.  Systems that lack it (mingw) also lack symlinks, so
9003 +  dnl stat is a good replacement.
9004 +  AC_CHECK_FUNCS_ONCE([lstat])
9005 +  if test $ac_cv_func_lstat = yes; then
9006 +    HAVE_LSTAT=1
9007 +  else
9008 +    HAVE_LSTAT=0
9009 +  fi
9010 +  AC_SUBST([HAVE_LSTAT])
9011 +
9012 +  dnl For the mkdir substitute.
9013 +  AC_REQUIRE([AC_C_INLINE])
9014 +
9015 +  dnl Check for broken stat macros.
9016 +  AC_REQUIRE([AC_HEADER_STAT])
9017 +
9018 +  gl_CHECK_NEXT_HEADERS([sys/stat.h])
9019 +  SYS_STAT_H='sys/stat.h'
9020 +  AC_SUBST([SYS_STAT_H])
9021 +
9022 +  dnl Define types that are supposed to be defined in <sys/types.h> or
9023 +  dnl <sys/stat.h>.
9024 +  AC_CHECK_TYPE([nlink_t], [],
9025 +    [AC_DEFINE([nlink_t], [int],
9026 +       [Define to the type of st_nlink in struct stat, or a supertype.])],
9027 +    [#include <sys/types.h>
9028 +     #include <sys/stat.h>])
9029 +
9030 +]) # gl_HEADER_SYS_STAT_H
9031 +
9032 +AC_DEFUN([gl_SYS_STAT_MODULE_INDICATOR],
9033 +[
9034 +  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
9035 +  AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
9036 +  GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
9037 +])
9038 +
9039 +AC_DEFUN([gl_SYS_STAT_H_DEFAULTS],
9040 +[
9041 +  GNULIB_LCHMOD=0; AC_SUBST([GNULIB_LCHMOD])
9042 +  GNULIB_LSTAT=0;  AC_SUBST([GNULIB_LSTAT])
9043 +  dnl Assume proper GNU behavior unless another module says otherwise.
9044 +  HAVE_LCHMOD=1;   AC_SUBST([HAVE_LCHMOD])
9045 +  REPLACE_LSTAT=0; AC_SUBST([REPLACE_LSTAT])
9046 +  REPLACE_MKDIR=0; AC_SUBST([REPLACE_MKDIR])
9047 +])
9048 diff -urN popt-for-windows/m4/unistd_h.m4 popt-for-windows-gnulib/m4/unistd_h.m4
9049 --- popt-for-windows/m4/unistd_h.m4     1970-01-01 01:00:00.000000000 +0100
9050 +++ popt-for-windows-gnulib/m4/unistd_h.m4      2008-10-25 15:17:05.000000000 +0100
9051 @@ -0,0 +1,81 @@
9052 +# unistd_h.m4 serial 16
9053 +dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
9054 +dnl This file is free software; the Free Software Foundation
9055 +dnl gives unlimited permission to copy and/or distribute it,
9056 +dnl with or without modifications, as long as this notice is preserved.
9057 +
9058 +dnl Written by Simon Josefsson, Bruno Haible.
9059 +
9060 +AC_DEFUN([gl_UNISTD_H],
9061 +[
9062 +  dnl Use AC_REQUIRE here, so that the default behavior below is expanded
9063 +  dnl once only, before all statements that occur in other macros.
9064 +  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
9065 +
9066 +  gl_CHECK_NEXT_HEADERS([unistd.h])
9067 +
9068 +  AC_CHECK_HEADERS_ONCE([unistd.h])
9069 +  if test $ac_cv_header_unistd_h = yes; then
9070 +    HAVE_UNISTD_H=1
9071 +  else
9072 +    HAVE_UNISTD_H=0
9073 +  fi
9074 +  AC_SUBST([HAVE_UNISTD_H])
9075 +])
9076 +
9077 +AC_DEFUN([gl_UNISTD_MODULE_INDICATOR],
9078 +[
9079 +  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
9080 +  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
9081 +  GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
9082 +])
9083 +
9084 +AC_DEFUN([gl_UNISTD_H_DEFAULTS],
9085 +[
9086 +  GNULIB_CHOWN=0;            AC_SUBST([GNULIB_CHOWN])
9087 +  GNULIB_CLOSE=0;            AC_SUBST([GNULIB_CLOSE])
9088 +  GNULIB_DUP2=0;             AC_SUBST([GNULIB_DUP2])
9089 +  GNULIB_ENVIRON=0;          AC_SUBST([GNULIB_ENVIRON])
9090 +  GNULIB_EUIDACCESS=0;       AC_SUBST([GNULIB_EUIDACCESS])
9091 +  GNULIB_FCHDIR=0;           AC_SUBST([GNULIB_FCHDIR])
9092 +  GNULIB_FSYNC=0;            AC_SUBST([GNULIB_FSYNC])
9093 +  GNULIB_FTRUNCATE=0;        AC_SUBST([GNULIB_FTRUNCATE])
9094 +  GNULIB_GETCWD=0;           AC_SUBST([GNULIB_GETCWD])
9095 +  GNULIB_GETDOMAINNAME=0;    AC_SUBST([GNULIB_GETDOMAINNAME])
9096 +  GNULIB_GETDTABLESIZE=0;    AC_SUBST([GNULIB_GETDTABLESIZE])
9097 +  GNULIB_GETHOSTNAME=0;      AC_SUBST([GNULIB_GETHOSTNAME])
9098 +  GNULIB_GETLOGIN_R=0;       AC_SUBST([GNULIB_GETLOGIN_R])
9099 +  GNULIB_GETPAGESIZE=0;      AC_SUBST([GNULIB_GETPAGESIZE])
9100 +  GNULIB_GETUSERSHELL=0;     AC_SUBST([GNULIB_GETUSERSHELL])
9101 +  GNULIB_LCHOWN=0;           AC_SUBST([GNULIB_LCHOWN])
9102 +  GNULIB_LSEEK=0;            AC_SUBST([GNULIB_LSEEK])
9103 +  GNULIB_READLINK=0;         AC_SUBST([GNULIB_READLINK])
9104 +  GNULIB_SLEEP=0;            AC_SUBST([GNULIB_SLEEP])
9105 +  GNULIB_UNISTD_H_SIGPIPE=0; AC_SUBST([GNULIB_UNISTD_H_SIGPIPE])
9106 +  GNULIB_WRITE=0;            AC_SUBST([GNULIB_WRITE])
9107 +  dnl Assume proper GNU behavior unless another module says otherwise.
9108 +  HAVE_DUP2=1;            AC_SUBST([HAVE_DUP2])
9109 +  HAVE_EUIDACCESS=1;      AC_SUBST([HAVE_EUIDACCESS])
9110 +  HAVE_FSYNC=1;           AC_SUBST([HAVE_FSYNC])
9111 +  HAVE_FTRUNCATE=1;       AC_SUBST([HAVE_FTRUNCATE])
9112 +  HAVE_GETDOMAINNAME=1;   AC_SUBST([HAVE_GETDOMAINNAME])
9113 +  HAVE_GETDTABLESIZE=1;   AC_SUBST([HAVE_GETDTABLESIZE])
9114 +  HAVE_GETHOSTNAME=1;     AC_SUBST([HAVE_GETHOSTNAME])
9115 +  HAVE_GETPAGESIZE=1;     AC_SUBST([HAVE_GETPAGESIZE])
9116 +  HAVE_GETUSERSHELL=1;    AC_SUBST([HAVE_GETUSERSHELL])
9117 +  HAVE_READLINK=1;        AC_SUBST([HAVE_READLINK])
9118 +  HAVE_SLEEP=1;           AC_SUBST([HAVE_SLEEP])
9119 +  HAVE_DECL_ENVIRON=1;    AC_SUBST([HAVE_DECL_ENVIRON])
9120 +  HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R])
9121 +  HAVE_OS_H=0;            AC_SUBST([HAVE_OS_H])
9122 +  HAVE_SYS_PARAM_H=0;     AC_SUBST([HAVE_SYS_PARAM_H])
9123 +  REPLACE_CHOWN=0;        AC_SUBST([REPLACE_CHOWN])
9124 +  REPLACE_CLOSE=0;        AC_SUBST([REPLACE_CLOSE])
9125 +  REPLACE_FCHDIR=0;       AC_SUBST([REPLACE_FCHDIR])
9126 +  REPLACE_GETCWD=0;       AC_SUBST([REPLACE_GETCWD])
9127 +  REPLACE_GETPAGESIZE=0;  AC_SUBST([REPLACE_GETPAGESIZE])
9128 +  REPLACE_LCHOWN=0;       AC_SUBST([REPLACE_LCHOWN])
9129 +  REPLACE_LSEEK=0;        AC_SUBST([REPLACE_LSEEK])
9130 +  REPLACE_WRITE=0;        AC_SUBST([REPLACE_WRITE])
9131 +  UNISTD_H_HAVE_WINSOCK2_H=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H])
9132 +])
9133 diff -urN popt-for-windows/m4/wchar.m4 popt-for-windows-gnulib/m4/wchar.m4
9134 --- popt-for-windows/m4/wchar.m4        1970-01-01 01:00:00.000000000 +0100
9135 +++ popt-for-windows-gnulib/m4/wchar.m4 2008-10-25 15:17:05.000000000 +0100
9136 @@ -0,0 +1,69 @@
9137 +dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues.
9138 +
9139 +dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
9140 +dnl This file is free software; the Free Software Foundation
9141 +dnl gives unlimited permission to copy and/or distribute it,
9142 +dnl with or without modifications, as long as this notice is preserved.
9143 +
9144 +dnl Written by Eric Blake.
9145 +
9146 +# wchar.m4 serial 6
9147 +
9148 +AC_DEFUN([gl_WCHAR_H],
9149 +[
9150 +  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
9151 +  AC_CACHE_CHECK([whether <wchar.h> is standalone],
9152 +    [gl_cv_header_wchar_h_standalone],
9153 +    [AC_COMPILE_IFELSE([[#include <wchar.h>
9154 +wchar_t w;]],
9155 +      [gl_cv_header_wchar_h_standalone=yes],
9156 +      [gl_cv_header_wchar_h_standalone=no])])
9157 +
9158 +  AC_REQUIRE([gt_TYPE_WINT_T])
9159 +  if test $gt_cv_c_wint_t = yes; then
9160 +    HAVE_WINT_T=1
9161 +  else
9162 +    HAVE_WINT_T=0
9163 +  fi
9164 +  AC_SUBST([HAVE_WINT_T])
9165 +
9166 +  if test $gl_cv_header_wchar_h_standalone != yes || test $gt_cv_c_wint_t != yes; then
9167 +    WCHAR_H=wchar.h
9168 +  fi
9169 +
9170 +  dnl Prepare for creating substitute <wchar.h>.
9171 +  dnl Do it always: WCHAR_H may be empty here but can be set later.
9172 +  dnl Check for <wchar.h> (missing in Linux uClibc when built without wide
9173 +  dnl character support).
9174 +  AC_CHECK_HEADERS_ONCE([wchar.h])
9175 +  if test $ac_cv_header_wchar_h = yes; then
9176 +    HAVE_WCHAR_H=1
9177 +  else
9178 +    HAVE_WCHAR_H=0
9179 +  fi
9180 +  AC_SUBST([HAVE_WCHAR_H])
9181 +  gl_CHECK_NEXT_HEADERS([wchar.h])
9182 +])
9183 +
9184 +dnl Unconditionally enables the replacement of <wchar.h>.
9185 +AC_DEFUN([gl_REPLACE_WCHAR_H],
9186 +[
9187 +  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
9188 +  WCHAR_H=wchar.h
9189 +])
9190 +
9191 +AC_DEFUN([gl_WCHAR_MODULE_INDICATOR],
9192 +[
9193 +  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
9194 +  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
9195 +  GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
9196 +])
9197 +
9198 +AC_DEFUN([gl_WCHAR_H_DEFAULTS],
9199 +[
9200 +  GNULIB_WCWIDTH=0; AC_SUBST([GNULIB_WCWIDTH])
9201 +  dnl Assume proper GNU behavior unless another module says otherwise.
9202 +  HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH])
9203 +  REPLACE_WCWIDTH=0;   AC_SUBST([REPLACE_WCWIDTH])
9204 +  WCHAR_H='';          AC_SUBST([WCHAR_H])
9205 +])
9206 diff -urN popt-for-windows/m4/wctype.m4 popt-for-windows-gnulib/m4/wctype.m4
9207 --- popt-for-windows/m4/wctype.m4       1970-01-01 01:00:00.000000000 +0100
9208 +++ popt-for-windows-gnulib/m4/wctype.m4        2008-10-25 15:17:05.000000000 +0100
9209 @@ -0,0 +1,74 @@
9210 +# wctype.m4 serial 2
9211 +
9212 +dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
9213 +
9214 +dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
9215 +dnl This file is free software; the Free Software Foundation
9216 +dnl gives unlimited permission to copy and/or distribute it,
9217 +dnl with or without modifications, as long as this notice is preserved.
9218 +
9219 +dnl Written by Paul Eggert.
9220 +
9221 +AC_DEFUN([gl_WCTYPE_H],
9222 +[
9223 +  AC_REQUIRE([AC_PROG_CC])
9224 +  AC_CHECK_FUNCS_ONCE([iswcntrl])
9225 +  if test $ac_cv_func_iswcntrl = yes; then
9226 +    HAVE_ISWCNTRL=1
9227 +  else
9228 +    HAVE_ISWCNTRL=0
9229 +  fi
9230 +  AC_SUBST([HAVE_ISWCNTRL])
9231 +  AC_CHECK_HEADERS_ONCE([wctype.h])
9232 +  AC_REQUIRE([AC_C_INLINE])
9233 +
9234 +  AC_REQUIRE([gt_TYPE_WINT_T])
9235 +  if test $gt_cv_c_wint_t = yes; then
9236 +    HAVE_WINT_T=1
9237 +  else
9238 +    HAVE_WINT_T=0
9239 +  fi
9240 +  AC_SUBST([HAVE_WINT_T])
9241 +
9242 +  WCTYPE_H=wctype.h
9243 +  if test $ac_cv_header_wctype_h = yes; then
9244 +    if test $ac_cv_func_iswcntrl = yes; then
9245 +      dnl Linux libc5 has an iswprint function that returns 0 for all arguments.
9246 +      dnl The other functions are likely broken in the same way.
9247 +      AC_CACHE_CHECK([whether iswcntrl works], [gl_cv_func_iswcntrl_works],
9248 +        [
9249 +          AC_TRY_RUN([#include <stddef.h>
9250 +                      #include <stdio.h>
9251 +                      #include <time.h>
9252 +                      #include <wchar.h>
9253 +                      #include <wctype.h>
9254 +                      int main () { return iswprint ('x') == 0; }],
9255 +            [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no],
9256 +            [AC_TRY_COMPILE([#include <stdlib.h>
9257 +                          #if __GNU_LIBRARY__ == 1
9258 +                          Linux libc5 i18n is broken.
9259 +                          #endif], [],
9260 +              [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no])
9261 +            ])
9262 +        ])
9263 +      if test $gl_cv_func_iswcntrl_works = yes; then
9264 +        WCTYPE_H=
9265 +      fi
9266 +    fi
9267 +    dnl Compute NEXT_WCTYPE_H even if WCTYPE_H is empty,
9268 +    dnl for the benefit of builds from non-distclean directories.
9269 +    gl_CHECK_NEXT_HEADERS([wctype.h])
9270 +    HAVE_WCTYPE_H=1
9271 +  else
9272 +    HAVE_WCTYPE_H=0
9273 +  fi
9274 +  AC_SUBST([HAVE_WCTYPE_H])
9275 +  AC_SUBST([WCTYPE_H])
9276 +
9277 +  if test "$gl_cv_func_iswcntrl_works" = no; then
9278 +    REPLACE_ISWCNTRL=1
9279 +  else
9280 +    REPLACE_ISWCNTRL=0
9281 +  fi
9282 +  AC_SUBST([REPLACE_ISWCNTRL])
9283 +])
9284 diff -urN popt-for-windows/m4/wint_t.m4 popt-for-windows-gnulib/m4/wint_t.m4
9285 --- popt-for-windows/m4/wint_t.m4       1970-01-01 01:00:00.000000000 +0100
9286 +++ popt-for-windows-gnulib/m4/wint_t.m4        2008-10-25 15:17:05.000000000 +0100
9287 @@ -0,0 +1,28 @@
9288 +# wint_t.m4 serial 2 (gettext-0.17)
9289 +dnl Copyright (C) 2003, 2007 Free Software Foundation, Inc.
9290 +dnl This file is free software; the Free Software Foundation
9291 +dnl gives unlimited permission to copy and/or distribute it,
9292 +dnl with or without modifications, as long as this notice is preserved.
9293 +
9294 +dnl From Bruno Haible.
9295 +dnl Test whether <wchar.h> has the 'wint_t' type.
9296 +dnl Prerequisite: AC_PROG_CC
9297 +
9298 +AC_DEFUN([gt_TYPE_WINT_T],
9299 +[
9300 +  AC_CACHE_CHECK([for wint_t], gt_cv_c_wint_t,
9301 +    [AC_TRY_COMPILE([
9302 +/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
9303 +   <wchar.h>.
9304 +   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be included
9305 +   before <wchar.h>.  */
9306 +#include <stddef.h>
9307 +#include <stdio.h>
9308 +#include <time.h>
9309 +#include <wchar.h>
9310 +       wint_t foo = (wchar_t)'\0';], ,
9311 +       gt_cv_c_wint_t=yes, gt_cv_c_wint_t=no)])
9312 +  if test $gt_cv_c_wint_t = yes; then
9313 +    AC_DEFINE(HAVE_WINT_T, 1, [Define if you have the 'wint_t' type.])
9314 +  fi
9315 +])