Author: adrian.chadd
Date: Thu Feb  5 11:33:02 2009
New Revision: 13802

Modified:
    branches/LUSCA_HEAD/libmem/String.c
    branches/LUSCA_HEAD/libmem/String.h
    branches/LUSCA_HEAD/src/store.c

Log:
suck over strncasecmp() into a String interface.

Issue #3 unfortunately may be String->buf == NULL, so..



Modified: branches/LUSCA_HEAD/libmem/String.c
==============================================================================
--- branches/LUSCA_HEAD/libmem/String.c (original)
+++ branches/LUSCA_HEAD/libmem/String.c Thu Feb  5 11:33:02 2009
@@ -200,3 +200,15 @@
        s->len = offset;
  }

+
+int
+strNCmpNull(const String *a, const char *b, int n)
+{
+    if (strIsNotNull(*a) && b) {
+        return strncmp(strBuf2(*a), b, XMIN(strLen2(*a), n));
+    } else if (strIsNotNull(*a))
+        return 1;
+    else if (b)
+        return -1;
+    return 0;
+}

Modified: branches/LUSCA_HEAD/libmem/String.h
==============================================================================
--- branches/LUSCA_HEAD/libmem/String.h (original)
+++ branches/LUSCA_HEAD/libmem/String.h Thu Feb  5 11:33:02 2009
@@ -23,6 +23,7 @@
  #define strCaseCmp(s,str)     strcasecmp(strBuf(s), (str))
  #define strNCaseCmp(s,str,n)  strncasecmp(strBuf(s), (str), (n))

+extern int strNCmpNull(const String *s, const char *s2, int n);
  extern void stringInit(String * s, const char *str);
  extern void stringLimitInit(String * s, const char *str, int len);
  extern String stringDup(const String * s);

Modified: branches/LUSCA_HEAD/src/store.c
==============================================================================
--- branches/LUSCA_HEAD/src/store.c     (original)
+++ branches/LUSCA_HEAD/src/store.c     Thu Feb  5 11:33:02 2009
@@ -1007,7 +1007,7 @@
  #if 0
            if (strncmpnull(state->accept_encoding, p2, l2) == 0 &&  
state->accept_encoding[l2] == '\0') {
  #endif
-           if (strNCmp(state->accept_encoding, p2, l2) == 0 &&  
strLen2(state->accept_encoding) == l2) {
+           if (strNCmpNull(&state->accept_encoding, p2, l2) == 0 &&  
strLen2(state->accept_encoding) == l2) {
                state->current.encoding_ok = 1;
            }
        }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"lusca-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/lusca-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to