Peter Miller wrote: > yes, I was missing something subtle. > The attached patch adds comments to explain it to me.
Thanks for suggesting this. Comments about a functions calling convention should be at the function's definition, not where it is called, therefore I'm applying this: 2008-01-08 Bruno Haible <[EMAIL PROTECTED]> * lib/str-kmp.h (knuth_morris_pratt_unibyte): Document the calling convention better. * lib/mbsstr.c (knuth_morris_pratt_multibyte): Likewise. * lib/mbscasestr.c (knuth_morris_pratt_multibyte): Likewise. Reported by Peter Miller <[EMAIL PROTECTED]>. *** lib/str-kmp.h.orig 2008-01-08 23:53:17.000000000 +0100 --- lib/str-kmp.h 2008-01-08 23:50:23.000000000 +0100 *************** *** 1,6 **** /* Substring search in a NUL terminated string of 'char' elements, using the Knuth-Morris-Pratt algorithm. ! Copyright (C) 2005-2007 Free Software Foundation, Inc. Written by Bruno Haible <[EMAIL PROTECTED]>, 2005. This program is free software; you can redistribute it and/or modify --- 1,6 ---- /* Substring search in a NUL terminated string of 'char' elements, using the Knuth-Morris-Pratt algorithm. ! Copyright (C) 2005-2008 Free Software Foundation, Inc. Written by Bruno Haible <[EMAIL PROTECTED]>, 2005. This program is free software; you can redistribute it and/or modify *************** *** 25,31 **** /* Knuth-Morris-Pratt algorithm. See http://en.wikipedia.org/wiki/Knuth-Morris-Pratt_algorithm ! Return a boolean indicating success. */ static bool knuth_morris_pratt_unibyte (const char *haystack, const char *needle, const char **resultp) --- 25,33 ---- /* Knuth-Morris-Pratt algorithm. See http://en.wikipedia.org/wiki/Knuth-Morris-Pratt_algorithm ! Return a boolean indicating success: ! Return true and set *RESULTP if the search was completed. ! Return false if it was aborted because not enough memory was available. */ static bool knuth_morris_pratt_unibyte (const char *haystack, const char *needle, const char **resultp) *** lib/mbscasestr.c.orig 2008-01-08 23:53:16.000000000 +0100 --- lib/mbscasestr.c 2008-01-08 23:50:23.000000000 +0100 *************** *** 1,5 **** /* Case-insensitive searching in a string. ! Copyright (C) 2005-2007 Free Software Foundation, Inc. Written by Bruno Haible <[EMAIL PROTECTED]>, 2005. This program is free software: you can redistribute it and/or modify --- 1,5 ---- /* Case-insensitive searching in a string. ! Copyright (C) 2005-2008 Free Software Foundation, Inc. Written by Bruno Haible <[EMAIL PROTECTED]>, 2005. This program is free software: you can redistribute it and/or modify *************** *** 38,44 **** #if HAVE_MBRTOWC /* Knuth-Morris-Pratt algorithm. See http://en.wikipedia.org/wiki/Knuth-Morris-Pratt_algorithm ! Return a boolean indicating success. */ static bool knuth_morris_pratt_multibyte (const char *haystack, const char *needle, const char **resultp) --- 38,46 ---- #if HAVE_MBRTOWC /* Knuth-Morris-Pratt algorithm. See http://en.wikipedia.org/wiki/Knuth-Morris-Pratt_algorithm ! Return a boolean indicating success: ! Return true and set *RESULTP if the search was completed. ! Return false if it was aborted because not enough memory was available. */ static bool knuth_morris_pratt_multibyte (const char *haystack, const char *needle, const char **resultp) *** lib/mbsstr.c.orig 2008-01-08 23:53:17.000000000 +0100 --- lib/mbsstr.c 2008-01-08 23:50:23.000000000 +0100 *************** *** 1,5 **** /* Searching in a string. ! Copyright (C) 2005-2007 Free Software Foundation, Inc. Written by Bruno Haible <[EMAIL PROTECTED]>, 2005. This program is free software: you can redistribute it and/or modify --- 1,5 ---- /* Searching in a string. ! Copyright (C) 2005-2008 Free Software Foundation, Inc. Written by Bruno Haible <[EMAIL PROTECTED]>, 2005. This program is free software: you can redistribute it and/or modify *************** *** 35,41 **** #if HAVE_MBRTOWC /* Knuth-Morris-Pratt algorithm. See http://en.wikipedia.org/wiki/Knuth-Morris-Pratt_algorithm ! Return a boolean indicating success. */ static bool knuth_morris_pratt_multibyte (const char *haystack, const char *needle, const char **resultp) --- 35,43 ---- #if HAVE_MBRTOWC /* Knuth-Morris-Pratt algorithm. See http://en.wikipedia.org/wiki/Knuth-Morris-Pratt_algorithm ! Return a boolean indicating success: ! Return true and set *RESULTP if the search was completed. ! Return false if it was aborted because not enough memory was available. */ static bool knuth_morris_pratt_multibyte (const char *haystack, const char *needle, const char **resultp)