]> granicus.if.org Git - neomutt/commitdiff
lib: move functions to string.c
authorRichard Russon <rich@flatcap.org>
Wed, 1 Nov 2017 04:39:07 +0000 (04:39 +0000)
committerRichard Russon <rich@flatcap.org>
Wed, 1 Nov 2017 04:39:07 +0000 (04:39 +0000)
hcache/hcache.c
lib/string.c
lib/string2.h
sendlib.c

index 03ee012cf07b6b77295cb2a78d8cde645d9bb58b..8f70675d7e604dd11283eee7aae579bd7880fe00 100644 (file)
@@ -168,18 +168,6 @@ static void restore_int(unsigned int *i, const unsigned char *d, int *off)
   (*off) += sizeof(int);
 }
 
-static inline bool is_ascii(const char *p, size_t len)
-{
-  const char *s = p;
-  while (s && (unsigned int) (s - p) < len)
-  {
-    if ((*s & 0x80) != 0)
-      return false;
-    s++;
-  }
-  return true;
-}
-
 static unsigned char *dump_char_size(char *c, unsigned char *d, int *off,
                                      ssize_t size, bool convert)
 {
index 3072dd5c75cadbc475afb7eef05d847f15287222..0f2694ebe068231b179e55877d4a42444c58dfb2 100644 (file)
@@ -27,7 +27,9 @@
  *
  * | Function                  | Description
  * | :------------------------ | :---------------------------------------------------------
+ * | find_word()               | Find the next word (non-space)
  * | imap_wordcasecmp()        | Find word a in word list b
+ * | is_ascii()                | Is a string ASCII (7-bit)?
  * | is_email_wsp()            | Is this a whitespace character (for an email header)
  * | lwslen()                  | Measure the linear-white-space at the beginning of a string
  * | lwsrlen()                 | Measure the linear-white-space at the end of a string
  * | mutt_strncasecmp()        | Compare two strings ignoring case (to a maximum), safely
  * | mutt_strncmp()            | Compare two strings (to a maximum), safely
  * | mutt_str_adjust()         | Shrink-to-fit a string
+ * | mutt_str_append_item()    | Add string to another seprated by sep
  * | mutt_str_replace()        | Replace one string with another
- * | mutt_str_append_item()    | Add a string to another
  * | mutt_substrcpy()          | Copy a sub-string into a buffer
  * | mutt_substrdup()          | Duplicate a sub-string
+ * | next_word()               | Find the next word in a string
  * | rfc822_dequote_comment()  | Un-escape characters in an email address comment
  * | rstrnstr()                | Find last instance of a substring
  * | safe_strcat()             | Concatenate two strings
@@ -745,3 +748,43 @@ int imap_wordcasecmp(const char *a, const char *b)
 
   return mutt_strcasecmp(a, tmp);
 }
+
+/**
+ * is_ascii - Is a string ASCII (7-bit)?
+ * @param p   String to examine
+ * @param len Length of string
+ * @retval bool True if there are no 8-bit chars
+ */
+bool is_ascii(const char *p, size_t len)
+{
+  const char *s = p;
+  while (s && (unsigned int) (s - p) < len)
+  {
+    if ((*s & 0x80) != 0)
+      return false;
+    s++;
+  }
+  return true;
+}
+
+/**
+ * find_word - Find the next word (non-space)
+ * @param src String to search
+ * @retval ptr Beginning of the next word
+ *
+ * Skip to the end of the current word.
+ * Skip past any whitespace characters.
+ *
+ * @note If there aren't any more words, this will return a pointer to the
+ *       final NUL character.
+ */
+const char *find_word(const char *src)
+{
+  const char *p = src;
+
+  while (p && *p && strchr(" \t\n", *p))
+    p++;
+  while (p && *p && !strchr(" \t\n", *p))
+    p++;
+  return p;
+}
index 6b4a6dc76d8fed926cf65ac6bb0f0ddfbcf6ca36..c7dff15a137d92b01e1725ec152458bd8e1cd3ce 100644 (file)
@@ -28,6 +28,7 @@
 #define _LIB_STRING_H
 
 #include <ctype.h>
+#include <stdbool.h>
 #include <stdio.h>
 
 #define SHORT_STRING 128
@@ -56,7 +57,9 @@
 
 #define terminate_buffer(a, b) terminate_string(a, b, sizeof(a) - 1)
 
+const char *find_word(const char *src);
 int         imap_wordcasecmp(const char *a, const char *b);
+bool        is_ascii(const char *p, size_t len);
 int         is_email_wsp(char c);
 size_t      lwslen(const char *s, size_t n);
 size_t      lwsrlen(const char *s, size_t n);
index b87634b7c17bdcf262187976be8635762790d7c7..e3a086fcc0974cd919a69bbaa15d26b551b3cbca 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -1679,17 +1679,6 @@ void mutt_write_references(const struct ListHead *r, FILE *f, size_t trim)
   FREE(&ref);
 }
 
-static const char *find_word(const char *src)
-{
-  const char *p = src;
-
-  while (p && *p && strchr(" \t\n", *p))
-    p++;
-  while (p && *p && !strchr(" \t\n", *p))
-    p++;
-  return p;
-}
-
 /**
  * my_width - like wcwidth(), but gets const char* not wchar_t*
  */