glibc/posix/runtests.c
Ulrich Drepper 701666b77d * nss/nsswitch.c (__nss_lookup_function): Don't cast &ni->known to
void **.
	* nss/nsswitch.h (service_user): Use void * type for KNOWN field.

	* nss/nss_files/files-hosts.c (LINE_PARSER): Cast host_addr to
	char * to avoid warning.
	* nis/nss_nis/nis-hosts.c (LINE_PARSER): Likewise.

	* timezone/Makefile (CFLAGS-zdump.c): Add -fwrapv.

	* locale/programs/ld-ctype.c (ctype_finish, set_class_defaults,
	allocate_arrays): Cast second argument to charmap_find_symbol
	to char * to avoid warnings.

	* locale/programs/repertoire.c (repertoire_new_char): Change
	from_nr, to_nr and cnt to unsigned long, adjust printf format
	string.

	* locale/programs/ld-collate.c (insert_value, handle_ellipsis):
	Cast second argument to new_element to char * to avoid warnings.

	* locale/weightwc.h (findidx): Cast &extra[-i] to const int32_t *.

	* intl/gettextP.h (struct loaded_domain): Change plural to const
	struct expression *.
	* intl/plural-eval.c (plural_eval): Change first argument to
	const struct expression *.
	* intl/plural-exp.c (EXTRACT_PLURAL_EXPRESSION): Change first
	argument to const struct expression **.
	* intl/plural-exp.h (EXTRACT_PLURAL_EXPRESSION, plural_eval): Adjust
	prototypes.
	* intl/loadmsgcat (_nl_unload_domain): Cast away const
	in call to __gettext_free_exp.

	* posix/fnmatch.c (fnmatch): Rearrange code to avoid maybe
	unitialized wstring/wpattern var warnings.

	* posix/runtests.c (struct a_test): Make data field const char *.

	* stdio-common/tst-sprintf2.c (main): Don't declere u, v and buf
	vars if not LDBL_MANT_DIG >= 106.

	* stdio-common/Makefile (CFLAGS-vfwprintf.c): Add -Wno-unitialized.

	* stdio-common/vfprintf.c (vfprintf): Cast first arugment to
	__find_specmb to avoid warning.

	* rt/tst-mqueue1.c (do_one_test): Add casts to avoid warnings.

	* debug/test-strcpy_chk.c (do_tests, do_random_tests): Add casts
	to avoid warnings.

	* sysdeps/ieee754/ldbl-96/s_roundl.c (huge): Add L suffix to
	initializer.

	* sysdeps/unix/clock_gettime.c (clock_gettime): Only define
	tv var when it will be actually used.

	* sunrpc/rpc_cmsg.c (xdr_callmsg): Cast IXDR_PUT_* to void
	to avoid warnings.
2007-07-28 20:36:21 +00:00

139 lines
2.9 KiB
C
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/***********************************************************
Copyright 1995 by Tom Lord
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of the copyright holder not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
Tom Lord DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
EVENT SHALL TOM LORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
#include <sys/types.h>
#include <regex.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct a_test
{
int expected;
const char * pattern;
const char * data;
};
static const struct a_test the_tests[] =
{
#include "testcases.h"
{-1, 0, 0}
};
static int
run_a_test (int id, const struct a_test * t)
{
static const char * last_pattern = 0;
static regex_t r;
int err;
char errmsg[100];
int x;
regmatch_t regs[10];
if (!last_pattern || strcmp (last_pattern, t->pattern))
{
if (last_pattern)
regfree (&r);
last_pattern = t->pattern;
err = regcomp (&r, t->pattern, REG_EXTENDED);
if (err)
{
if (t->expected == 2)
{
puts (" OK.");
return 0;
}
if (last_pattern)
regfree (&r);
last_pattern = NULL;
regerror (err, &r, errmsg, 100);
printf (" FAIL: %s.\n", errmsg);
return 1;
}
else if (t->expected == 2)
{
printf ("test %d\n", id);
printf ("pattern \"%s\" successfull compilation not expected\n",
t->pattern);
return 1;
}
}
err = regexec (&r, t->data, 10, regs, 0);
if (err != t->expected)
{
printf ("test %d\n", id);
printf ("pattern \"%s\" data \"%s\" wanted %d got %d\n",
t->pattern, t->data, t->expected, err);
for (x = 0; x < 10; ++x)
printf ("reg %d == (%d, %d) %.*s\n",
x,
regs[x].rm_so,
regs[x].rm_eo,
regs[x].rm_eo - regs[x].rm_so,
t->data + regs[x].rm_so);
return 1;
}
puts (" OK.");
return 0;
}
int
main (int argc, char * argv[])
{
int x;
int lo;
int hi;
int res = 0;
lo = 0;
hi = (sizeof (the_tests) / sizeof (the_tests[0])) - 1;
if (argc > 1)
{
lo = atoi (argv[1]);
hi = lo + 1;
if (argc > 2)
hi = atoi (argv[2]);
}
for (x = lo; x < hi; ++x)
{
printf ("#%d:", x);
res |= run_a_test (x, &the_tests[x]);
}
return res != 0;
}