This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

str-two-way.h cleanup


this patch is a cleanup of string/str-two-way.h.

- fixes a typo in a macro name in the header comment
- adds 2 macros to a macro list in the header comment
- removes 3 superfluous undefines at the end of the file
- adds one missing undefine at the end of the file

I haven't build or tested this, but I checked that str-two-way.h is only used in
3 source files in the string dir:
$ find -type f | egrep -v '\.patch|ChangeLog|\.git' | xargs grep str-two-way.h
./string/strcasestr.c:#include "str-two-way.h"
./string/strstr.c:#include "str-two-way.h"
./string/memmem.c:#include "str-two-way.h"

I've grepped in those files (and the header file) for AVAILABLE1 and AVAILABLE2:
$ egrep 'AVAILABLE1|AVAILABLE2' string/*.c string/str-two-way.h
string/str-two-way.h:#undef AVAILABLE1
string/str-two-way.h:#undef AVAILABLE2
string/str-two-way.h:#undef AVAILABLE1_USES_J
and the only hits where the undefs, so that justifies the removal of those undefs.

And I've grepped in those files for CHECK_EOL:
$ egrep 'CHECK_EOL|str-two-way.h' string/*.c
string/memmem.c:#include "str-two-way.h"
string/strcasestr.c:#define CHECK_EOL (1)
string/strcasestr.c:#include "str-two-way.h"
string/strstr.c:#define CHECK_EOL (1)
string/strstr.c:#include "str-two-way.h"
and only found the defines in front of the include of str-two-way.h. That
justifies the addition of the undef of CHECK_EOL.

I'll build and test this somewhere in the coming weeks.

Does this patch look ok?

- Tom
2013-02-07  Tom de Vries  <>

	* string/str-two-way.h:  Fix typo RESULT_TYPE -> RETURN_TYPE in comment.
	Add RET0_IF_0 and CHECK_EOL to macro list in comment.
	(AVAILABLE1, AVAILABLE2, AVAILABLE1_USES_J): Remove superfluous undef.
	(CHECK_EOL): Add undef.

diff --git a/string/str-two-way.h b/string/str-two-way.h
index 8912f24..1cc20ee 100644
--- a/string/str-two-way.h
+++ b/string/str-two-way.h
@@ -19,7 +19,7 @@
 /* Before including this file, you need to include <string.h> (and
    <config.h> before that, if not part of libc), and define:
-     RESULT_TYPE             A macro that expands to the return type.
+     RETURN_TYPE             A macro that expands to the return type.
      AVAILABLE(h, h_l, j, n_l)
 			     A macro that returns nonzero if there are
 			     at least N_L bytes left starting at H[J].
@@ -37,7 +37,11 @@
 			     The argument is an 'unsigned char'; the result
 			     must be an 'unsigned char' as well.
-  This file undefines the macros documented above, and defines
+  Other macros you may optionally define:
+     RET0_IF_0(a)            Documented below at default definition.
+     CHECK_EOL               Same.
+  This file undefines the macros listed above, and defines
@@ -516,10 +520,8 @@ two_way_long_needle (const unsigned char *haystack, size_t haystack_len,
-#undef AVAILABLE1
-#undef AVAILABLE2
 #undef CMP_FUNC
 #undef RET0_IF_0
+#undef CHECK_EOL

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]