]> mj.ucw.cz Git - libucw.git/blobdiff - lib/regex.c
The great conversion of log() logging function to msg().
[libucw.git] / lib / regex.c
index f952333e7e061aabd30dd5013394d32b86017cd1..adff133e38138964da5a7256076f17fecfe70783 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *     Sherlock Library -- Interface to Regular Expression Libraries
+ *     UCW Library -- Interface to Regular Expression Libraries
  *
  *     (c) 1997--2004 Martin Mares <mj@ucw.cz>
  *     (c) 2001 Robert Spalek <robert@ucw.cz>
@@ -14,7 +14,6 @@
 
 #include <stdio.h>
 #include <string.h>
-#include <stdlib.h>
 
 #if defined(CONFIG_OWN_REGEX) || defined(CONFIG_POSIX_REGEX)
 
@@ -32,7 +31,7 @@ struct regex {
 };
 
 regex *
-rx_compile(byte *p, int icase)
+rx_compile(const byte *p, int icase)
 {
   regex *r = xmalloc_zero(sizeof(regex));
 
@@ -55,7 +54,7 @@ rx_free(regex *r)
 }
 
 int
-rx_match(regex *r, byte *s)
+rx_match(regex *r, const byte *s)
 {
   int err = regexec(&r->rx, s, 10, r->matches, 0);
   if (!err)
@@ -72,7 +71,7 @@ rx_match(regex *r, byte *s)
 }
 
 int
-rx_subst(regex *r, byte *by, byte *src, byte *dest, uns destlen)
+rx_subst(regex *r, const byte *by, const byte *src, byte *dest, uns destlen)
 {
   byte *end = dest + destlen - 1;
 
@@ -89,7 +88,7 @@ rx_subst(regex *r, byte *by, byte *src, byte *dest, uns destlen)
              uns j = *by++ - '0';
              if (j <= r->rx.re_nsub && r->matches[j].rm_so >= 0)
                {
-                 byte *s = src + r->matches[j].rm_so;
+                 const byte *s = src + r->matches[j].rm_so;
                  uns i = r->matches[j].rm_eo - r->matches[j].rm_so;
                  if (dest + i >= end)
                    return -1;