Module Name:    src
Committed By:   dsl
Date:           Fri Jul 17 22:07:36 UTC 2009

Modified Files:
        src/regress/lib/libc/string/strchr: strchr_test.c

Log Message:
Pollute the space either side of the string being compared with the test
pattern.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/regress/lib/libc/string/strchr/strchr_test.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/regress/lib/libc/string/strchr/strchr_test.c
diff -u src/regress/lib/libc/string/strchr/strchr_test.c:1.1 src/regress/lib/libc/string/strchr/strchr_test.c:1.2
--- src/regress/lib/libc/string/strchr/strchr_test.c:1.1	Tue Mar 15 15:57:58 2005
+++ src/regress/lib/libc/string/strchr/strchr_test.c	Fri Jul 17 22:07:36 2009
@@ -29,14 +29,15 @@
 #include <assert.h>
 #include <string.h>
 
+extern char *xstrchr(const char *, int);
 void check_strchr(void);
 
+/* try to trick the compiler */
+char * (*volatile f)((const char *, int);
+
 void
 check_strchr(void)
 {
-    /* try to trick the compiler */
-    char * (*f)(const char *, int) = strchr;
-    
     int a;
     int t;
     char* off;
@@ -234,8 +235,16 @@
 
 
     for (a = 0; a < sizeof(long); ++a) {
+	if (a >= 2) {
+		/* Put char and a \0 before the buffer */
+		buf[a-1] = '/';
+		buf[a-2] = '0';
+	}
 	for (t = 0; t < (sizeof(tab) / sizeof(tab[0])); ++t) {
-	    strcpy(&buf[a], tab[t].val);
+	    int len = strlen(tab[t].val) + 1;
+	    memcpy(&buf[a], tab[t].val, len);
+	    /* Put the char we are looking for after the \0 */
+	    buf[a + len] = '/';
 	    
 	    off = f(&buf[a], '/');
 	    assert((tab[t].match == 0 && off == 0) ||
@@ -252,6 +261,7 @@
 int
 main(void)
 {
+	f = strchr;
 	check_strchr();
 	return 0;
 }

Reply via email to