]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Display an error message if a regex is used in the hostalias
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Mon, 13 Feb 2012 08:03:00 +0000 (09:03 +0100)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Mon, 13 Feb 2012 08:03:00 +0000 (09:03 +0100)
If libpcre was not compiled in sarg and regex are used in the hostalias
file, an error message is displayed and sarg exits.

url.c

diff --git a/url.c b/url.c
index 794dfed253736d143842c91398658e238ddcdc7c..668e0635a77c4511249fe39296a05b8ec6cf59d2 100644 (file)
--- a/url.c
+++ b/url.c
@@ -531,27 +531,30 @@ static int Alias_Store(char *buf)
        const char *next;
        int Error;
        
+       if (strncasecmp(buf,"re:",3)==0) {
 #ifdef USE_PCRE
-               if (strncasecmp(buf,"re:",3)==0) {
-                       if (Alias_StoreRegexp(buf+3)<0)
-                               return(-1);
-                       return(0);
-               }
-#endif
-               type=extract_address_mask(buf,&name,ipv4,ipv6,&nbits,&next);
-               if (type<0) {
+               if (Alias_StoreRegexp(buf+3)<0)
                        return(-1);
-               }
-
-               if (type==1) {
-                       Error=Alias_StoreName(name,next);
-               } else if (type==2) {
-                       Error=Alias_StoreIpv4(ipv4,nbits,next);
-               } else if (type==3) {
-                       Error=Alias_StoreIpv6(ipv6,nbits,next);
-               }
-               if (Error<0) return(-1);
                return(0);
+#else
+               debuga(_("PCRE not compiled in therefore the regular expressions are not available in the host alias file\n"));
+               return(-1);
+#endif
+       }
+       type=extract_address_mask(buf,&name,ipv4,ipv6,&nbits,&next);
+       if (type<0) {
+               return(-1);
+       }
+
+       if (type==1) {
+               Error=Alias_StoreName(name,next);
+       } else if (type==2) {
+               Error=Alias_StoreIpv4(ipv4,nbits,next);
+       } else if (type==3) {
+               Error=Alias_StoreIpv6(ipv6,nbits,next);
+       }
+       if (Error<0) return(-1);
+       return(0);
 }
 
 /*!