]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/kern/misc.c (grub_strstr): Moved from here ...
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 11 Nov 2011 19:02:51 +0000 (20:02 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 11 Nov 2011 19:02:51 +0000 (20:02 +0100)
* include/grub/misc.h (grub_strstr): ... here. Make static and inline.

ChangeLog
grub-core/kern/misc.c
include/grub/misc.h

index 4838d9566a09e22fadda1a921b214cb8c3b15e3f..6d740545af05d36888922e6a92ee62dea790950a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-11-11  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/kern/misc.c (grub_strstr): Moved from here ...
+       * include/grub/misc.h (grub_strstr): ... here. Make static and inline.
+
 2011-11-11  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * include/grub/ieee1275/ieee1275.h (grub_ieee1275_set_property):
index ebf80f100eaa4db74a93a42634973f969d37db05..34c9b3b0c7a8efbb3a761fdb9306d149718dcd72 100644 (file)
@@ -312,52 +312,6 @@ grub_strrchr (const char *s, int c)
   return p;
 }
 
-/* Copied from gnulib.
-   Written by Bruno Haible <bruno@clisp.org>, 2005. */
-char *
-grub_strstr (const char *haystack, const char *needle)
-{
-  /* Be careful not to look at the entire extent of haystack or needle
-     until needed.  This is useful because of these two cases:
-       - haystack may be very long, and a match of needle found early,
-       - needle may be very long, and not even a short initial segment of
-       needle may be found in haystack.  */
-  if (*needle != '\0')
-    {
-      /* Speed up the following searches of needle by caching its first
-        character.  */
-      char b = *needle++;
-
-      for (;; haystack++)
-       {
-         if (*haystack == '\0')
-           /* No match.  */
-           return NULL;
-         if (*haystack == b)
-           /* The first character matches.  */
-           {
-             const char *rhaystack = haystack + 1;
-             const char *rneedle = needle;
-
-             for (;; rhaystack++, rneedle++)
-               {
-                 if (*rneedle == '\0')
-                   /* Found a match.  */
-                   return (char *) haystack;
-                 if (*rhaystack == '\0')
-                   /* No match.  */
-                   return NULL;
-                 if (*rhaystack != *rneedle)
-                   /* Nothing in this round.  */
-                   break;
-               }
-           }
-       }
-    }
-  else
-    return (char *) haystack;
-}
-
 int
 grub_strword (const char *haystack, const char *needle)
 {
index 4e7d9077cf38f1ff900d857b9c8e6b184894ce6a..358f73258a3b1ed3b7bc40770a6cc062c753b3b1 100644 (file)
@@ -113,7 +113,53 @@ int EXPORT_FUNC(grub_strncmp) (const char *s1, const char *s2, grub_size_t n);
 char *EXPORT_FUNC(grub_strchr) (const char *s, int c);
 char *EXPORT_FUNC(grub_strrchr) (const char *s, int c);
 int EXPORT_FUNC(grub_strword) (const char *s, const char *w);
-char *EXPORT_FUNC(grub_strstr) (const char *haystack, const char *needle);
+
+/* Copied from gnulib.
+   Written by Bruno Haible <bruno@clisp.org>, 2005. */
+static inline char *
+grub_strstr (const char *haystack, const char *needle)
+{
+  /* Be careful not to look at the entire extent of haystack or needle
+     until needed.  This is useful because of these two cases:
+       - haystack may be very long, and a match of needle found early,
+       - needle may be very long, and not even a short initial segment of
+       needle may be found in haystack.  */
+  if (*needle != '\0')
+    {
+      /* Speed up the following searches of needle by caching its first
+        character.  */
+      char b = *needle++;
+
+      for (;; haystack++)
+       {
+         if (*haystack == '\0')
+           /* No match.  */
+           return 0;
+         if (*haystack == b)
+           /* The first character matches.  */
+           {
+             const char *rhaystack = haystack + 1;
+             const char *rneedle = needle;
+
+             for (;; rhaystack++, rneedle++)
+               {
+                 if (*rneedle == '\0')
+                   /* Found a match.  */
+                   return (char *) haystack;
+                 if (*rhaystack == '\0')
+                   /* No match.  */
+                   return 0;
+                 if (*rhaystack != *rneedle)
+                   /* Nothing in this round.  */
+                   break;
+               }
+           }
+       }
+    }
+  else
+    return (char *) haystack;
+}
+
 int EXPORT_FUNC(grub_isspace) (int c);
 int EXPORT_FUNC(grub_isprint) (int c);