]> git.sur5r.net Git - openldap/blobdiff - libraries/liblunicode/ure/ure.c
Full implementation of server identity checking per RFC2830 section 3.6
[openldap] / libraries / liblunicode / ure / ure.c
index 3ed7d7a889031d86035d6a7717fbfcf99fbc9204..90cea614073b1d21c50079f3fd510c9c0ee18bdc 100644 (file)
@@ -1,6 +1,6 @@
 /* $OpenLDAP$ */
 /*
- * Copyright 2000-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 2000 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 /*
@@ -25,9 +25,7 @@
  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-#ifndef lint
-static char rcsid[] = "$Id: ure.c,v 1.2 1999/09/21 15:47:43 mleisher Exp $";
-#endif
+/* $Id: ure.c,v 1.2 1999/09/21 15:47:43 mleisher Exp $" */
 
 #include "portable.h"
 
@@ -1077,7 +1075,7 @@ _ure_make_symbol(ucs2_t *sym, unsigned long limit, unsigned long *consumed,
      * Build the next symbol so we can test to see if it is already in the
      * symbol table.
      */
-    (void) memset((char *) &symbol, 0, sizeof(_ure_symtab_t));
+    (void) memset((char *) &symbol, '\0', sizeof(_ure_symtab_t));
     *consumed = _ure_compile_symbol(sym, limit, &symbol, b);
 
     /*
@@ -1108,12 +1106,12 @@ _ure_make_symbol(ucs2_t *sym, unsigned long limit, unsigned long *consumed,
               realloc((char *) b->symtab,
                       sizeof(_ure_symtab_t) * (b->symtab_size + 8));
         sp = b->symtab + b->symtab_size;
-        (void) memset((char *) sp, 0, sizeof(_ure_symtab_t) << 3);
+        (void) memset((char *) sp, '\0', sizeof(_ure_symtab_t) << 3);
         b->symtab_size += 8;
     }
 
     symbol.id = b->symtab_used++;
-    (void) memcpy((char *) &b->symtab[symbol.id], (char *) &symbol,
+    (void) AC_MEMCPY((char *) &b->symtab[symbol.id], (char *) &symbol,
                   sizeof(_ure_symtab_t));
 
     return symbol.id;
@@ -1329,7 +1327,7 @@ _ure_add_state(ucs2_t nstates, ucs2_t *states, _ure_buffer_t *b)
                   realloc((char *) b->states.states,
                           sizeof(_ure_state_t) * (b->states.states_size + 8));
             sp = b->states.states + b->states.states_size;
-            (void) memset((char *) sp, 0, sizeof(_ure_state_t) << 3);
+            (void) memset((char *) sp, '\0', sizeof(_ure_state_t) << 3);
             b->states.states_size += 8;
         }
 
@@ -1347,7 +1345,7 @@ _ure_add_state(ucs2_t nstates, ucs2_t *states, _ure_buffer_t *b)
             sp->st.slist_size = sp->st.slist_used + nstates;
         }
         sp->st.slist_used = nstates;
-        (void) memcpy((char *) sp->st.slist, (char *) states,
+        (void) AC_MEMCPY((char *) sp->st.slist, (char *) states,
                       sizeof(ucs2_t) * nstates);
     }
 
@@ -1734,7 +1732,7 @@ ure_compile(ucs2_t *re, unsigned long relen, int casefold, ure_buffer_t buf)
      * Construct the minimal DFA.
      */
     dfa = (ure_dfa_t) malloc(sizeof(_ure_dfa_t));
-    (void) memset((char *) dfa, 0, sizeof(_ure_dfa_t));
+    (void) memset((char *) dfa, '\0', sizeof(_ure_dfa_t));
 
     dfa->flags = buf->flags & (_URE_DFA_CASEFOLD|_URE_DFA_BLANKLINE);
 
@@ -1868,8 +1866,8 @@ ure_write_dfa(ure_dfa_t dfa, FILE *out)
                  */
                 if (0x10000 <= rp->min_code &&
                     rp->min_code <= 0x10ffff) {
-                    h = ((rp->min_code - 0x10000) >> 10) + 0xd800;
-                    l = ((rp->min_code - 0x10000) & 1023) + 0xdc00;
+                    h = (ucs2_t) (((rp->min_code - 0x10000) >> 10) + 0xd800);
+                    l = (ucs2_t) (((rp->min_code - 0x10000) & 1023) + 0xdc00);
                     fprintf(out, "\\x%04hX\\x%04hX", h, l);
                 } else
                   fprintf(out, "\\x%04lX", rp->min_code & 0xffff);
@@ -1877,8 +1875,8 @@ ure_write_dfa(ure_dfa_t dfa, FILE *out)
                     putc('-', out);
                     if (rp->max_code >= 0x10000 &&
                         rp->max_code <= 0x10ffff) {
-                        h = ((rp->max_code - 0x10000) >> 10) + 0xd800;
-                        l = ((rp->max_code - 0x10000) & 1023) + 0xdc00;
+                        h = (ucs2_t) (((rp->max_code - 0x10000) >> 10) + 0xd800);
+                        l = (ucs2_t) (((rp->max_code - 0x10000) & 1023) + 0xdc00);
                         fprintf(out, "\\x%04hX\\x%04hX", h, l);
                     } else
                       fprintf(out, "\\x%04lX", rp->max_code & 0xffff);
@@ -1908,8 +1906,8 @@ ure_write_dfa(ure_dfa_t dfa, FILE *out)
                     /*
                      * Take care of UTF16 characters.
                      */
-                    h = ((sym->sym.chr - 0x10000) >> 10) + 0xd800;
-                    l = ((sym->sym.chr - 0x10000) & 1023) + 0xdc00;
+                    h = (ucs2_t) (((sym->sym.chr - 0x10000) >> 10) + 0xd800);
+                    l = (ucs2_t) (((sym->sym.chr - 0x10000) & 1023) + 0xdc00);
                     fprintf(out, "\\x%04hX\\x%04hX ", h, l);
                 } else
                   fprintf(out, "\\x%04lX ", sym->sym.chr & 0xffff);