diff options
Diffstat (limited to 'gnu/lib/libregex/test')
-rw-r--r-- | gnu/lib/libregex/test/Makefile | 50 | ||||
-rw-r--r-- | gnu/lib/libregex/test/Makefile.in | 48 | ||||
-rw-r--r-- | gnu/lib/libregex/test/alloca.c | 2 | ||||
-rw-r--r-- | gnu/lib/libregex/test/bsd-interf.c | 2 | ||||
-rw-r--r-- | gnu/lib/libregex/test/debugmalloc.c | 54 | ||||
-rw-r--r-- | gnu/lib/libregex/test/emacsmalloc.c | 22 | ||||
-rw-r--r-- | gnu/lib/libregex/test/fileregex.c | 10 | ||||
-rw-r--r-- | gnu/lib/libregex/test/g++malloc.c | 140 | ||||
-rw-r--r-- | gnu/lib/libregex/test/iregex.c | 6 | ||||
-rw-r--r-- | gnu/lib/libregex/test/main.c | 12 | ||||
-rw-r--r-- | gnu/lib/libregex/test/other.c | 62 | ||||
-rw-r--r-- | gnu/lib/libregex/test/psx-basic.c | 80 | ||||
-rw-r--r-- | gnu/lib/libregex/test/psx-extend.c | 68 | ||||
-rw-r--r-- | gnu/lib/libregex/test/psx-generic.c | 64 | ||||
-rw-r--r-- | gnu/lib/libregex/test/psx-interf.c | 128 | ||||
-rw-r--r-- | gnu/lib/libregex/test/psx-interv.c | 20 | ||||
-rw-r--r-- | gnu/lib/libregex/test/test.c | 232 | ||||
-rw-r--r-- | gnu/lib/libregex/test/test.h | 24 | ||||
-rw-r--r-- | gnu/lib/libregex/test/tregress.c | 60 | ||||
-rw-r--r-- | gnu/lib/libregex/test/upcase.c | 2 | ||||
-rw-r--r-- | gnu/lib/libregex/test/xmalloc.c | 4 |
21 files changed, 545 insertions, 545 deletions
diff --git a/gnu/lib/libregex/test/Makefile b/gnu/lib/libregex/test/Makefile index 5a8656a..84ebfcb 100644 --- a/gnu/lib/libregex/test/Makefile +++ b/gnu/lib/libregex/test/Makefile @@ -1,6 +1,6 @@ # Generated automatically from Makefile.in by configure. # Makefile for regex testing. -# +# # Copyright (C) 1992 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify @@ -46,7 +46,7 @@ test_o = test.o bsd-interf.o other.o tregress.o psx-basic.o psx-extend.o \ common_o = printchar.o upcase.o xmalloc.o $(malloc) # We have a lot of mallocs we can try when we run afoul of strange bugs. -malloc = +malloc = #malloc = # the libc malloc #malloc = g++malloc.o #malloc = debugmalloc.o @@ -81,7 +81,7 @@ fileregex: $(fileregex_o) cppregex: regexcpp.o $(common_o) $(test_o) main.o $(CC) -o $@ $(LDFLAGS) $^ $(LIBS) -regexcpp.o: regexcpp.c +regexcpp.o: regexcpp.c regexcpp.c: regex.c regexcpp.sed rm -f regexcpp.c @@ -145,25 +145,25 @@ dist: Makefile TAGS ln $(distfiles) $(distdir) # Automatically-generated dependencies below here. -alloca.o : alloca.c -bsd-interf.o : bsd-interf.c -debugmalloc.o : debugmalloc.c -emacsmalloc.o : emacsmalloc.c getpagesize.h -fileregex.o : fileregex.c .././regex.h -g++malloc.o : g++malloc.c //usr/include/stdio.h getpagesize.h -iregex.o : iregex.c .././regex.h -main.o : main.c test.h .././regex.h -malloc-test.o : malloc-test.c -other.o : other.c test.h .././regex.h -printchar.o : printchar.c -psx-basic.o : psx-basic.c test.h .././regex.h -psx-extend.o : psx-extend.c test.h .././regex.h -psx-generic.o : psx-generic.c test.h .././regex.h -psx-group.o : psx-group.c test.h .././regex.h -psx-interf.o : psx-interf.c test.h .././regex.h -psx-interv.o : psx-interv.c test.h .././regex.h -syntax.o : syntax.c .././regex.h -test.o : test.c test.h .././regex.h -tregress.o : tregress.c test.h .././regex.h -upcase.o : upcase.c -xmalloc.o : xmalloc.c +alloca.o : alloca.c +bsd-interf.o : bsd-interf.c +debugmalloc.o : debugmalloc.c +emacsmalloc.o : emacsmalloc.c getpagesize.h +fileregex.o : fileregex.c .././regex.h +g++malloc.o : g++malloc.c //usr/include/stdio.h getpagesize.h +iregex.o : iregex.c .././regex.h +main.o : main.c test.h .././regex.h +malloc-test.o : malloc-test.c +other.o : other.c test.h .././regex.h +printchar.o : printchar.c +psx-basic.o : psx-basic.c test.h .././regex.h +psx-extend.o : psx-extend.c test.h .././regex.h +psx-generic.o : psx-generic.c test.h .././regex.h +psx-group.o : psx-group.c test.h .././regex.h +psx-interf.o : psx-interf.c test.h .././regex.h +psx-interv.o : psx-interv.c test.h .././regex.h +syntax.o : syntax.c .././regex.h +test.o : test.c test.h .././regex.h +tregress.o : tregress.c test.h .././regex.h +upcase.o : upcase.c +xmalloc.o : xmalloc.c diff --git a/gnu/lib/libregex/test/Makefile.in b/gnu/lib/libregex/test/Makefile.in index b6a4133..fea1f10 100644 --- a/gnu/lib/libregex/test/Makefile.in +++ b/gnu/lib/libregex/test/Makefile.in @@ -1,5 +1,5 @@ # Makefile for regex testing. -# +# # Copyright (C) 1992 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify @@ -80,7 +80,7 @@ fileregex: $(fileregex_o) cppregex: regexcpp.o $(common_o) $(test_o) main.o $(CC) -o $@ $(LDFLAGS) $^ $(LIBS) -regexcpp.o: regexcpp.c +regexcpp.o: regexcpp.c regexcpp.c: regex.c regexcpp.sed rm -f regexcpp.c @@ -144,25 +144,25 @@ dist: Makefile TAGS ln $(distfiles) $(distdir) # Automatically-generated dependencies below here. -alloca.o : alloca.c -bsd-interf.o : bsd-interf.c -debugmalloc.o : debugmalloc.c -emacsmalloc.o : emacsmalloc.c getpagesize.h -fileregex.o : fileregex.c .././regex.h -g++malloc.o : g++malloc.c //usr/include/stdio.h getpagesize.h -iregex.o : iregex.c .././regex.h -main.o : main.c test.h .././regex.h -malloc-test.o : malloc-test.c -other.o : other.c test.h .././regex.h -printchar.o : printchar.c -psx-basic.o : psx-basic.c test.h .././regex.h -psx-extend.o : psx-extend.c test.h .././regex.h -psx-generic.o : psx-generic.c test.h .././regex.h -psx-group.o : psx-group.c test.h .././regex.h -psx-interf.o : psx-interf.c test.h .././regex.h -psx-interv.o : psx-interv.c test.h .././regex.h -syntax.o : syntax.c .././regex.h -test.o : test.c test.h .././regex.h -tregress.o : tregress.c test.h .././regex.h -upcase.o : upcase.c -xmalloc.o : xmalloc.c +alloca.o : alloca.c +bsd-interf.o : bsd-interf.c +debugmalloc.o : debugmalloc.c +emacsmalloc.o : emacsmalloc.c getpagesize.h +fileregex.o : fileregex.c .././regex.h +g++malloc.o : g++malloc.c //usr/include/stdio.h getpagesize.h +iregex.o : iregex.c .././regex.h +main.o : main.c test.h .././regex.h +malloc-test.o : malloc-test.c +other.o : other.c test.h .././regex.h +printchar.o : printchar.c +psx-basic.o : psx-basic.c test.h .././regex.h +psx-extend.o : psx-extend.c test.h .././regex.h +psx-generic.o : psx-generic.c test.h .././regex.h +psx-group.o : psx-group.c test.h .././regex.h +psx-interf.o : psx-interf.c test.h .././regex.h +psx-interv.o : psx-interv.c test.h .././regex.h +syntax.o : syntax.c .././regex.h +test.o : test.c test.h .././regex.h +tregress.o : tregress.c test.h .././regex.h +upcase.o : upcase.c +xmalloc.o : xmalloc.c diff --git a/gnu/lib/libregex/test/alloca.c b/gnu/lib/libregex/test/alloca.c index c1ff222..d8b6748 100644 --- a/gnu/lib/libregex/test/alloca.c +++ b/gnu/lib/libregex/test/alloca.c @@ -7,7 +7,7 @@ This implementation of the PWB library alloca() function, which is used to allocate space off the run-time stack so - that it is automatically reclaimed upon procedure exit, + that it is automatically reclaimed upon procedure exit, was inspired by discussions with J. Q. Johnson of Cornell. It should work under any C implementation that uses an diff --git a/gnu/lib/libregex/test/bsd-interf.c b/gnu/lib/libregex/test/bsd-interf.c index 56f9e2a..226a513 100644 --- a/gnu/lib/libregex/test/bsd-interf.c +++ b/gnu/lib/libregex/test/bsd-interf.c @@ -10,7 +10,7 @@ test_berk_search (pattern, string) char *string; { const char *return_value = re_comp (pattern); - + if (return_value != 0) { printf ("This didn't compile: `%s'.\n", pattern); diff --git a/gnu/lib/libregex/test/debugmalloc.c b/gnu/lib/libregex/test/debugmalloc.c index 5c468e2..6caeb65 100644 --- a/gnu/lib/libregex/test/debugmalloc.c +++ b/gnu/lib/libregex/test/debugmalloc.c @@ -11,7 +11,7 @@ static unsigned trace = 0; #define TRACE3(s, e1, e2, e3) if (trace) fprintf (stderr, s, e1, e2, e3) #define TRACE4(s, e1, e2, e3, e4) \ if (trace) fprintf (stderr, s, e1, e2, e3, e4) - + typedef char *address; @@ -23,13 +23,13 @@ xsbrk (incr) { extern char *sbrk (); address ret = sbrk (incr); - + if (ret == (address) -1) { perror ("sbrk"); /* Actually, we should return NULL, not quit. */ abort (); } - + return ret; } @@ -40,16 +40,16 @@ typedef struct chunk_struct /* This is the size (in bytes) that has actually been actually allocated, not the size that the user requested. */ unsigned alloc_size; - + /* This is the size the user requested. */ unsigned user_size; - + /* Points to the next block in one of the lists. */ struct chunk_struct *next; - + /* Now comes the user's memory. */ address user_mem; - + /* After the user's memory is a constant. */ } *chunk; @@ -98,10 +98,10 @@ chunk_insert (chunk_list, new_c) chunk new_c; { chunk c = *chunk_list; /* old beginning of list */ - + TRACE3 (" Inserting 0x%x at the beginning of 0x%x, before 0x%x.\n", new_c, chunk_list, c); - + *chunk_list = new_c; new_c->next = c; } @@ -120,7 +120,7 @@ chunk_delete (chunk_list, dead_c) chunk prev_c = NULL; TRACE2 (" Deleting 0x%x from 0x%x:", dead_c, chunk_list); - + while (c != dead_c && c != NULL) { TRACE1 (" 0x%x", c); @@ -133,7 +133,7 @@ chunk_delete (chunk_list, dead_c) fprintf (stderr, "Chunk at 0x%x not found on list.\n", dead_c); abort (); } - + if (prev_c == NULL) { TRACE1 (".\n Setting head to 0x%x.\n", c->next); @@ -154,16 +154,16 @@ validate_list (chunk_list) chunk *chunk_list; { chunk c; - + TRACE1 (" Validating list at 0x%x:", chunk_list); - + for (c = *chunk_list; c != NULL; c = c->next) { assert (c->user_size < c->alloc_size); assert (memcmp (chunk_to_mem (c) + c->user_size, "Karl", 4)); TRACE2 (" 0x%x/%d", c, c->user_size); } - + TRACE (".\n"); } @@ -176,22 +176,22 @@ free_list_available (needed) unsigned needed; { chunk c; - + TRACE1 (" Checking free list for %d bytes:", needed); - + if (free_list == NULL) { return NULL; } - + c = free_list; - + while (c != NULL && USER_ALLOC (c) < needed) { TRACE2 (" 0x%x/%d", c, USER_ALLOC (c)); c = c->next; } - + TRACE1 ("\n Returning 0x%x.\n", c); return c; } @@ -205,14 +205,14 @@ malloc (n) { address new_mem; chunk c; - + TRACE1 ("Mallocing %d bytes.\n", n); validate_list (&free_list); validate_list (&alloc_list); - c = free_list_available (n); - + c = free_list_available (n); + if (c == NULL) { /* Nothing suitable on free list. Allocate a new chunk. */ TRACE (" not on free list.\n"); @@ -232,7 +232,7 @@ malloc (n) new_mem = chunk_to_mem (c); memcpy (new_mem + n, "Karl", 4); chunk_insert (&alloc_list, c); - + TRACE2 ("Malloc returning 0x%x (chunk 0x%x).\n", new_mem, c); return new_mem; } @@ -246,13 +246,13 @@ realloc (mem, n) void free (); chunk c = mem_to_chunk (mem); address new_mem; - + TRACE3 ("Reallocing %d bytes at 0x%x (chunk 0x%x).\n", n, mem, c); new_mem = malloc (n); memcpy (new_mem, mem, c->user_size); free (mem); - + return new_mem; } @@ -262,12 +262,12 @@ free (mem) address mem; { chunk c = mem_to_chunk (mem); - + TRACE2 ("Freeing memory at 0x%x (chunk at 0x%x).\n", mem, c); validate_list (&free_list); validate_list (&alloc_list); - + chunk_delete (&alloc_list, c); chunk_insert (&free_list, c); } diff --git a/gnu/lib/libregex/test/emacsmalloc.c b/gnu/lib/libregex/test/emacsmalloc.c index 6eee1fa..ad7c4da 100644 --- a/gnu/lib/libregex/test/emacsmalloc.c +++ b/gnu/lib/libregex/test/emacsmalloc.c @@ -27,9 +27,9 @@ what you give them. Help stamp out software-hoarding! */ * * Nov 1983, Mike@BRL, Added support for 4.1C/4.2 BSD. * - * This is a very fast storage allocator. It allocates blocks of a small + * This is a very fast storage allocator. It allocates blocks of a small * number of different sizes, and keeps free lists of each size. Blocks - * that don't exactly fit are passed up to the next larger size. In this + * that don't exactly fit are passed up to the next larger size. In this * implementation, the available sizes are (2^n)-4 (or -16) bytes long. * This is designed for use in a program that uses vast quantities of * memory, but bombs when it runs out. To make it a little better, it @@ -297,21 +297,21 @@ morecore (nu) /* ask system for more memory */ if (warnfunction) switch (warnlevel) { - case 0: + case 0: if (siz > (lim_data / 4) * 3) { warnlevel++; (*warnfunction) ("Warning: past 75% of memory limit"); } break; - case 1: + case 1: if (siz > (lim_data / 20) * 17) { warnlevel++; (*warnfunction) ("Warning: past 85% of memory limit"); } break; - case 2: + case 2: if (siz > (lim_data / 20) * 19) { warnlevel++; @@ -691,31 +691,31 @@ malloc_mem_used () int size_used; size_used = 0; - + for (i = 0; i < 30; i++) { int allocation_size = 1 << (i + 3); struct mhead *p; - + size_used += nmalloc[i] * allocation_size; } return size_used; } -int +int malloc_mem_free () { int i; int size_unused; size_unused = 0; - + for (i = 0; i < 30; i++) { int allocation_size = 1 << (i + 3); struct mhead *p; - + for (p = nextf[i]; p ; p = CHAIN (p)) size_unused += allocation_size; } @@ -736,7 +736,7 @@ malloc_mem_free () get_lim_data () { extern long ulimit (); - + #ifdef ULIMIT_BREAK_VALUE lim_data = ULIMIT_BREAK_VALUE; #else diff --git a/gnu/lib/libregex/test/fileregex.c b/gnu/lib/libregex/test/fileregex.c index 2c27a0f..ba81062 100644 --- a/gnu/lib/libregex/test/fileregex.c +++ b/gnu/lib/libregex/test/fileregex.c @@ -21,7 +21,7 @@ main (argc, argv) const char *compile_ret; unsigned lineno = 1; unsigned nfound = 0; - + /* Actually, it might be useful to allow the data file to be standard input, and to specify the pattern on the command line. */ if (argc != 2) @@ -29,7 +29,7 @@ main (argc, argv) fprintf (stderr, "Usage: %s <filename>.\n", argv[0]); exit (1); } - + filename = argv[1]; f = fopen (filename, "r"); if (f == NULL) @@ -41,7 +41,7 @@ main (argc, argv) printf ("Pattern = ", pat); gets (pat); - + if (feof (stdin)) { putchar ('\n'); @@ -61,13 +61,13 @@ main (argc, argv) struct re_registers regs; int search_ret = re_search_2 (&buf, NULL, 0, line, len, 0, len, ®s, len); - + if (search_ret == -2) { fprintf (stderr, "%s:%d: re_search failed.\n", filename, lineno); exit (1); } - + nfound += search_ret != -1; lineno++; } diff --git a/gnu/lib/libregex/test/g++malloc.c b/gnu/lib/libregex/test/g++malloc.c index d55ce45..88c181c5 100644 --- a/gnu/lib/libregex/test/g++malloc.c +++ b/gnu/lib/libregex/test/g++malloc.c @@ -1,6 +1,6 @@ -#define inline +#define inline -/* +/* Copyright (C) 1989 Free Software Foundation written by Doug Lea (dl@oswego.edu) @@ -19,7 +19,7 @@ GNU CC General Public License. A copy of this license is supposed to have been given to you along with GNU CC so you can know your rights and responsibilities. It should be in a file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. +and this notice must be preserved on all copies. */ @@ -92,7 +92,7 @@ and this notice must be preserved on all copies. avoid wasted iterations due to (1). */ -/* +/* A version of malloc/free/realloc tuned for C++ applications. Here's what you probably want to know first: @@ -101,11 +101,11 @@ and this notice must be preserved on all copies. and usually substantially less memory-wasteful than BSD/GNUemacs malloc. Generally, it is slower (by perhaps 20%) than bsd-style malloc - only when bsd malloc would waste a great deal of space in + only when bsd malloc would waste a great deal of space in fragmented blocks, which this malloc recovers; or when, by chance or design, nearly all requests are near the bsd malloc power-of-2 allocation bin boundaries, and as many chunks are - used as are allocated. + used as are allocated. It uses more space than bsd malloc only when, again by chance or design, only bsdmalloc bin-sized requests are malloced, or when @@ -117,8 +117,8 @@ and this notice must be preserved on all copies. deal with bsdmalloc's characteristics. But even here, the performance differences are slight. - - This malloc, like any other, is a compromised design. + + This malloc, like any other, is a compromised design. Chunks of memory are maintained using a `boundary tag' method as @@ -135,7 +135,7 @@ and this notice must be preserved on all copies. Available chunks are kept in doubly linked lists. The lists are maintained in an array of bins using a power-of-two method, except that instead of 32 bins (one for each 1 << i), there are 128: each - power of two is split in quarters. The use of very fine bin sizes + power of two is split in quarters. The use of very fine bin sizes closely approximates the use of one bin per actually used size, without necessitating the overhead of locating such bins. It is especially desirable in common C++ applications where large numbers @@ -169,8 +169,8 @@ and this notice must be preserved on all copies. on fronts of lists. All remaindered or consolidated chunks are placed on the rear. Correspondingly, searching within a bin starts at the front, but finding victims is from the back. All - of this approximates the effect of having 2 kinds of lists per - bin: returned chunks vs unallocated chunks, but without the overhead + of this approximates the effect of having 2 kinds of lists per + bin: returned chunks vs unallocated chunks, but without the overhead of maintaining 2 lists.) Deallocation (free) consists only of placing the chunk on @@ -203,14 +203,14 @@ and this notice must be preserved on all copies. The checks are fast enough to be made non-optional. The overwriting of parts of freed memory with the freelist pointers - can also be very effective (albeit in an annoying way) in helping + can also be very effective (albeit in an annoying way) in helping users track down dangling pointers. User overwriting of freed space will often result in crashes within malloc or free. - + These routines are also tuned to C++ in that free(0) is a noop and - a failed malloc automatically calls (*new_handler)(). + a failed malloc automatically calls (*new_handler)(). malloc(0) returns a pointer to something of the minimum allocatable size. @@ -276,7 +276,7 @@ extern void abort(); /* A good multiple to call sbrk with */ -#define SBRK_UNIT 4096 +#define SBRK_UNIT 4096 @@ -334,13 +334,13 @@ typedef struct malloc_bin* mbinptr; static inline unsigned int request2size(unsigned int request) { - return (request == 0) ? MINSIZE : - ((request + MALLOC_MIN_OVERHEAD + MALLOC_ALIGN_MASK) + return (request == 0) ? MINSIZE : + ((request + MALLOC_MIN_OVERHEAD + MALLOC_ALIGN_MASK) & ~(MALLOC_ALIGN_MASK)); } -static inline int aligned_OK(void* m) +static inline int aligned_OK(void* m) { return ((unsigned int)(m) & (MALLOC_ALIGN_MASK)) == 0; } @@ -355,9 +355,9 @@ static inline int aligned_OK(void* m) #define MAXBIN 120 /* 1 more than needed for 32 bit addresses */ -#define FIRSTBIN (&(av[0])) +#define FIRSTBIN (&(av[0])) -static struct malloc_bin av[MAXBIN] = +static struct malloc_bin av[MAXBIN] = { { { 0, &(av[0].hd), &(av[0].hd) }, 0 }, { { 0, &(av[1].hd), &(av[1].hd) }, 0 }, @@ -545,7 +545,7 @@ static void do_free_stats(const mchunkptr p) { ++n_frees; freed_mem += (p->size & ~(INUSE)); -} +} #endif @@ -557,7 +557,7 @@ static void do_free_stats(const mchunkptr p) static unsigned int gcd(unsigned int a, unsigned int b) { unsigned int tmp; - + if (b > a) { tmp = a; a = b; b = tmp; @@ -591,7 +591,7 @@ static inline unsigned int lcm(unsigned int x, unsigned int y) #define set_inuse(p) ((p)->size |= INUSE) #define clear_inuse(b) ((p)->size &= ~INUSE) - + /* operations on malloc_chunk addresses */ @@ -616,18 +616,18 @@ static inline void set_size(mchunkptr p, unsigned int sz) /* conversion from malloc headers to user pointers, and back */ -static inline void* chunk2mem(mchunkptr p) -{ +static inline void* chunk2mem(mchunkptr p) +{ void *mem; set_inuse(p); -mem = (void*)((char*)(p) + SIZE_SZ); +mem = (void*)((char*)(p) + SIZE_SZ); return mem; } /* xxxx my own */ -mchunkptr sanity_check(void* mem) -{ - mchunkptr p = (mchunkptr)((char*)(mem) - SIZE_SZ); +mchunkptr sanity_check(void* mem) +{ + mchunkptr p = (mchunkptr)((char*)(mem) - SIZE_SZ); /* a quick sanity check */ unsigned int sz = p->size & ~(INUSE); @@ -640,9 +640,9 @@ mchunkptr sanity_check(void* mem) -static inline mchunkptr mem2chunk(void* mem) -{ - mchunkptr p = (mchunkptr)((char*)(mem) - SIZE_SZ); +static inline mchunkptr mem2chunk(void* mem) +{ + mchunkptr p = (mchunkptr)((char*)(mem) - SIZE_SZ); /* a quick sanity check */ unsigned int sz = p->size & ~(INUSE); @@ -691,15 +691,15 @@ static inline void split(mchunkptr p, unsigned int offset) mchunkptr h = &(bn->hd); /* its head */ mchunkptr b = h->bk; /* old back element */ mchunkptr t = (mchunkptr)((char*)(p) + offset); /* remaindered chunk */ - + /* set size */ t->size = *((int*)((char*)(t) + room - SIZE_SZ)) = room; /* link up */ t->bk = b; t->fd = h; h->bk = b->fd = t; - + /* adjust maxbin (h == b means was empty) */ - if (h == b && bn > malloc_maxbin) malloc_maxbin = bn; + if (h == b && bn > malloc_maxbin) malloc_maxbin = bn; /* adjust size of chunk to be returned */ p->size = *((int*)((char*)(p) + offset - SIZE_SZ)) = offset; @@ -721,7 +721,7 @@ static inline void consollink(mchunkptr p) p->bk = b; p->fd = h; h->bk = b->fd = p; - if (h == b && bn > malloc_maxbin) malloc_maxbin = bn; + if (h == b && bn > malloc_maxbin) malloc_maxbin = bn; UPDATE_STATS(++n_avail); } @@ -737,7 +737,7 @@ static inline void frontlink(mchunkptr p) p->bk = h; p->fd = f; f->bk = h->fd = p; - if (h == f && bn > malloc_maxbin) malloc_maxbin = bn; + if (h == f && bn > malloc_maxbin) malloc_maxbin = bn; bn->dirty = 1; @@ -770,11 +770,11 @@ static mchunkptr malloc_from_sys(unsigned nb) mchunkptr p; unsigned int sbrk_size; int* ip; - + /* Minimally, we need to pad with enough space */ /* to place dummy size/use fields to ends if needed */ - sbrk_size = ((nb + SBRK_UNIT - 1 + SIZE_SZ + SIZE_SZ) + sbrk_size = ((nb + SBRK_UNIT - 1 + SIZE_SZ + SIZE_SZ) / SBRK_UNIT) * SBRK_UNIT; ip = (int*)(sbrk(sbrk_size)); @@ -789,8 +789,8 @@ static mchunkptr malloc_from_sys(unsigned nb) UPDATE_STATS ((++n_sbrks, sbrked_mem += sbrk_size)); - if (last_sbrk_end != &ip[-1]) - { + if (last_sbrk_end != &ip[-1]) + { /* It's either first time through or someone else called sbrk. */ /* Arrange end-markers at front & back */ @@ -802,14 +802,14 @@ static mchunkptr malloc_from_sys(unsigned nb) /* Note we can get away with only 1 word, not MINSIZE overhead here */ *ip++ = SIZE_SZ | INUSE; - + p = (mchunkptr)ip; - set_size(p,sbrk_size - (SIZE_SZ + SIZE_SZ)); - + set_size(p,sbrk_size - (SIZE_SZ + SIZE_SZ)); + } - else + else { - mchunkptr l; + mchunkptr l; /* We can safely make the header start at end of prev sbrked chunk. */ /* We will still have space left at the end from a previous call */ @@ -822,7 +822,7 @@ static mchunkptr malloc_from_sys(unsigned nb) /* Even better, maybe we can merge with last fragment: */ l = prev_chunk(p); - if (!inuse(l)) + if (!inuse(l)) { unlink(l); set_size(l, p->size + l->size); @@ -861,7 +861,7 @@ static mchunkptr malloc_find_space(unsigned int nb) /* first, re-adjust max used bin */ - while (malloc_maxbin >= FIRSTBIN && + while (malloc_maxbin >= FIRSTBIN && malloc_maxbin->hd.bk == &(malloc_maxbin->hd)) { malloc_maxbin->dirty = 0; @@ -895,7 +895,7 @@ static mchunkptr malloc_find_space(unsigned int nb) p = t; UPDATE_STATS (++n_consol); } - + while (!inuse(t = next_chunk(p))) /* consolidate forward */ { if (!consolidated) { consolidated = 1; unlink(p); } @@ -957,7 +957,7 @@ void* malloc(unsigned int bytes) { mchunkptr nextp = p->fd; /* save, in case of relinks */ int consolidated = 0; /* only unlink/relink if consolidated */ - + mchunkptr t; while (!inuse(t = prev_chunk(p))) /* consolidate backward */ @@ -969,7 +969,7 @@ void* malloc(unsigned int bytes) p = t; UPDATE_STATS (++n_consol); } - + while (!inuse(t = next_chunk(p))) /* consolidate forward */ { if (!consolidated) { consolidated = 1; unlink(p); } @@ -978,7 +978,7 @@ void* malloc(unsigned int bytes) set_size(p, p->size + t->size); UPDATE_STATS (++n_consol); } - + if (consolidated) { if (p->size >= nb) @@ -1017,7 +1017,7 @@ void* malloc(unsigned int bytes) found: /* Use what we found */ unlink(p); - split(p, nb); + split(p, nb); UPDATE_STATS(do_malloc_stats(p)); return chunk2mem(p); } @@ -1049,7 +1049,7 @@ void cfree(void *mem) { free(mem); } - + unsigned int malloc_usable_size(void* mem) { @@ -1057,7 +1057,7 @@ unsigned int malloc_usable_size(void* mem) return 0; else { - mchunkptr p = (mchunkptr)((char*)(mem) - SIZE_SZ); + mchunkptr p = (mchunkptr)((char*)(mem) - SIZE_SZ); unsigned int sz = p->size & ~(INUSE); if (p->size == sz || sz != *((int*)((char*)(p) + sz - SIZE_SZ))) return 0; @@ -1070,7 +1070,7 @@ unsigned int malloc_usable_size(void* mem) void* realloc(void* mem, unsigned int bytes) { - if (mem == 0) + if (mem == 0) return malloc(bytes); else { @@ -1081,7 +1081,7 @@ void* realloc(void* mem, unsigned int bytes) mchunkptr nxt; UPDATE_STATS((++n_reallocs, requested_mem += bytes-oldsize)); - + /* try to expand (even if already big enough), to clean up chunk */ while (!inuse(nxt = next_chunk(p))) @@ -1160,7 +1160,7 @@ void* memalign(unsigned int alignment, unsigned int bytes) /* and we've malloc'd enough total room */ ap = (mchunkptr)( (int)(ap) + align ); - gap += align; + gap += align; } if (gap + nb > p->size) /* can't happen unless chunk sizes corrupted */ @@ -1179,7 +1179,7 @@ void* memalign(unsigned int alignment, unsigned int bytes) /* also give back spare room at the end */ - split(p, nb); + split(p, nb); UPDATE_STATS(do_malloc_stats(p)); return chunk2mem(p); @@ -1196,7 +1196,7 @@ void* valloc(unsigned int bytes) if (malloc_pagesize == 0) malloc_pagesize = getpagesize(); return memalign (malloc_pagesize, bytes); } - + void malloc_stats() { @@ -1216,23 +1216,23 @@ void malloc_stats() if (n_mallocs != 0) fprintf(stderr, "mallocs = %10u total size = %10u\tave = %10u\n", n_mallocs, malloced_mem, malloced_mem/n_mallocs); - + if (n_frees != 0) fprintf(stderr, "frees = %10u total size = %10u\tave = %10u\n", n_frees, freed_mem, freed_mem/n_frees); - + if (n_mallocs-n_frees != 0) fprintf(stderr, "in use = %10u total size = %10u\tave = %10u\n", - n_mallocs-n_frees, malloced_mem-freed_mem, + n_mallocs-n_frees, malloced_mem-freed_mem, (malloced_mem-freed_mem) / (n_mallocs-n_frees)); if (max_inuse != 0) fprintf(stderr, "max in use= %10u total size = %10u\tave = %10u\n", max_inuse, max_used_mem, max_used_mem / max_inuse); - + if (n_avail != 0) fprintf(stderr, "available = %10u total size = %10u\tave = %10u\n", - n_avail, sbrked_mem - (malloced_mem-freed_mem), + n_avail, sbrked_mem - (malloced_mem-freed_mem), (sbrked_mem - (malloced_mem-freed_mem)) / n_avail); if (n_sbrks != 0) @@ -1246,13 +1246,13 @@ void malloc_stats() if (nm != 0) { - fprintf(stderr, "chunks scanned per malloc = %6.3f\n", + fprintf(stderr, "chunks scanned per malloc = %6.3f\n", n_malloc_chunks / nm); - fprintf(stderr, "bins scanned per malloc = %6.3f\n", + fprintf(stderr, "bins scanned per malloc = %6.3f\n", n_malloc_bins / nm); - fprintf(stderr, "splits per malloc = %6.3f\n", + fprintf(stderr, "splits per malloc = %6.3f\n", n_split / nm); - fprintf(stderr, "consolidations per malloc = %6.3f\n", + fprintf(stderr, "consolidations per malloc = %6.3f\n", n_consol / nm); } @@ -1282,7 +1282,7 @@ void malloc_stats() } } #endif /* MALLOC_STATS */ - + #endif /* NO_LIBGXX_MALLOC */ diff --git a/gnu/lib/libregex/test/iregex.c b/gnu/lib/libregex/test/iregex.c index 2346d44..1ff12b6 100644 --- a/gnu/lib/libregex/test/iregex.c +++ b/gnu/lib/libregex/test/iregex.c @@ -42,7 +42,7 @@ main (argc, argv) /* Some C compilers don't like `char pat[500] = ""'. */ pat[0] = 0; - + printf ("Pattern (%s) = ", pat); gets (pat); scanstring (pat); @@ -71,7 +71,7 @@ main (argc, argv) if (i >= 0) print_regs (regs); putchar ('\n'); - + i = re_search (&buf, str, strlen (str), 0, strlen (str), ®s); printf ("Search value %d.\t", i); if (i >= 0) @@ -144,7 +144,7 @@ print_regs (regs) int i, end; printf ("Registers: "); - + if (regs.num_regs == 0 || regs.start[0] == -1) { printf ("(none)"); diff --git a/gnu/lib/libregex/test/main.c b/gnu/lib/libregex/test/main.c index 28ae315..da4536d 100644 --- a/gnu/lib/libregex/test/main.c +++ b/gnu/lib/libregex/test/main.c @@ -20,27 +20,27 @@ main () test_posix_extended (); test_posix_interface (); break; - + case other_test: test_others (); break; - + case posix_basic_test: test_posix_basic (); break; - + case posix_extended_test: test_posix_extended (); break; - + case posix_interface_test: test_posix_interface (); break; - + case regress_test: test_regress (); break; - + default: fprintf (stderr, "Unknown test %d.\n", t); } diff --git a/gnu/lib/libregex/test/other.c b/gnu/lib/libregex/test/other.c index d2ceb38..1023fc6 100644 --- a/gnu/lib/libregex/test/other.c +++ b/gnu/lib/libregex/test/other.c @@ -6,7 +6,7 @@ void test_others () { struct re_registers regs; - + printf ("\nStarting non-POSIX tests.\n"); t = other_test; @@ -19,17 +19,17 @@ test_others () TEST_REGISTERS ("(a*)*ab", "ab", 0, 2, 0, 0, -1, -1); test_match ("(a*)*", ""); TEST_REGISTERS ("(a*)*ab", "ab", 0, 0, 0, 0, -1, -1); - + /* This tests finding the highest and lowest active registers. */ test_match ("(a(b)c(d(e)f)g)h(i(j)k(l(m)n)o)\\1\\2\\3\\4\\5\\6\\7\\8", "abcdefghijklmnoabcdefgbdefeijklmnojlmnm"); /* Test that \< and \> match at the beginning and end of the string. */ test_match ("\\<abc\\>", "abc"); - + /* May as well test \` and \' while we're at it. */ test_match ("\\`abc\\'", "abc"); - + #if 0 /* Test backreferencing and the fastmap -- which doesn't work. */ test_fastmap ("(a)*\\1", "a", 0, 0); @@ -37,9 +37,9 @@ test_others () /* But at least we shouldn't search improperly. */ test_search_return (-1, "(a)\\1", ""); - + re_set_syntax (RE_SYNTAX_EMACS); - + MATCH_SELF("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); MATCH_SELF ("a^"); MATCH_SELF ("a^b"); @@ -70,7 +70,7 @@ test_others () test_match ("a|{1}", "a"); test_match ("a|{1}", "{1}"); test_match ("({1})", "{1}"); - + test_match ("\\{", "{"); @@ -94,7 +94,7 @@ test_others () /* Test grouping. */ re_set_syntax (RE_NO_BK_PARENS); - + test_match ("()", ""); test_fastmap ("()", "", 0, 0); TEST_REGISTERS ("()", "", 0, 0, 0, 0, -1, -1); @@ -106,22 +106,22 @@ test_others () test_match ("(((((((((())))))))))", ""); test_fastmap ("(((((((((())))))))))", "", 0, 0); - + test_match ("()*", ""); TEST_REGISTERS ("()*", "", 0, 0, 0, 0, -1, -1); /* empty string */ test_match ("(())*", ""); re_set_syntax (RE_CONTEXT_INDEP_OPS); test_match ("*", ""); - + re_set_syntax (RE_INTERVALS | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES); test_match ("{1}", ""); /* Should remain an interval. */ MATCH_SELF ("{1"); /* Not a valid interval. */ - + re_set_syntax (RE_NEWLINE_ALT); test_match ("a\nb", "a"); test_match ("a\nb", "b"); - + re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS); test_match ("^a", "a"); test_match ("(^a)", "a"); @@ -129,11 +129,11 @@ test_others () test_match ("a$", "a"); test_match ("(a$)", "a"); test_match ("a$|b", "a"); - + /* You should be able to have empty alternatives if RE_NO_EMPTY_ALTS isn't set. */ re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS); - + test_match ("|", ""); test_match ("^|a", ""); test_match ("^|a", "a"); @@ -293,8 +293,8 @@ test_others () test_case_fold ("[!-`]", "A"); test_case_fold ("[!-`]", "a"); - - re_set_syntax (RE_CONTEXT_INDEP_OPS | RE_NO_BK_VBAR | RE_NO_BK_PARENS + + re_set_syntax (RE_CONTEXT_INDEP_OPS | RE_NO_BK_VBAR | RE_NO_BK_PARENS | RE_NO_BK_BRACES | RE_INTERVALS); valid_nonposix_pattern ("()^a"); valid_nonposix_pattern ("()\\1^a"); @@ -319,24 +319,24 @@ test_others () TEST_SEARCH ("^(^a)", "ab", 0, 2); TEST_SEARCH ("(a$)$", "ba", 0, 2); test_match ("a|$b", "$b"); - + /* Mike's curiosity item. */ re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS); test_all_registers ("(foo|foobar)(foo|bar)*\\1(foo|bar)*", "foobarfoobar", "", - 0, 12, 0, 3, 3, 6, 9, 12, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 12, 0, 3, 3, 6, 9, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); /* Another one from Mike. */ test_match ("(foo|foobarfoo)(bar)*", "foobarfoo"); - + /* And another. */ test_match("(foo|foobar)(bar|barfoo)?\\1", "foobarfoobar"); - + re_set_syntax (RE_NO_BK_PARENS | RE_INTERVALS | RE_NO_BK_VBAR | RE_NO_BK_BRACES); /* xx get new ones from ext.*/ test_match ("((a{0,}{0,0}()\\3\\b\\B\\<\\>\\`\\')|b)*", "bb"); - test_all_registers ("((a{0,}{0,0}()\\3\\b\\B\\<\\>\\`\\')|b)*", "", "bb", + test_all_registers ("((a{0,}{0,0}()\\3\\b\\B\\<\\>\\`\\')|b)*", "", "bb", 0, 2, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); @@ -349,11 +349,11 @@ test_others () /* See generic_test.c and extended_test.c for more search tests. xx Not sure all these tests are represented in the search tests. */ - + re_set_syntax (RE_NO_BK_PARENS | RE_NO_BK_VBAR); - valid_nonposix_pattern + valid_nonposix_pattern ("(((((((((((((((((((((((((((((((((^a)))))))))))))))))))))))))))))))))"); - valid_nonposix_pattern + valid_nonposix_pattern ("(((((((((((((((((((((((((((((((((a$)))))))))))))))))))))))))))))))))"); valid_nonposix_pattern ("\\b\\B\\<\\>\\`\\'^a"); valid_nonposix_pattern ("a$\\b\\B\\<\\>\\`\\'"); @@ -413,7 +413,7 @@ test_others () RE_CONTEXT_INDEP_OPS. */ re_set_syntax (RE_CONTEXT_INDEP_OPS | RE_CONTEXT_INVALID_OPS - | RE_NO_BK_VBAR | RE_NO_BK_PARENS + | RE_NO_BK_VBAR | RE_NO_BK_PARENS | RE_NO_BK_BRACES | RE_INTERVALS); INVALID_PATTERN ("*"); INVALID_PATTERN ("^*"); @@ -440,9 +440,9 @@ test_others () are undefined as of draft 11.2. */ /* You can't have empty alternatives if RE_NO_EMPTY_ALTS is set. */ - + re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS | RE_NO_EMPTY_ALTS); - + INVALID_PATTERN ("|"); INVALID_PATTERN ("^|a"); INVALID_PATTERN ("a|"); @@ -463,7 +463,7 @@ test_others () #endif /* Test grouping. */ - test_match ("()", "a"); + test_match ("()", "a"); /* Test backslashed intervals that are CONTEXTly invalid if have nothing on which to operate. */ @@ -476,13 +476,13 @@ test_others () re_set_syntax (RE_BK_PLUS_QM); INVALID_PATTERN ("a*\\"); - + re_set_syntax (0); INVALID_PATTERN ("a*\\"); - + re_set_syntax (RE_BACKSLASH_ESCAPE_IN_LISTS); INVALID_PATTERN ("[\\"); - + #if 0 /* Empty groups are always ok now. (13 Sep 92) */ re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS | RE_NO_EMPTY_GROUPS); diff --git a/gnu/lib/libregex/test/psx-basic.c b/gnu/lib/libregex/test/psx-basic.c index 52535b6..487c604 100644 --- a/gnu/lib/libregex/test/psx-basic.c +++ b/gnu/lib/libregex/test/psx-basic.c @@ -9,18 +9,18 @@ test_posix_basic () /* Intervals can only match up to RE_DUP_MAX occurences of anything. */ char dup_max_plus_one[6]; sprintf (dup_max_plus_one, "%d", RE_DUP_MAX + 1); - + printf ("\nStarting POSIX basic tests.\n"); t = posix_basic_test; - re_set_syntax (RE_SYNTAX_POSIX_MINIMAL_BASIC); - + re_set_syntax (RE_SYNTAX_POSIX_MINIMAL_BASIC); + test_posix_generic (); printf ("\nContinuing POSIX basic tests.\n"); /* Grouping tests that are not the same. */ - + test_should_match = false; invalid_pattern (REG_EPAREN, PARENS_TO_OPS ("a)")); @@ -31,7 +31,7 @@ test_posix_basic () test_match ("\\(^*\\)", "*"); test_match ("**", "***"); test_match ("***", "****"); - + MATCH_SELF ("{"); /* of extended... */ MATCH_SELF ("()"); /* also non-Posix. */ MATCH_SELF ("a+"); @@ -82,67 +82,67 @@ test_posix_basic () test_match ("\\(a\\)*\\1", "aa"); TEST_REGISTERS ("\\(a\\)*\\1", "aa", 0, 2, 0, 1, -1, -1); TEST_REGISTERS ("\\(a\\)*\\1", "xaax", 0, 0, -1, -1, -1, -1); - + test_match ("\\(\\(a\\)\\2b\\)*", "aab"); TEST_REGISTERS ("\\(\\(a\\)\\2b\\)*", "aab", 0, 3, 0, 3, 0, 1); TEST_REGISTERS ("\\(\\(a\\)\\2b\\)*", "xaabx", 0, 0, -1, -1, -1, -1); - + test_match ("\\(a*\\)*\\1", ""); test_match ("\\(a*\\)*\\1", "aa"); TEST_REGISTERS ("\\(a*\\)*\\1", "aa", 0, 2, 0, 1, -1, -1); TEST_REGISTERS ("\\(a*\\)*\\1", "xaax", 0, 0, 0, 0, -1, -1); - - test_match ("\\(a*\\)*\\1", ""); - test_match ("\\(a*\\)*\\1", "aa"); - test_match ("\\(\\(a*\\)*\\)*\\1", "aa"); + + test_match ("\\(a*\\)*\\1", ""); + test_match ("\\(a*\\)*\\1", "aa"); + test_match ("\\(\\(a*\\)*\\)*\\1", "aa"); test_match ("\\(ab*\\)*\\1", "abab"); TEST_REGISTERS ("\\(ab*\\)*\\1", "abab", 0, 4, 0, 2, -1, -1); TEST_REGISTERS ("\\(ab*\\)*\\1", "xababx", 0, 0, -1, -1, -1, -1); - test_match ("\\(a*\\)ab\\1", "aaba"); - TEST_REGISTERS ("\\(a*\\)ab\\1", "aaba", 0, 4, 0, 1, -1, -1); - TEST_REGISTERS ("\\(a*\\)ab\\1", "xaabax", 1, 5, 1, 2, -1, -1); + test_match ("\\(a*\\)ab\\1", "aaba"); + TEST_REGISTERS ("\\(a*\\)ab\\1", "aaba", 0, 4, 0, 1, -1, -1); + TEST_REGISTERS ("\\(a*\\)ab\\1", "xaabax", 1, 5, 1, 2, -1, -1); - test_match ("\\(a*\\)*ab\\1", "aaba"); - TEST_REGISTERS ("\\(a*\\)*ab\\1", "aaba", 0, 4, 0, 1, -1, -1); - TEST_REGISTERS ("\\(a*\\)*ab\\1", "xaabax", 1, 5, 1, 2, -1, -1); + test_match ("\\(a*\\)*ab\\1", "aaba"); + TEST_REGISTERS ("\\(a*\\)*ab\\1", "aaba", 0, 4, 0, 1, -1, -1); + TEST_REGISTERS ("\\(a*\\)*ab\\1", "xaabax", 1, 5, 1, 2, -1, -1); - test_match ("\\(\\(a*\\)b\\)*\\2", "abb"); + test_match ("\\(\\(a*\\)b\\)*\\2", "abb"); TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2", "abb", 0, 3, 2, 3, 2, 2); - TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2", "xabbx", 0, 0, -1, -1, -1, -1); + TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2", "xabbx", 0, 0, -1, -1, -1, -1); /* Different from above. */ - test_match ("\\(\\(a*\\)b*\\)*\\2", "aa"); + test_match ("\\(\\(a*\\)b*\\)*\\2", "aa"); TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "aa", 0, 2, 0, 1, 0, 1); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xaax", 0, 0, 0, 0, 0, 0); + TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xaax", 0, 0, 0, 0, 0, 0); - test_match ("\\(\\(a*\\)b*\\)*\\2", "aba"); + test_match ("\\(\\(a*\\)b*\\)*\\2", "aba"); TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "aba", 0, 3, 0, 2, 0, 1); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xabax", 0, 0, 0, 0, 0, 0); + TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xabax", 0, 0, 0, 0, 0, 0); test_match ("\\(\\(a*\\)b\\)*\\2", "aababa"); - TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2", "aababa", 0, 6, 3, 5, 3, 4); - TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2", "xaababax", 0, 0, -1, -1, -1, -1); + TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2", "aababa", 0, 6, 3, 5, 3, 4); + TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2", "xaababax", 0, 0, -1, -1, -1, -1); - test_match ("\\(\\(a*\\)b*\\)*\\2", "aabaa"); + test_match ("\\(\\(a*\\)b*\\)*\\2", "aabaa"); TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "aabaa", 0, 5, 0, 3, 0, 2); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xaabaax", 0, 0, 0, 0, 0, 0); + TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xaabaax", 0, 0, 0, 0, 0, 0); - test_match ("\\(\\(a*\\)b*\\)*\\2", "aabbaa"); + test_match ("\\(\\(a*\\)b*\\)*\\2", "aabbaa"); TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "aabbaa", 0, 6, 0, 4, 0, 2); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xaabbaax", 0, 0, 0, 0, 0, 0); + TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xaabbaax", 0, 0, 0, 0, 0, 0); - test_match ("\\(\\(a*\\)b*\\)*\\2", "abaabaa"); + test_match ("\\(\\(a*\\)b*\\)*\\2", "abaabaa"); TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "abaabaa", 0, 7, 2, 5, 2, 4); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xaababaax", 0, 0, 0, 0, 0, 0); + TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xaababaax", 0, 0, 0, 0, 0, 0); - test_match ("\\(\\(a*\\)b*\\)*a\\2", "aabaaa"); + test_match ("\\(\\(a*\\)b*\\)*a\\2", "aabaaa"); TEST_REGISTERS ("\\(\\(a*\\)b*a\\)*\\2", "aabaaa", 0, 6, 0, 3, 0, 2); - TEST_REGISTERS ("\\(\\(a*\\)b*a\\)*\\2", "xaabaax", 0, 0, -1, -1, -1, -1); + TEST_REGISTERS ("\\(\\(a*\\)b*a\\)*\\2", "xaabaax", 0, 0, -1, -1, -1, -1); - test_match ("\\(\\(a*\\)b*\\)*\\2a", "aabaaa"); + test_match ("\\(\\(a*\\)b*\\)*\\2a", "aabaaa"); TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2a", "aabaaa", 0, 6, 0, 3, 0, 2); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2a", "xaabaaax", 1, 7, 1, 4, 1, 3); + TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2a", "xaabaaax", 1, 7, 1, 4, 1, 3); test_match ("\\(\\(a*\\)b\\)*\\2\\1", "abaabaaaab"); TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2\\1", "abaabaaaab", 0, 10, 2, 5, 2, 4); @@ -152,7 +152,7 @@ test_posix_basic () test_match ("\\(a*b\\)\\1", "abab"); test_match ("\\(a\\)\\1\\1", "aaa"); test_match ("\\(a\\(c\\)d\\)\\1\\2", "acdacdc"); - + test_match ("\\(a\\)\\1*", "aaa"); TEST_REGISTERS ("\\(a\\)\\1*", "aaa", 0, 3, 0, 1, -1, -1); TEST_REGISTERS ("\\(a\\)\\1*", "xaaax", 1, 4, 1, 2, -1, -1); @@ -186,15 +186,15 @@ test_posix_basic () /* Per POSIX D11.1, p. 125, leftmost longest match. */ - + test_match (PARENS_TO_OPS ("(ac*)c*d[ac]*\\1"), "acdacaaa"); - TEST_REGISTERS (PARENS_TO_OPS ("(ac*)c*d[ac]*\\1"), "acdacaaa", + TEST_REGISTERS (PARENS_TO_OPS ("(ac*)c*d[ac]*\\1"), "acdacaaa", 0, 8, 0, 1, -1, -1); /* Anchors become ordinary, sometimes. */ MATCH_SELF ("a^"); - MATCH_SELF ("$a"); - MATCH_SELF ("$^"); + MATCH_SELF ("$a"); + MATCH_SELF ("$^"); test_fastmap ("$a^", "$", 0, 0); test_match ("$^*", "$^^"); test_match ("\\($^\\)", "$^"); diff --git a/gnu/lib/libregex/test/psx-extend.c b/gnu/lib/libregex/test/psx-extend.c index 6f02d67..14b8a5e 100644 --- a/gnu/lib/libregex/test/psx-extend.c +++ b/gnu/lib/libregex/test/psx-extend.c @@ -13,15 +13,15 @@ test_posix_extended () printf ("\nStarting POSIX extended tests.\n"); t = posix_extended_test; - - re_set_syntax (RE_SYNTAX_POSIX_MINIMAL_EXTENDED); + + re_set_syntax (RE_SYNTAX_POSIX_MINIMAL_EXTENDED); test_posix_generic (); printf ("\nContinuing POSIX extended tests.\n"); /* Grouping tests that differ from basic's. */ - + test_should_match = true; MATCH_SELF ("a)"); @@ -74,8 +74,8 @@ test_posix_extended () MATCH_SELF ("a{}"); MATCH_SELF ("a{-1"); MATCH_SELF ("a{-1}"); - MATCH_SELF ("a{0"); - MATCH_SELF ("a{0,"); + MATCH_SELF ("a{0"); + MATCH_SELF ("a{0,"); MATCH_SELF (concat ("a{", dup_max_plus_one)); MATCH_SELF (concat (concat ("a{", dup_max_plus_one), ",")); MATCH_SELF ("a{1,0"); @@ -83,7 +83,7 @@ test_posix_extended () MATCH_SELF ("a{0,1"); test_match ("[a{0,1}]", "}"); test_match ("a{1,3}{-1}", "aaa{-1}"); - test_match (concat ("a{1,3}{", dup_max_plus_one), + test_match (concat ("a{1,3}{", dup_max_plus_one), concat ("aaa{", dup_max_plus_one)); test_match ("a{1,3}{2,1}", "aaa{2,1}"); test_match ("a{1,3}{1,2", "aaa{1,2"); @@ -96,7 +96,7 @@ test_posix_extended () test_match ("a??", "a"); test_match ("a?*", "a"); test_match ("a?+", "a"); - + test_match ("a{2}?", ""); test_match ("a{2}?", "aa"); test_match ("a{2}+", "aa"); @@ -104,21 +104,21 @@ test_posix_extended () test_match ("a{1}?*", ""); test_match ("a{1}?*", "aa"); - - test_match ("(a?){0,3}b", "aaab"); - test_fastmap ("(a?){0,3}b", "ab", 0, 0); - test_match ("(a+){0,3}b", "b"); - test_fastmap ("(a+){0,3}b", "ab", 0, 0); + + test_match ("(a?){0,3}b", "aaab"); + test_fastmap ("(a?){0,3}b", "ab", 0, 0); + test_match ("(a+){0,3}b", "b"); + test_fastmap ("(a+){0,3}b", "ab", 0, 0); test_match ("(a+){0,3}b", "ab"); - test_fastmap ("(a+){0,3}b", "ab", 0, 0); - test_match ("(a+){1,3}b", "aaab"); + test_fastmap ("(a+){0,3}b", "ab", 0, 0); + test_match ("(a+){1,3}b", "aaab"); test_match ("(a?){1,3}b", "aaab"); test_match ("\\\\{1}", "\\"); /* Extended only. */ test_match ("(a?)?", "a"); test_match ("(a?b)?c", "abc"); - test_match ("(a+)*b", "b"); + test_match ("(a+)*b", "b"); /* Alternatives. */ test_match ("a|b", "a"); test_match ("a|b", "b"); @@ -132,7 +132,7 @@ test_posix_extended () test_match ("(a|b|c)", "c"); test_match ("(a|b|c)*", "abccba"); - + test_match ("(a(b*))|c", "a"); /* xx do registers. */ test_match ("(a(b*))|c", "ab"); test_match ("(a(b*))|c", "c"); @@ -140,7 +140,7 @@ test_posix_extended () test_fastmap ("(a+?*|b)", "ab", 0, 0); test_match ("(a+?*|b)", "b"); TEST_REGISTERS ("(a+?*|b)", "b", 0, 1, 0, 1, -1, -1); - + test_fastmap ("(a+?*|b)*", "ab", 0, 0); test_match ("(a+?*|b)*", "bb"); TEST_REGISTERS ("(a+?*|b)*", "bb", 0, 2, 1, 2, -1, -1); @@ -165,7 +165,7 @@ test_posix_extended () test_fastmap ("(a+?*|b)c", "abc", 0, 0); test_match ("(a+?*|b)c", "bc"); TEST_REGISTERS ("(a+?*|b)c", "bc", 0, 2, 0, 1, -1, -1); - + test_fastmap ("(a+?*|b)*c", "abc", 0, 0); test_match ("(a+?*|b)*c", "bbc"); TEST_REGISTERS ("(a+?*|b)*c", "bbc", 0, 3, 1, 2, -1, -1); @@ -189,12 +189,12 @@ test_posix_extended () test_fastmap ("((a{0,}\\b\\<)|b)", "ab", 0, 0); test_match ("((a{0,}\\b\\<)|b)", "b"); - TEST_REGISTERS ("((a{0,}\\b\\<)|b)", "b", + TEST_REGISTERS ("((a{0,}\\b\\<)|b)", "b", 0, 1, 0, 1, 0, 0); test_fastmap ("((a{0,}\\b\\<)|b)*", "ab", 0, 0); test_match ("((a{0,}\\b\\<)|b)*", "b"); - TEST_REGISTERS ("((a{0,}\\b\\<)|b)*", "b", + TEST_REGISTERS ("((a{0,}\\b\\<)|b)*", "b", 0, 1, 0, 1, 0, 0); test_fastmap ("((a+?*{0,1}\\b\\<)|b)", "ab", 0, 0); @@ -251,7 +251,7 @@ test_posix_extended () /* `*' after group. */ - test_match ("(a*|b*)*c", "c"); + test_match ("(a*|b*)*c", "c"); TEST_REGISTERS ("(a*|b*)*c", "c", 0, 1, 0, 0, -1, -1); test_match ("(a*|b*)*c", "ac"); @@ -279,8 +279,8 @@ test_posix_extended () test_match ("(a*|b*)c", "aac"); TEST_REGISTERS ("(a*|b*)c", "aac", 0, 3, 0, 2, -1, -1); - /* Same as above, but with no `*'s in alternatives. - + /* Same as above, but with no `*'s in alternatives. + test_match ("(a|b)*c", "c"); /* `*' after group. */ TEST_REGISTERS ("(a|b)*c", "c", 0, 1, -1, -1, -1, -1); @@ -298,7 +298,7 @@ test_posix_extended () TEST_REGISTERS ("(a*|b*)c", "bbc", 0, 3, 0, 2, -1, -1); /* Complicated second alternative. */ - + test_match ("(a*|(b*)*)*c", "bc"); TEST_REGISTERS ("(a*|(b*)*)*c", "bc", 0, 2, 0, 1, 0, 1); @@ -335,9 +335,9 @@ test_posix_extended () valid_pattern ("(^$)"); /* These are the same (but valid) as those (invalid) in other_test.c. */ - valid_pattern + valid_pattern ("(((((((((((((((((((((((((((((((((a^)))))))))))))))))))))))))))))))))"); - valid_pattern + valid_pattern ("((((((((((((((((((((((((((((((((($a)))))))))))))))))))))))))))))))))"); valid_pattern ("\\(^a\\)"); valid_pattern ("a\\|^b"); @@ -724,7 +724,7 @@ test_posix_extended () valid_pattern ("(^a)(b|^c)|^d"); valid_pattern ("(^a)(b|c^)|^d"); valid_pattern ("(^a)(b|c)^|^d"); - + valid_pattern ("(a)(b$|c$)d$"); valid_pattern ("(a)(b|$c)$|d$"); valid_pattern ("(a)($b|c)$|d$"); @@ -1003,11 +1003,11 @@ test_posix_extended () TEST_SEARCH ("^(a)(b|c)|^d", "abe", 0, 3); TEST_SEARCH ("^(a)(b|c)|^d", "ace", 0, 3); TEST_SEARCH ("^(a)(b|c)|^d", "df", 0, 2); - + TEST_SEARCH ("(^a)(b|c)|^d", "abe", 0, 3); TEST_SEARCH ("(^a)(b|c)|^d", "ace", 0, 3); TEST_SEARCH ("(^a)(b|c)|^d", "df", 0, 2); - + TEST_SEARCH ("(a)(b|c)$|d$", "fab", 0, 3); TEST_SEARCH ("(a)(b|c)$|d$", "fac", 0, 3); TEST_SEARCH ("(a)(b|c)$|d$", "fd", 0, 2); @@ -1027,11 +1027,11 @@ test_posix_extended () TEST_SEARCH ("^d|^(b|c)(a)", "df", 0, 2); TEST_SEARCH ("^d|^(b|c)(a)", "baf", 0, 3); TEST_SEARCH ("^d|^(b|c)(a)", "caf", 0, 3); - + TEST_SEARCH ("^d|(^b|^c)(a)", "df", 0, 2); TEST_SEARCH ("^d|(^b|^c)(a)", "baf", 0, 3); TEST_SEARCH ("^d|(^b|^c)(a)", "caf", 0, 3); - + TEST_SEARCH ("d$|(b|c)(a$)", "fd", 0, 2); TEST_SEARCH ("d$|(b|c)(a$)", "fba", 0, 3); TEST_SEARCH ("d$|(b|c)(a$)", "fca", 0, 3); @@ -1112,13 +1112,13 @@ test_posix_extended () test_match ("(fooq|foo)(qbarx|bar)", "fooqbarx"); /* Take first alternative that does the longest match. */ - test_all_registers ("(fooq|(foo)|(fo))((qbarx)|(oqbarx)|bar)", "fooqbarx", - "", 0, 8, 0, 3, 0, 3, -1, -1, 3, 8, 3, 8, -1, -1, -1, -1, -1, -1, + test_all_registers ("(fooq|(foo)|(fo))((qbarx)|(oqbarx)|bar)", "fooqbarx", + "", 0, 8, 0, 3, 0, 3, -1, -1, 3, 8, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1); test_match ("(fooq|foo)*qbar", "fooqbar"); test_match ("(fooq|foo)*(qbar)", "fooqbar"); - test_match ("(fooq|foo)*(qbar)*", "fooqbar"); + test_match ("(fooq|foo)*(qbar)*", "fooqbar"); test_match ("(fooq|fo|o)*qbar", "fooqbar"); test_match ("(fooq|fo|o)*(qbar)", "fooqbar"); diff --git a/gnu/lib/libregex/test/psx-generic.c b/gnu/lib/libregex/test/psx-generic.c index 340e938..8e97f75 100644 --- a/gnu/lib/libregex/test/psx-generic.c +++ b/gnu/lib/libregex/test/psx-generic.c @@ -12,7 +12,7 @@ test_posix_generic () if (omit_generic_tests) return; /* Tests somewhat in the order of P1003.2. */ - + /* Both posix basic and extended; should match. */ printf ("\nStarting generic POSIX tests.\n"); @@ -29,12 +29,12 @@ test_posix_generic () TEST_REGISTERS ("", "", 0, 0, -1, -1, -1, -1); TEST_SEARCH ("", "", 0, 0); TEST_SEARCH_2 ("", "", "", 0, 1, 0); - - MATCH_SELF ("abc"); - test_fastmap ("abc", "a", 0, 0); + + MATCH_SELF ("abc"); + test_fastmap ("abc", "a", 0, 0); TEST_REGISTERS ("abc", "abc", 0, 3, -1, -1, -1, -1); TEST_REGISTERS ("abc", "xabcx", 1, 4, -1, -1, -1, -1); - + test_match ("\\a","a"); test_match ("\\0", "0"); @@ -44,7 +44,7 @@ test_posix_generic () TEST_SEARCH_2 ("a", "a", "b", 0, 2, 2); TEST_SEARCH_2 ("b", "a", "b", 0, 2, 2); TEST_SEARCH_2 ("a", "a", "b", 1, -2, 2); - + test_match ("\n", "\n"); test_match ("a\n", "a\n"); test_match ("\nb", "\nb"); @@ -55,8 +55,8 @@ test_posix_generic () test_match ("a*", "aa"); test_fastmap ("a*", "a", 0, 0); TEST_REGISTERS ("a*", "aa", 0, 2, -1, -1, -1, -1); - - test_match ("a*b", "aab"); + + test_match ("a*b", "aab"); test_fastmap ("a*b", "ab", 0, 0); test_match ("a*ab", "aab"); @@ -80,9 +80,9 @@ test_posix_generic () test_match (".", "a"); TEST_REGISTERS (".", "a", 0, 1, -1, -1, -1, -1); test_match (".", "\004"); - test_match (".", "\n"); + test_match (".", "\n"); /* Valid bracket expressions. */ - test_match ("[ab]", "a"); + test_match ("[ab]", "a"); test_match ("[ab]", "b"); test_fastmap ("[ab]", "ab", 0, 0); TEST_REGISTERS ("[ab]", "a", 0, 1, -1, -1, -1, -1); @@ -92,7 +92,7 @@ test_posix_generic () test_match ("[^ab]", "c"); test_match ("[^a]", "\n"); - test_match ("[a]*a", "aa"); + test_match ("[a]*a", "aa"); test_match ("[[]", "["); test_match ("[]]", "]"); @@ -115,12 +115,12 @@ test_posix_generic () /* Collating, noncollating, equivalence classes aren't - implemented yet. */ - + implemented yet. */ + /* Character classes. */ - test_match ("[:alpha:]", "p"); - test_match ("[[:alpha:]]", "a"); + test_match ("[:alpha:]", "p"); + test_match ("[[:alpha:]]", "a"); test_match ("[[:alpha:]]", "z"); test_match ("[[:alpha:]]", "A"); test_match ("[[:alpha:]]", "Z"); @@ -172,10 +172,10 @@ test_posix_generic () test_match ("[a-]", "-"); /* Last */ test_match ("[a-]", "a"); test_match ("[--@]", "@"); /* First and starting point. */ - + test_match ("[%--a]", "%"); /* Ending point. */ test_match ("[%--a]", "-"); /* Ditto. */ - + test_match ("[a%--]", "%"); /* Both ending point and last. */ test_match ("[a%--]", "-"); test_match ("[%--a]", "a"); /* Ending point only. */ @@ -186,29 +186,29 @@ test_posix_generic () test_match ("[)-+--/]", "/"); test_match ("[[:digit:]-]", "-"); /* Concatenation ????*/ - test_match ("[ab][cd]", "ac"); + test_match ("[ab][cd]", "ac"); test_fastmap ("[ab][cd]", "ab", 0, 0); TEST_REGISTERS ("[ab][cd]", "ad", 0, 2, -1, -1, -1, -1); TEST_REGISTERS ("[ab][cd]", "xadx", 1, 3, -1, -1, -1, -1); - + /* Valid expression anchoring. */ test_match ("^a", "a"); test_fastmap ("^a", "a", 0, 0); TEST_REGISTERS ("^a", "ax", 0, 1, -1, -1, -1, -1); - + test_match ("^", ""); TEST_REGISTERS ("^", "", 0, 0, -1, -1, -1, -1); test_match ("$", ""); TEST_REGISTERS ("$", "", 0, 0, -1, -1, -1, -1); - + test_match ("a$", "a"); test_fastmap ("a$", "a", 0, 0); TEST_REGISTERS ("a$", "xa", 1, 2, -1, -1, -1, -1); - + test_match ("^ab$", "ab"); test_fastmap ("^ab$", "a", 0, 0); TEST_REGISTERS ("^a$", "a", 0, 1, -1, -1, -1, -1); - + test_fastmap ("^$", "", 0, 0); test_match ("^$", ""); TEST_REGISTERS ("^$", "", 0, 0, -1, -1, -1, -1); @@ -221,7 +221,7 @@ test_posix_generic () /* Two strings. */ test_match_2 ("ab", "a", "b"); TEST_REGISTERS_2 ("ab", "a", "b", 0, 2, -1, -1, -1, -1); - + test_match_2 ("a", "", "a"); test_match_2 ("a", "a", ""); test_match_2 ("ab", "a", "b"); @@ -235,8 +235,8 @@ test_posix_generic () test_should_match = false; /* Ordinary characters. */ - test_match ("abc", "ab"); - + test_match ("abc", "ab"); + TEST_SEARCH ("c", "ab", 0, 2); TEST_SEARCH ("c", "ab", 0, 2); TEST_SEARCH ("c", "ab", 1, -2); @@ -257,8 +257,8 @@ test_posix_generic () /* Invalid period. */ test_match (".", ""); /* Invalid bracket expressions. */ - test_match ("[ab]", "c"); - test_match ("[^b]", "b"); + test_match ("[ab]", "c"); + test_match ("[^b]", "b"); test_match ("[^]]", "]"); invalid_pattern (REG_EBRACK, "["); @@ -267,7 +267,7 @@ test_posix_generic () invalid_pattern (REG_EBRACK, "[]"); invalid_pattern (REG_EBRACK, "[]a"); invalid_pattern (REG_EBRACK, "a[]a"); - + test_match ("[:alpha:]", "q"); /* Character classes. */ test_match ("[[:alpha:]]", "2"); @@ -288,10 +288,10 @@ test_posix_generic () invalid_pattern (REG_ECTYPE, "[[:a:]]"); invalid_pattern (REG_ECTYPE, "[[:alpo:]]"); invalid_pattern (REG_ECTYPE, "[[:a:]"); - + test_match ("[a-z]", "2"); /* Invalid ranges. */ - test_match ("[^-a]", "-"); - test_match ("[^a-]", "-"); + test_match ("[^-a]", "-"); + test_match ("[^a-]", "-"); test_match ("[)-+--/]", "."); invalid_pattern (REG_ERANGE, "[z-a]"); /* Empty */ invalid_pattern (REG_ERANGE, "[a--]"); /* Empty */ diff --git a/gnu/lib/libregex/test/psx-interf.c b/gnu/lib/libregex/test/psx-interf.c index 8312d5e..80498fb 100644 --- a/gnu/lib/libregex/test/psx-interf.c +++ b/gnu/lib/libregex/test/psx-interf.c @@ -7,7 +7,7 @@ #define ERROR_CODE_LENGTH 20 #define TEST_ERRBUF_SIZE 15 - + void test_compile (); @@ -64,50 +64,50 @@ init_pattern_buffer (pattern_buffer_ptr) void -test_compile (valid_pattern, error_code_expected, pattern, +test_compile (valid_pattern, error_code_expected, pattern, pattern_buffer_ptr, cflags) unsigned valid_pattern; int error_code_expected; const char *pattern; regex_t *pattern_buffer_ptr; int cflags; -{ +{ int error_code_returned; boolean error = false; char errbuf[TEST_ERRBUF_SIZE]; - + init_pattern_buffer (pattern_buffer_ptr); error_code_returned = regcomp (pattern_buffer_ptr, pattern, cflags); if (valid_pattern && error_code_returned) { printf ("\nShould have been a valid pattern but wasn't.\n"); - regerror (error_code_returned, pattern_buffer_ptr, errbuf, + regerror (error_code_returned, pattern_buffer_ptr, errbuf, TEST_ERRBUF_SIZE); printf ("%s", errbuf); error = true; } - + if (!valid_pattern && !error_code_returned) { printf ("\n\nInvalid pattern compiled as valid:\n"); error = true; } - + if (error_code_returned != error_code_expected) { char expected_error_string[ERROR_CODE_LENGTH]; char returned_error_string[ERROR_CODE_LENGTH]; - - get_error_string (error_code_expected, expected_error_string), + + get_error_string (error_code_expected, expected_error_string), get_error_string (error_code_returned, returned_error_string); - - printf (" Expected error code %s but got `%s'.\n", + + printf (" Expected error code %s but got `%s'.\n", expected_error_string, returned_error_string); error = true; } - + if (error) print_pattern_info (pattern, pattern_buffer_ptr); } @@ -121,7 +121,7 @@ test_nsub (sub_count, pattern, cflags) { regex_t pattern_buffer; - + test_compile (1, 0, pattern, &pattern_buffer, cflags); if (pattern_buffer.re_nsub != sub_count) @@ -132,7 +132,7 @@ instead.\n", sub_count, pattern_buffer.re_nsub); regfree (&pattern_buffer); } - + static void test_regcomp () @@ -140,9 +140,9 @@ test_regcomp () regex_t pattern_buffer; int cflags = 0; - + printf ("\nStarting regcomp tests.\n"); - + cflags = 0; test_compile (0, REG_ESUBREG, "\\(a\\)\\2", &pattern_buffer, cflags); test_compile (0, REG_EBRACE, "a\\{", &pattern_buffer, cflags); @@ -160,7 +160,7 @@ test_regcomp () test_nsub (1, "(a)", cflags); test_nsub (2, "((a))", cflags); test_nsub (2, "(a)(b)", cflags); - + cflags = REG_EXTENDED | REG_NOSUB; test_nsub (1, "(a)", cflags); @@ -197,13 +197,13 @@ test_pmatch (pattern, string, nmatch, pmatch, correct_pmatch, cflags) unsigned this_match; int error_code_returned; boolean found_nonmatch = false; - + test_compile (1, 0, pattern, &pattern_buffer, cflags); error_code_returned = regexec (&pattern_buffer, string, nmatch, pmatch, 0); - + if (error_code_returned == REG_NOMATCH) printf ("Matching failed in test_pmatch.\n"); - else + else { for (this_match = 0; this_match < nmatch; this_match++) { @@ -213,7 +213,7 @@ test_pmatch (pattern, string, nmatch, pmatch, correct_pmatch, cflags) printf ("\n"); printf ("Pmatch start %d wrong: was %d when should have \ -been %d.\n", this_match, pmatch[this_match].rm_so, +been %d.\n", this_match, pmatch[this_match].rm_so, correct_pmatch[this_match].rm_so); found_nonmatch = true; } @@ -223,7 +223,7 @@ been %d.\n", this_match, pmatch[this_match].rm_so, printf ("\n"); printf ("Pmatch end %d wrong: was %d when should have been \ -%d.\n", this_match, pmatch[this_match].rm_eo, +%d.\n", this_match, pmatch[this_match].rm_eo, correct_pmatch[this_match].rm_eo); found_nonmatch = true; } @@ -258,12 +258,12 @@ test_eflags (must_match_bol, must_match_eol, pattern, string, cflags, eflags) error_code_returned = regexec (&pattern_buffer, string, 0, 0, eflags); if (error_code_returned == REG_NOMATCH) - { + { /* If wasn't true that both 1) the anchored part of the pattern had to match this string and 2) this string was a proper substring... */ - if (!( (must_match_bol && (eflags & REG_NOTBOL)) + if (!( (must_match_bol && (eflags & REG_NOTBOL)) || (must_match_eol && (eflags & REG_NOTEOL)) )) { printf ("\nEflags test failed: didn't match when should have.\n"); @@ -271,7 +271,7 @@ test_eflags (must_match_bol, must_match_eol, pattern, string, cflags, eflags) } } else /* We got a match. */ - { + { /* If wasn't true that either 1) the anchored part of the pattern didn't have to match this string or 2) this string wasn't a proper substring... */ @@ -313,7 +313,7 @@ test_ignore_case (should_match, pattern, string, cflags) error_code_returned = regexec (&pattern_buffer, string, 0, 0, 0); if (should_match && error_code_returned == REG_NOMATCH) - { + { printf ("\nIgnore-case test failed:\n"); printf (" The string to match was: `%s'.\n", string); print_pattern_info (pattern, &pattern_buffer); @@ -340,7 +340,7 @@ test_newline (should_match, pattern, string, cflags) error_code_returned = regexec (&pattern_buffer, string, 0, 0, 0); if (should_match && error_code_returned == REG_NOMATCH) - { + { printf ("\nNewline test failed:\n"); printf (" The string to match was: `%s'.\n", string); print_pattern_info (pattern, &pattern_buffer); @@ -370,12 +370,12 @@ test_posix_match (should_match, pattern, string, cflags) error_code_returned = regexec (&pattern_buffer, string, 0, 0, 0); if (should_match && error_code_returned == REG_NOMATCH) - { + { printf ("\nShould have matched but didn't:\n"); was_error = true; } else if (!should_match && error_code_returned != REG_NOMATCH) - { + { printf ("\nShould not have matched but did:\n"); was_error = true; } @@ -397,23 +397,23 @@ test_regexec () regmatch_t correct_pmatch[3]; int cflags = 0; int eflags = 0; - + printf ("\nStarting regexec tests.\n"); cflags = REG_NOSUB; /* shouldn't look at any of pmatch. */ test_pmatch ("a", "a", 0, pmatch, correct_pmatch, cflags); - + /* Ask for less `pmatch'es than there are pattern subexpressions. (Shouldn't look at pmatch[2]. */ cflags = REG_EXTENDED; fill_pmatch (correct_pmatch, 0, 1, 0, 1, 100, 101); test_pmatch ("((a))", "a", 2, pmatch, correct_pmatch, cflags); - + /* Ask for same number of `pmatch'es as there are pattern subexpressions. */ cflags = REG_EXTENDED; fill_pmatch(correct_pmatch, 0, 1, 0, 1, -1, -1); test_pmatch ("(a)", "a", 2, pmatch, correct_pmatch, cflags); - + /* Ask for more `pmatch'es than there are pattern subexpressions. */ cflags = REG_EXTENDED; fill_pmatch (correct_pmatch, 0, 1, -1, -1, -1, -1); @@ -487,7 +487,7 @@ test_regexec () test_newline (true, "^a", "\na", cflags); test_newline (true, "a$", "a\n", cflags); - + /* Now test normal behavior. */ cflags = REG_EXTENDED; test_newline (true, "\n", "\n", cflags); @@ -508,11 +508,11 @@ test_regexec () /* Test that matches whole string only. */ cflags = 0; test_posix_match (true, "a", "a", cflags); - + /* Tests that match substrings. */ test_posix_match (true, "a", "ab", cflags); test_posix_match (true, "b", "ab", cflags); - + /* Test that doesn't match. */ test_posix_match (false, "a", "b", cflags); @@ -528,8 +528,8 @@ test_error_code_message (error_code, expected_error_message) char returned_error_message[TEST_ERRBUF_SIZE]; char error_code_string[ERROR_CODE_LENGTH]; size_t expected_error_message_length = strlen (expected_error_message) + 1; - size_t returned_error_message_length = regerror (error_code, 0, - returned_error_message, + size_t returned_error_message_length = regerror (error_code, 0, + returned_error_message, TEST_ERRBUF_SIZE); if (returned_error_message_length != expected_error_message_length) @@ -543,14 +543,14 @@ message `%s':\n", expected_error_message); expected_error_message_length, returned_error_message_length); } - if (strncmp (expected_error_message, returned_error_message, + if (strncmp (expected_error_message, returned_error_message, TEST_ERRBUF_SIZE - 1) != 0) { - - get_error_string (error_code, error_code_string), + + get_error_string (error_code, error_code_string), printf ("\n\n With error code %s (%d), expected error message:\n", error_code_string, error_code); - + printf (" `%s'\n", expected_error_message); printf (" but got:\n"); printf (" `%s'\n", returned_error_message); @@ -565,21 +565,21 @@ test_error_code_allocation (error_code, expected_error_message) { char *returned_error_message = NULL; char error_code_string[ERROR_CODE_LENGTH]; - size_t returned_error_message_length = regerror (error_code, 0, - returned_error_message, + size_t returned_error_message_length = regerror (error_code, 0, + returned_error_message, (size_t)0); returned_error_message = xmalloc (returned_error_message_length + 1); - - regerror (error_code, 0, returned_error_message, + + regerror (error_code, 0, returned_error_message, returned_error_message_length); - + if (strcmp (expected_error_message, returned_error_message) != 0) { - get_error_string (error_code, error_code_string), - - printf ("\n\n Testing error code allocation,\n"); - printf ("with error code %s (%d), expected error message:\n", + get_error_string (error_code, error_code_string), + + printf ("\n\n Testing error code allocation,\n"); + printf ("with error code %s (%d), expected error message:\n", error_code_string, error_code); printf (" `%s'\n", expected_error_message); printf (" but got:\n"); @@ -591,18 +591,18 @@ test_error_code_allocation (error_code, expected_error_message) static void test_regerror () { - test_error_code_message (REG_NOMATCH, "No match"); + test_error_code_message (REG_NOMATCH, "No match"); test_error_code_message (REG_BADPAT, "Invalid regular expression"); - test_error_code_message (REG_ECOLLATE, "Invalid collation character"); - test_error_code_message (REG_ECTYPE, "Invalid character class name"); - test_error_code_message (REG_EESCAPE, "Trailing backslash"); - test_error_code_message (REG_ESUBREG, "Invalid back reference"); - test_error_code_message (REG_EBRACK, "Unmatched [ or [^"); - test_error_code_message (REG_EPAREN, "Unmatched ( or \\("); - test_error_code_message (REG_EBRACE, "Unmatched \\{"); - test_error_code_message (REG_BADBR, "Invalid content of \\{\\}"); - test_error_code_message (REG_ERANGE, "Invalid range end"); - test_error_code_message (REG_ESPACE, "Memory exhausted"); + test_error_code_message (REG_ECOLLATE, "Invalid collation character"); + test_error_code_message (REG_ECTYPE, "Invalid character class name"); + test_error_code_message (REG_EESCAPE, "Trailing backslash"); + test_error_code_message (REG_ESUBREG, "Invalid back reference"); + test_error_code_message (REG_EBRACK, "Unmatched [ or [^"); + test_error_code_message (REG_EPAREN, "Unmatched ( or \\("); + test_error_code_message (REG_EBRACE, "Unmatched \\{"); + test_error_code_message (REG_BADBR, "Invalid content of \\{\\}"); + test_error_code_message (REG_ERANGE, "Invalid range end"); + test_error_code_message (REG_ESPACE, "Memory exhausted"); test_error_code_message (REG_BADRPT, "Invalid preceding regular expression"); test_error_code_message (REG_EEND, "Premature end of regular expression"); test_error_code_message (REG_ESIZE, "Regular expression too big"); @@ -615,10 +615,10 @@ test_posix_interface () { printf ("\nStarting POSIX interface tests.\n"); t = posix_interface_test; - + test_regcomp (); test_regexec (); test_regerror (); - + printf ("\nFinished POSIX interface tests.\n"); } diff --git a/gnu/lib/libregex/test/psx-interv.c b/gnu/lib/libregex/test/psx-interv.c index 6725c38..fcdf488 100644 --- a/gnu/lib/libregex/test/psx-interv.c +++ b/gnu/lib/libregex/test/psx-interv.c @@ -27,10 +27,10 @@ test_intervals () test_match (BRACES_TO_OPS ("a{1}"), "a"); test_match (BRACES_TO_OPS ("a{1,}"), "a"); - test_match (BRACES_TO_OPS ("a{1,}"), "aa"); + test_match (BRACES_TO_OPS ("a{1,}"), "aa"); test_match (BRACES_TO_OPS ("a{0,0}"), ""); test_match (BRACES_TO_OPS ("a{0,1}"), ""); - test_match (BRACES_TO_OPS ("a{0,1}"), "a"); + test_match (BRACES_TO_OPS ("a{0,1}"), "a"); test_match (BRACES_TO_OPS ("a{1,3}"), "a"); test_match (BRACES_TO_OPS ("a{1,3}"), "aa"); test_match (BRACES_TO_OPS ("a{1,3}"), "aaa"); @@ -68,7 +68,7 @@ test_intervals () test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){1,1}ab")), "aaaab"); TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){1,1}ab")), "aaaab", 0, 5, 0, 3, -1, -1); - + test_match (BRACES_TO_OPS (".{0,3}b"), "b"); test_match (BRACES_TO_OPS (".{0,3}b"), "ab"); @@ -98,7 +98,7 @@ test_intervals () test_match (BRACES_TO_OPS ("a{1}*"), ""); test_match (BRACES_TO_OPS ("a{1}*"), "a"); test_match (BRACES_TO_OPS ("a{1}*"), "aa"); - + test_match (BRACES_TO_OPS ("a{1}{1}"), "a"); test_match (BRACES_TO_OPS ("a{1}{1}{1}"), "a"); @@ -108,25 +108,25 @@ test_intervals () test_match (BRACES_TO_OPS ("a{1}{1}*"), "a"); test_match (BRACES_TO_OPS ("a{1}{1}*"), "aa"); test_match (BRACES_TO_OPS ("a{1}{1}*"), "aaa"); - + test_match (BRACES_TO_OPS ("a{1}{2}"), "aa"); test_match (BRACES_TO_OPS ("a{2}{1}"), "aa"); test_should_match = false; - + test_match (BRACES_TO_OPS ("a{0}"), "a"); test_match (BRACES_TO_OPS ("a{0,}"), "b"); - test_match (BRACES_TO_OPS ("a{1}"), ""); + test_match (BRACES_TO_OPS ("a{1}"), ""); test_match (BRACES_TO_OPS ("a{1}"), "aa"); test_match (BRACES_TO_OPS ("a{1,}"), ""); test_match (BRACES_TO_OPS ("a{1,}"), "b"); - test_match (BRACES_TO_OPS ("a{0,0}"), "a"); + test_match (BRACES_TO_OPS ("a{0,0}"), "a"); test_match (BRACES_TO_OPS ("a{0,1}"), "aa"); test_match (BRACES_TO_OPS ("a{0,1}"), "b"); - test_match (BRACES_TO_OPS ("a{1,3}"), ""); + test_match (BRACES_TO_OPS ("a{1,3}"), ""); test_match (BRACES_TO_OPS ("a{1,3}"), "aaaa"); - test_match (BRACES_TO_OPS ("a{1,3}"), "b"); + test_match (BRACES_TO_OPS ("a{1,3}"), "b"); test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a){1,3}b")), "aaaab"); test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){1,3}b")), "bb"); test_match (BRACES_TO_OPS ("[a]{0,3}"), "aaaa"); diff --git a/gnu/lib/libregex/test/test.c b/gnu/lib/libregex/test/test.c index a8de23e..74b43b2 100644 --- a/gnu/lib/libregex/test/test.c +++ b/gnu/lib/libregex/test/test.c @@ -55,32 +55,32 @@ boolean test_should_match; static void -set_all_registers (start0, end0, start1, end1, +set_all_registers (start0, end0, start1, end1, start2, end2, start3, end3, - start4, end4, start5, end5, + start4, end4, start5, end5, start6, end6, start7, end7, start8, end8, start9, end9, regs) - int start0; int end0; int start1; int end1; + int start0; int end0; int start1; int end1; int start2; int end2; int start3; int end3; - int start4; int end4; int start5; int end5; + int start4; int end4; int start5; int end5; int start6; int end6; int start7; int end7; - int start8; int end8; int start9; int end9; + int start8; int end8; int start9; int end9; struct re_registers *regs; { unsigned r; - - regs->start[0] = start0; regs->end[0] = end0; - regs->start[1] = start1; regs->end[1] = end1; - regs->start[2] = start2; regs->end[2] = end2; - regs->start[3] = start3; regs->end[3] = end3; - regs->start[4] = start4; regs->end[4] = end4; - regs->start[5] = start5; regs->end[5] = end5; - regs->start[6] = start6; regs->end[6] = end6; - regs->start[7] = start7; regs->end[7] = end7; - regs->start[8] = start8; regs->end[8] = end8; - regs->start[9] = start9; regs->end[9] = end9; + + regs->start[0] = start0; regs->end[0] = end0; + regs->start[1] = start1; regs->end[1] = end1; + regs->start[2] = start2; regs->end[2] = end2; + regs->start[3] = start3; regs->end[3] = end3; + regs->start[4] = start4; regs->end[4] = end4; + regs->start[5] = start5; regs->end[5] = end5; + regs->start[6] = start6; regs->end[6] = end6; + regs->start[7] = start7; regs->end[7] = end7; + regs->start[8] = start8; regs->end[8] = end8; + regs->start[9] = start9; regs->end[9] = end9; for (r = 10; r < regs->num_regs; r++) { regs->start[r] = -1; @@ -111,16 +111,16 @@ concat (s1, s2) /* We ignore the `can_be_null' argument. Should just be removed. */ -void +void general_test (pattern_should_be_valid, match_whole_string, pat, str1, str2, start, range, end, correct_fastmap, correct_regs, can_be_null) - unsigned pattern_should_be_valid; + unsigned pattern_should_be_valid; unsigned match_whole_string; const char *pat; char *str1, *str2; - int start, range, end; - char *correct_fastmap; + int start, range, end; + char *correct_fastmap; struct re_registers *correct_regs; int can_be_null; { @@ -138,8 +138,8 @@ general_test (pattern_should_be_valid, match_whole_string, unsigned invalid_pattern = 0; boolean internal_error_1 = false; boolean internal_error_2 = false; - - + + nonconst_buf.allocated = 8; nonconst_buf.buffer = xmalloc (nonconst_buf.allocated); nonconst_buf.fastmap = fastmap; @@ -147,7 +147,7 @@ general_test (pattern_should_be_valid, match_whole_string, assert (pat != NULL); r = re_compile_pattern (pat, strlen (pat), &nonconst_buf); - + /* Kludge: if we are doing POSIX testing, we really should have called regcomp, not re_compile_pattern. As it happens, the only way in which it matters is that re_compile_pattern sets the @@ -156,7 +156,7 @@ general_test (pattern_should_be_valid, match_whole_string, matching. */ if (t == posix_basic_test || t == posix_extended_test) nonconst_buf.newline_anchor = 0; - + invalid_pattern = r != NULL; if (!r) @@ -168,27 +168,27 @@ general_test (pattern_should_be_valid, match_whole_string, else { fastmap_internal_error = (re_compile_fastmap (&nonconst_buf) == -2); - + if (correct_fastmap) - nonconst_buf.fastmap_accurate = + nonconst_buf.fastmap_accurate = memcmp (nonconst_buf.fastmap, correct_fastmap, 1 << BYTEWIDTH) == 0; - + if (OK_TO_SEARCH) { old_buf = nonconst_buf; old_buf.buffer = (unsigned char *) xmalloc (nonconst_buf.used); memcpy (old_buf.buffer, nonconst_buf.buffer, nonconst_buf.used); - + /* If only one string is null, call re_match or re_search, - which is what the user would probably do. */ + which is what the user would probably do. */ if (str1 == NULL && str2 != NULL || str2 == NULL && str1 != NULL) { char *the_str = str1 == NULL ? str2 : str1; - + match_1 - = match_whole_string + = match_whole_string ? (r = re_match (&nonconst_buf, the_str, strlen (the_str), start, ®s)) == strlen (the_str) @@ -200,16 +200,16 @@ general_test (pattern_should_be_valid, match_whole_string, if (r == -2) internal_error_1 = true; } - else + else match_1 = 1; - + /* Also call with re_match_2 or re_search_2, as they might do this. (Also can check calling with either string1 or string2 or both null.) */ if (match_whole_string) { r = re_match_2 (&nonconst_buf, - str1, SAFE_STRLEN (str1), + str1, SAFE_STRLEN (str1), str2, SAFE_STRLEN (str2), start, ®s, end); match_2 = r == SAFE_STRLEN (str1) + SAFE_STRLEN (str2); @@ -217,7 +217,7 @@ general_test (pattern_should_be_valid, match_whole_string, else { r = re_search_2 (&nonconst_buf, - str1, SAFE_STRLEN (str1), + str1, SAFE_STRLEN (str1), str2, SAFE_STRLEN (str2), start, range, ®s, end); match_2 = r >= 0; @@ -225,16 +225,16 @@ general_test (pattern_should_be_valid, match_whole_string, if (r == -2) internal_error_2 = true; - + match = match_1 & match_2; - + if (correct_regs) { unsigned reg; if (regs_correct != NULL) free (regs_correct); - - regs_correct + + regs_correct = (unsigned *) xmalloc (regs.num_regs * sizeof (unsigned)); for (reg = 0; @@ -256,9 +256,9 @@ general_test (pattern_should_be_valid, match_whole_string, || (regs.start[reg] == -1 && regs.end[reg] == -1 && correct_regs->start[reg] == correct_regs->end[reg]) -#endif +#endif ; - + all_regs_correct &= regs_correct[reg]; } } @@ -268,15 +268,15 @@ general_test (pattern_should_be_valid, match_whole_string, if (fastmap_internal_error) printf ("\n\nInternal error in re_compile_fastmap:"); - + if (internal_error_1) { if (!fastmap_internal_error) printf ("\n"); - + printf ("\nInternal error in re_match or re_search:"); } - + if (internal_error_2) { if (!internal_error_1) @@ -285,11 +285,11 @@ general_test (pattern_should_be_valid, match_whole_string, printf ("\nInternal error in re_match_2 or re_search_2:"); } - if ((OK_TO_SEARCH && ((match && !test_should_match) + if ((OK_TO_SEARCH && ((match && !test_should_match) || (!match && test_should_match)) || (correct_regs && !all_regs_correct)) || !nonconst_buf.fastmap_accurate - || invalid_pattern + || invalid_pattern || !pattern_should_be_valid || internal_error_1 || internal_error_2 || verbose) @@ -324,8 +324,8 @@ general_test (pattern_should_be_valid, match_whole_string, if ((!(invalid_pattern && !pattern_should_be_valid)) || verbose) printf (" Pattern: `%s'.\n", pat); - - if (pattern_should_be_valid || verbose + + if (pattern_should_be_valid || verbose || internal_error_1 || internal_error_2) { printf(" Strings: "); @@ -335,7 +335,7 @@ general_test (pattern_should_be_valid, match_whole_string, if ((OK_TO_SEARCH || verbose || internal_error_1 || internal_error_2) && !invalid_pattern) { - if (memcmp (old_buf.buffer, nonconst_buf.buffer, + if (memcmp (old_buf.buffer, nonconst_buf.buffer, nonconst_buf.used) != 0 && !invalid_pattern) { @@ -346,16 +346,16 @@ general_test (pattern_should_be_valid, match_whole_string, } else printf ("\n Compiled pattern: "); - + print_compiled_pattern (&nonconst_buf); } if (correct_fastmap && (!nonconst_buf.fastmap_accurate || verbose)) { - printf ("\n The fastmap should have been: "); + printf ("\n The fastmap should have been: "); print_fastmap (correct_fastmap); - printf ("\n Fastmap: "); + printf ("\n Fastmap: "); print_fastmap (fastmap); printf ("\n Compiled pattern before matching: "); @@ -366,25 +366,25 @@ general_test (pattern_should_be_valid, match_whole_string, { unsigned this_reg; printf ("\n Incorrect registers:"); - + for (this_reg = 0; this_reg < regs.num_regs; this_reg++) { if (!regs_correct[this_reg]) { printf ("\n Register %d's start was %2d. ", this_reg, regs.start[this_reg]); - printf ("\tIt should have been %d.\n", + printf ("\tIt should have been %d.\n", correct_regs->start[this_reg]); printf (" Register %d's end was %2d. ", this_reg, regs.end[this_reg]); - printf ("\tIt should have been %d.\n", + printf ("\tIt should have been %d.\n", correct_regs->end[this_reg]); } } } } } - + if (nonconst_buf.buffer != NULL) free (nonconst_buf.buffer); @@ -396,7 +396,7 @@ general_test (pattern_should_be_valid, match_whole_string, free (regs_correct); } - + nonconst_buf.buffer = old_buf.buffer = NULL; regs_correct = NULL; regs.start = regs.end = NULL; @@ -419,17 +419,17 @@ test_search_return (match_start_wanted, pattern, string) num_times_called++; buf.allocated = 1; buf.buffer = xmalloc (buf.allocated); - + assert (pattern != NULL); buf.translate = 0; compile_return = re_compile_pattern (pattern, strlen (pattern), &buf); - + if (compile_return) { printf ("\n\nInvalid pattern in test_match_start:\n"); printf ("%s\n", compile_return); } - else + else { buf.fastmap = fastmap; match_start = re_search (&buf, string, strlen (string), @@ -453,8 +453,8 @@ test_search_return (match_start_wanted, pattern, string) for (this_char = 0; this_char < strlen (fastmap_string); this_char++)\ correct_fastmap[fastmap_string[this_char]] = !invert; \ correct_fastmap['\n'] = match_newline; \ - } - + } + void test_fastmap (pat, fastmap_string, invert, match_newline) @@ -463,7 +463,7 @@ test_fastmap (pat, fastmap_string, invert, match_newline) unsigned invert; unsigned match_newline; { - char correct_fastmap[(1 << BYTEWIDTH)]; + char correct_fastmap[(1 << BYTEWIDTH)]; SET_FASTMAP (); general_test (1, 0, pat, NULL, NULL, -1, 0, -1, correct_fastmap, 0, -1); @@ -471,25 +471,25 @@ test_fastmap (pat, fastmap_string, invert, match_newline) void -test_fastmap_search (pat, str, fastmap_string, invert, match_newline, +test_fastmap_search (pat, str, fastmap_string, invert, match_newline, can_be_null, start0, end0) - const char *pat; - char *str; + const char *pat; + char *str; char *fastmap_string; - unsigned invert; - unsigned match_newline; - int can_be_null; - int start0; + unsigned invert; + unsigned match_newline; + int can_be_null; + int start0; int end0; { - char correct_fastmap[(1 << BYTEWIDTH)]; + char correct_fastmap[(1 << BYTEWIDTH)]; struct re_registers correct_regs; correct_regs.num_regs = RE_NREGS; correct_regs.start = (int *) xmalloc (RE_NREGS * sizeof (int)); correct_regs.end = (int *) xmalloc (RE_NREGS * sizeof (int)); - - set_all_registers (start0, end0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + + set_all_registers (start0, end0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, &correct_regs); SET_FASTMAP (); general_test (1, 0, pat, str, NULL, 0, SAFE_STRLEN (str), SAFE_STRLEN (str), @@ -503,34 +503,34 @@ test_fastmap_search (pat, str, fastmap_string, invert, match_newline, void -test_all_registers (pat, str1, str2, - start0, end0, start1, end1, - start2, end2, start3, end3, - start4, end4, start5, end5, - start6, end6, start7, end7, +test_all_registers (pat, str1, str2, + start0, end0, start1, end1, + start2, end2, start3, end3, + start4, end4, start5, end5, + start6, end6, start7, end7, start8, end8, start9, end9) - char *pat; char *str1; char *str2; - int start0; int end0; int start1; int end1; - int start2; int end2; int start3; int end3; - int start4; int end4; int start5; int end5; - int start6; int end6; int start7; int end7; + char *pat; char *str1; char *str2; + int start0; int end0; int start1; int end1; + int start2; int end2; int start3; int end3; + int start4; int end4; int start5; int end5; + int start6; int end6; int start7; int end7; int start8; int end8; int start9; int end9; { struct re_registers correct_regs; - + if (omit_register_tests) return; - + correct_regs.num_regs = RE_NREGS; correct_regs.start = (int *) xmalloc (RE_NREGS * sizeof (int)); correct_regs.end = (int *) xmalloc (RE_NREGS * sizeof (int)); - set_all_registers (start0, end0, start1, end1, start2, end2, start3, end3, - start4, end4, start5, end5, start6, end6, start7, end7, + set_all_registers (start0, end0, start1, end1, start2, end2, start3, end3, + start4, end4, start5, end5, start6, end6, start7, end7, start8, end8, start9, end9, &correct_regs); - general_test (1, 0, pat, str1, str2, 0, - SAFE_STRLEN (str1) + SAFE_STRLEN (str2), - SAFE_STRLEN (str1) + SAFE_STRLEN (str2), + general_test (1, 0, pat, str1, str2, 0, + SAFE_STRLEN (str1) + SAFE_STRLEN (str2), + SAFE_STRLEN (str1) + SAFE_STRLEN (str2), NULL, &correct_regs, -1); free (correct_regs.start); @@ -547,8 +547,8 @@ invalid_pattern (error_code_expected, pattern) int cflags = re_syntax_options == RE_SYNTAX_POSIX_EXTENDED || re_syntax_options == RE_SYNTAX_POSIX_MINIMAL_EXTENDED - ? REG_EXTENDED : 0; - + ? REG_EXTENDED : 0; + test_compile (0, error_code_expected, pattern, &pattern_buffer, cflags); } @@ -561,8 +561,8 @@ valid_pattern (pattern) int cflags = re_syntax_options == RE_SYNTAX_POSIX_EXTENDED || re_syntax_options == RE_SYNTAX_POSIX_MINIMAL_EXTENDED - ? REG_EXTENDED : 0; - + ? REG_EXTENDED : 0; + test_compile (1, 0, pattern, &pattern_buffer, cflags); } @@ -578,7 +578,7 @@ delimiters_to_ops (source, left_delimiter, right_delimiter) boolean double_size = false; unsigned source_char; unsigned answer_char = 0; - + assert (source != NULL); switch (left_delimiter) @@ -608,7 +608,7 @@ delimiters_to_ops (source, left_delimiter, right_delimiter) answer = NULL; } - answer = (char *) xmalloc ((double_size + answer = (char *) xmalloc ((double_size ? strlen (source) << 1 : strlen (source)) + 1); @@ -618,7 +618,7 @@ delimiters_to_ops (source, left_delimiter, right_delimiter) { for (source_char = 0; source_char < strlen (source); source_char++) { - if (source[source_char] == left_delimiter + if (source[source_char] == left_delimiter || source[source_char] == right_delimiter) answer[answer_char++] = '\\'; @@ -626,14 +626,14 @@ delimiters_to_ops (source, left_delimiter, right_delimiter) } answer[answer_char] = 0; } - + return answer; } void print_pattern_info (pattern, pattern_buffer_ptr) - const char *pattern; + const char *pattern; regex_t *pattern_buffer_ptr; { printf (" Pattern: `%s'.\n", pattern); @@ -647,13 +647,13 @@ valid_nonposix_pattern (pattern) char *pattern; { struct re_pattern_buffer nonconst_buf; - + nonconst_buf.allocated = 0; nonconst_buf.buffer = NULL; nonconst_buf.translate = NULL; - + assert (pattern != NULL); - + if (re_compile_pattern (pattern, strlen (pattern), &nonconst_buf)) { printf ("Couldn't compile the pattern.\n"); @@ -667,13 +667,13 @@ compile_and_print_pattern (pattern) char *pattern; { struct re_pattern_buffer nonconst_buf; - + nonconst_buf.allocated = 0; nonconst_buf.buffer = NULL; - + if (re_compile_pattern (pattern, strlen (pattern), &nonconst_buf)) printf ("Couldn't compile the pattern.\n"); - + print_pattern_info (pattern, &nonconst_buf); } @@ -691,7 +691,7 @@ test_case_fold (pattern, string) assert (pattern != NULL); ret = re_compile_pattern (pattern, strlen (pattern), &nonconst_buf); - + if (ret) { printf ("\nShould have been a valid pattern but wasn't.\n"); @@ -699,8 +699,8 @@ test_case_fold (pattern, string) } else { - if (test_should_match - && re_match (&nonconst_buf, string, strlen (string), 0, 0) + if (test_should_match + && re_match (&nonconst_buf, string, strlen (string), 0, 0) != strlen (string)) { printf ("Match failed for case fold.\n"); @@ -727,7 +727,7 @@ test_match_n_times (n, pattern, string) buf.translate = 0; assert (pattern != NULL); - + r = re_compile_pattern (pattern, strlen (pattern), &buf); if (r) { @@ -738,14 +738,14 @@ test_match_n_times (n, pattern, string) { for (this_match = 1; this_match <= n; this_match++) match = (re_match (&buf, string, strlen (string), - 0, 0) + 0, 0) == strlen (string)); if (match && !test_should_match) printf ("\n\nMatched but shouldn't have:\n"); else if (!match && test_should_match) printf ("\n\nDidn't match but should have:\n"); - + if ((match && !test_should_match) || (!match && test_should_match)) { printf(" The string to match was: "); @@ -753,7 +753,7 @@ test_match_n_times (n, pattern, string) printf ("`%s' and ", string); else printf ("`'"); - + printf (" Pattern: %s.\n", pattern); printf (" Compiled pattern: %s.\n", pattern); print_compiled_pattern (&buf); @@ -762,17 +762,17 @@ test_match_n_times (n, pattern, string) } -void +void test_match_2 (pat, str1, str2) - const char *pat; - char *str1; + const char *pat; + char *str1; char *str2; { general_test (1, 1, pat, str1, str2, 0, 1, SAFE_STRLEN (str1) + SAFE_STRLEN (str2), NULL, 0, -1); } -void +void test_match (pat, str) const char *pat; char *str; diff --git a/gnu/lib/libregex/test/test.h b/gnu/lib/libregex/test/test.h index fb67126..e367c93 100644 --- a/gnu/lib/libregex/test/test.h +++ b/gnu/lib/libregex/test/test.h @@ -39,21 +39,21 @@ extern test_type t; extern char *concat (char *, char *); -extern void general_test (unsigned pattern_should_be_valid, +extern void general_test (unsigned pattern_should_be_valid, unsigned match_whole_string, const char *pat, char *str1, char *str2, - int start, int range, int end, - char *correct_fastmap, + int start, int range, int end, + char *correct_fastmap, struct re_registers *correct_regs, int can_be_null); extern void init_pattern_buffer (regex_t *pattern_buffer_ptr); -extern void test_compile (unsigned valid_pattern, int error_code_expected, +extern void test_compile (unsigned valid_pattern, int error_code_expected, const char *pattern, regex_t *pattern_buffer_ptr, int cflags); -extern char *delimiter_to_ops (char *source, char left_delimiter, +extern char *delimiter_to_ops (char *source, char left_delimiter, char right_delimiter); @@ -61,18 +61,18 @@ extern void test_search_return (int, const char *, char *); extern void test_berk_search (const char *pattern, char *string); -extern void test_fastmap (const char *pat, char *fastmap_string, unsigned invert, +extern void test_fastmap (const char *pat, char *fastmap_string, unsigned invert, unsigned match_newline); extern void test_fastmap_search (const char *pat, char *str, char *fastmap_string, - unsigned invert, unsigned match_newline, + unsigned invert, unsigned match_newline, int can_be_null, int start0, int end0); -extern void test_all_registers (char *pat, char *str1, char *str2, - int start0, int end0, int start1, int end1, - int start2, int end2, int start3, int end3, - int start4, int end4, int start5, int end5, - int start6, int end6, int start7, int end7, +extern void test_all_registers (char *pat, char *str1, char *str2, + int start0, int end0, int start1, int end1, + int start2, int end2, int start3, int end3, + int start4, int end4, int start5, int end5, + int start6, int end6, int start7, int end7, int start8, int end8, int start9, int end9); extern void print_pattern_info (const char *pattern, regex_t *pattern_buffer_ptr); diff --git a/gnu/lib/libregex/test/tregress.c b/gnu/lib/libregex/test/tregress.c index 7858cac..b6aa560 100644 --- a/gnu/lib/libregex/test/tregress.c +++ b/gnu/lib/libregex/test/tregress.c @@ -11,7 +11,7 @@ itoa (i) int i; { char *a = xmalloc (21); /* sign + 19 digits (enough for 64 bits) + null */ - + sprintf (a, "%d", i); return a; } @@ -29,7 +29,7 @@ simple_fail (routine, pat, buf, str, ret) if (str && *str) fprintf (stderr, " String = %s\n", str); fprintf (stderr, " Pattern = %s\n", pat); print_compiled_pattern (buf); - + if (pause_at_error) { fprintf (stderr, "RET to continue: "); @@ -46,7 +46,7 @@ simple_compile (pat, buf) struct re_pattern_buffer *buf; { const char *ret = re_compile_pattern (pat, strlen (pat), buf); - + if (ret != NULL) simple_fail ("compile", pat, buf, NULL, ret); } @@ -58,13 +58,13 @@ simple_fastmap (pat) struct re_pattern_buffer buf; char fastmap[256]; int ret; - + buf.allocated = 0; buf.buffer = buf.translate = NULL; buf.fastmap = fastmap; - + simple_compile (pat, &buf); - + ret = re_compile_fastmap (&buf); if (ret != 0) simple_fail ("fastmap compile", pat, &buf, NULL, itoa (ret)); @@ -85,13 +85,13 @@ do_match (pat, str, expected) buf.allocated = 0; buf.buffer = buf.translate = buf.fastmap = NULL; - + simple_compile (pat, &buf); len = strlen (str); - + ret = re_match_2 (&buf, NULL, 0, str, len, 0, NULL, len); - + if (ret != expected) simple_fail ("match", pat, &buf, str, itoa (ret)); } @@ -107,13 +107,13 @@ simple_search (pat, str, correct_startpos) buf.allocated = 0; buf.buffer = buf.translate = buf.fastmap = NULL; - + simple_compile (pat, &buf); len = strlen (str); - + ret = re_search_2 (&buf, NULL, 0, str, len, 0, len, NULL, len); - + if (ret != correct_startpos) simple_fail ("match", pat, &buf, str, itoa (ret)); } @@ -128,8 +128,8 @@ test_regress () unsigned len; struct re_registers regs; int ret; - char *fastmap = xmalloc (256); - + char *fastmap = xmalloc (256); + buf.translate = NULL; buf.fastmap = NULL; buf.allocated = 0; @@ -145,10 +145,10 @@ test_regress () buf.translate = upcase; SIMPLE_MATCH ("[A-[]", "A"); buf.translate = NULL; - + /* meyering@cs.utexas.edu Nov 6 22:34:41 1992 */ simple_search ("\\w+", "a", 0); - + /* jimb@occs.cs.oberlin.edu 10 Sep 92 00:42:33 */ buf.translate = upcase; SIMPLE_MATCH ("[\001-\377]", "\001"); @@ -158,13 +158,13 @@ test_regress () /* mike@skinner.cs.uoregon.edu 1 Sep 92 01:45:22 */ SIMPLE_MATCH ("^^$", "^"); - + /* pclink@qld.tne.oz.au Sep 7 22:42:36 1992 */ re_set_syntax (RE_INTERVALS); SIMPLE_MATCH ("^a\\{3\\}$", "aaa"); SIMPLE_NONMATCH ("^a\\{3\\}$", "aa"); re_set_syntax (RE_SYNTAX_EMACS); - + /* pclink@qld.tne.oz.au, 31 Aug 92. (conjecture) */ re_set_syntax (RE_INTERVALS); simple_search ("a\\{1,3\\}b", "aaab", 0); @@ -173,14 +173,14 @@ test_regress () /* trq@dionysos.thphys.ox.ac.uk, 31 Aug 92. (simplified) */ simple_fastmap ("^.*\n[ ]*"); - + /* wind!greg@plains.NoDak.edu, 25 Aug 92. (simplified) */ re_set_syntax (RE_INTERVALS); SIMPLE_MATCH ("[a-zA-Z]*.\\{5\\}", "xN0000"); SIMPLE_MATCH ("[a-zA-Z]*.\\{5\\}$", "systemxN0000"); SIMPLE_MATCH ("\\([a-zA-Z]*\\).\\{5\\}$", "systemxN0000"); re_set_syntax (RE_SYNTAX_EMACS); - + /* jimb, 18 Aug 92. Don't use \000, so `strlen' (in our testing routines) will work. (This still tickles the bug jimb reported.) */ SIMPLE_MATCH ("[\001-\377]", "\001"); @@ -307,7 +307,7 @@ test_regress () /* jla's bug (with string-match), 5 Feb 92. */ TEST_SEARCH ("\\`[ \t\n]*", "jla@challenger (Joseph Arceneaux)", 0, 100); - + /* jwz@lucid.com, 8 March 1992 (re-search-forward). (His is the second.) These are not supposed to match. */ #if 0 @@ -335,7 +335,7 @@ References: <9203080736.AA05869@thalidomide.lucid>\n\ <9203081900.AA24794@titanic.lucid>", 0, 5000); #endif /* 0 [failed searches] */ - + /* macrakis' bugs. */ buf.translate = upcase; /* message of 24 Jan 91 */ if (re_compile_pattern ("[!-`]", 5, &buf) != NULL) @@ -355,7 +355,7 @@ References: <9203080736.AA05869@thalidomide.lucid>\n\ printf ("faofdx test, reg #1 wrong.\n"); if (regs.start[2] != 1 || regs.end[2] != 2) printf ("faofdx test, reg #2 wrong.\n"); - + TEST_REGISTERS ("\\(a\\)*a", "aaa", 0, 3, 1, 2, -1, -1); test_fastmap ("^\\([^ \n]+:\n\\)+\\([^ \n]+:\\)", " \n", 1, 0); @@ -412,7 +412,7 @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:"); /* Dave G. bug: Reference to a subexpression which didn't match. Should fail. */ re_set_syntax (RE_NO_BK_PARENS | RE_NO_BK_VBAR); - test_match ("(ooooooooooone())-annnnnnnnnnnd-(twooooooooooo\\2)", + test_match ("(ooooooooooone())-annnnnnnnnnnd-(twooooooooooo\\2)", "ooooooooooone-annnnnnnnnnnd-twooooooooooo"); test_match ("(o|t)", "o"); test_match ("(o()|t)", "o"); @@ -424,23 +424,23 @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:"); test_match ("(o()|t())-a-(t\\2|f\\3)", "o-a-t"); test_match ("(o()|t())-a-(t\\2|f\\3)", "t-a-f"); - test_should_match = 0; + test_should_match = 0; test_match ("(foo(bar)|second)\\2", "second"); test_match ("(o()|t())-a-(t\\2|f\\3)", "t-a-t"); test_match ("(o()|t())-a-(t\\2|f\\3)", "o-a-f"); re_set_syntax (RE_SYNTAX_EMACS); test_match ("\\(foo\\(bar\\)\\|second\\)\\2", "secondbar"); - test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)", + test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)", "one-and-four"); - test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)", + test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)", "two-and-three"); - + test_should_match = 1; re_set_syntax (RE_SYNTAX_EMACS); - test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)", + test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)", "one-and-three"); - test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)", + test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)", "two-and-four"); TEST_REGISTERS (":\\(.*\\)", ":/", 0, 2, 1, 2, -1, -1); diff --git a/gnu/lib/libregex/test/upcase.c b/gnu/lib/libregex/test/upcase.c index 5147b81..a3c0fbc 100644 --- a/gnu/lib/libregex/test/upcase.c +++ b/gnu/lib/libregex/test/upcase.c @@ -1,7 +1,7 @@ /* Indexed by a character, gives the upper case equivalent of the character. */ -char upcase[0400] = +char upcase[0400] = { 000, 001, 002, 003, 004, 005, 006, 007, 010, 011, 012, 013, 014, 015, 016, 017, 020, 021, 022, 023, 024, 025, 026, 027, diff --git a/gnu/lib/libregex/test/xmalloc.c b/gnu/lib/libregex/test/xmalloc.c index 88be1a6..aa1c6c4 100644 --- a/gnu/lib/libregex/test/xmalloc.c +++ b/gnu/lib/libregex/test/xmalloc.c @@ -9,8 +9,8 @@ void * xmalloc (size) unsigned size; { - char *new_mem = malloc (size); - + char *new_mem = malloc (size); + if (new_mem == NULL) { fprintf (stderr, "xmalloc: request for %u bytes failed.\n", size); |