d79829e04a7d00dbe363675013dccb3527c3dc64
larrym
  Tue Nov 15 11:53:05 2011 -0800
add htmlTextReplaceTagsWithChar
diff --git src/lib/htmshell.c src/lib/htmshell.c
index b789404..1f1963c 100644
--- src/lib/htmshell.c
+++ src/lib/htmshell.c
@@ -137,30 +137,57 @@
     if (*from == '<')
         {
         from++;
         while (*from!='\0' && *from != '>')
             from++;
         if (*from == '\0')  // The last open tag was never closed!
             break;
         from++;
         }
     else
         *to++ = *from++;
     }
 return scrubbed;
 }
 
+char *htmlTextReplaceTagsWithChar(char *s, char ch)
+/* Returns a cloned string with all html tags replaced with given char (useful for tokenizing) */
+{
+if (s == NULL)
+    return NULL;
+char *scrubbed = needMem(strlen(s) + 1);
+char *from=s;
+char *to=scrubbed;
+while(*from!='\0')
+    {
+    if (*from == '<')
+        {
+        from++;
+        *to++ = ch;
+        while (*from!='\0' && *from != '>')
+            from++;
+        if (*from == '\0')  // The last open tag was never closed!
+            break;
+        from++;
+        }
+    else
+        *to++ = *from++;
+    }
+*to = '\0';
+return scrubbed;
+}
+
 char *htmlEncodeText(char *s,boolean tagsOkay)
 /* Returns a cloned string with quotes replaced by html codes.
    Changes ',",\n and if not tagsOkay >,<,& to code equivalents.
    This differs from cgiEncode as it handles text that will
    be displayed in an html page or tooltip style title.  */
 {
 int size = strlen(s) + 3; // Add some slop
 if(tagsOkay)
     size += countChars(s,'\n') * 4;
 else
     {
     size += countChars(s,'>' ) * 4;
     size += countChars(s,'<' ) * 4;
     size += countChars(s,'&' ) * 5;
     size += countChars(s,'\n') * 6;