Diff for /embedaddon/libxml2/xmlstring.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2012/02/21 23:37:57 version 1.1.1.2, 2014/06/15 19:53:28
Line 3 Line 3
  *   *
  * This module provides various utility functions for manipulating   * This module provides various utility functions for manipulating
  * the xmlChar* type. All functions named xmlStr* have been moved here   * the xmlChar* type. All functions named xmlStr* have been moved here
 * from the parser.c file (their original home).  * from the parser.c file (their original home).
  *   *
  * See Copyright for the status of this software.   * See Copyright for the status of this software.
  *   *
Line 40 Line 40
 xmlChar *  xmlChar *
 xmlStrndup(const xmlChar *cur, int len) {  xmlStrndup(const xmlChar *cur, int len) {
     xmlChar *ret;      xmlChar *ret;
    
     if ((cur == NULL) || (len < 0)) return(NULL);      if ((cur == NULL) || (len < 0)) return(NULL);
     ret = (xmlChar *) xmlMallocAtomic((len + 1) * sizeof(xmlChar));      ret = (xmlChar *) xmlMallocAtomic((len + 1) * sizeof(xmlChar));
     if (ret == NULL) {      if (ret == NULL) {
Line 85  xmlChar * Line 85  xmlChar *
 xmlCharStrndup(const char *cur, int len) {  xmlCharStrndup(const char *cur, int len) {
     int i;      int i;
     xmlChar *ret;      xmlChar *ret;
    
     if ((cur == NULL) || (len < 0)) return(NULL);      if ((cur == NULL) || (len < 0)) return(NULL);
     ret = (xmlChar *) xmlMallocAtomic((len + 1) * sizeof(xmlChar));      ret = (xmlChar *) xmlMallocAtomic((len + 1) * sizeof(xmlChar));
     if (ret == NULL) {      if (ret == NULL) {
Line 170  xmlStrEqual(const xmlChar *str1, const xmlChar *str2)  Line 170  xmlStrEqual(const xmlChar *str1, const xmlChar *str2) 
  * @name:  the localname of the QName   * @name:  the localname of the QName
  * @str:  the second xmlChar *   * @str:  the second xmlChar *
  *   *
 * Check if a QName is Equal to a given string  * Check if a QName is Equal to a given string
  *   *
  * Returns 1 if they are equal, 0 if they are different   * Returns 1 if they are equal, 0 if they are different
  */   */
Line 340  xmlStrchr(const xmlChar *str, xmlChar val) { Line 340  xmlStrchr(const xmlChar *str, xmlChar val) {
 const xmlChar *  const xmlChar *
 xmlStrstr(const xmlChar *str, const xmlChar *val) {  xmlStrstr(const xmlChar *str, const xmlChar *val) {
     int n;      int n;
    
     if (str == NULL) return(NULL);      if (str == NULL) return(NULL);
     if (val == NULL) return(NULL);      if (val == NULL) return(NULL);
     n = xmlStrlen(val);      n = xmlStrlen(val);
Line 368  xmlStrstr(const xmlChar *str, const xmlChar *val) { Line 368  xmlStrstr(const xmlChar *str, const xmlChar *val) {
 const xmlChar *  const xmlChar *
 xmlStrcasestr(const xmlChar *str, const xmlChar *val) {  xmlStrcasestr(const xmlChar *str, const xmlChar *val) {
     int n;      int n;
    
     if (str == NULL) return(NULL);      if (str == NULL) return(NULL);
     if (val == NULL) return(NULL);      if (val == NULL) return(NULL);
     n = xmlStrlen(val);      n = xmlStrlen(val);
Line 396  xmlStrcasestr(const xmlChar *str, const xmlChar *val)  Line 396  xmlStrcasestr(const xmlChar *str, const xmlChar *val) 
 xmlChar *  xmlChar *
 xmlStrsub(const xmlChar *str, int start, int len) {  xmlStrsub(const xmlChar *str, int start, int len) {
     int i;      int i;
    
     if (str == NULL) return(NULL);      if (str == NULL) return(NULL);
     if (start < 0) return(NULL);      if (start < 0) return(NULL);
     if (len < 0) return(NULL);      if (len < 0) return(NULL);
Line 519  xmlStrcat(xmlChar *cur, const xmlChar *add) { Line 519  xmlStrcat(xmlChar *cur, const xmlChar *add) {
     const xmlChar *p = add;      const xmlChar *p = add;
   
     if (add == NULL) return(cur);      if (add == NULL) return(cur);
    if (cur == NULL)     if (cur == NULL)
         return(xmlStrdup(add));          return(xmlStrdup(add));
   
     while (*p != 0) p++; /* non input consuming */      while (*p != 0) p++; /* non input consuming */
Line 537  xmlStrcat(xmlChar *cur, const xmlChar *add) { Line 537  xmlStrcat(xmlChar *cur, const xmlChar *add) {
  *   *
  * Returns the number of characters written to @buf or -1 if an error occurs.   * Returns the number of characters written to @buf or -1 if an error occurs.
  */   */
int XMLCDECL int XMLCDECL
 xmlStrPrintf(xmlChar *buf, int len, const xmlChar *msg, ...) {  xmlStrPrintf(xmlChar *buf, int len, const xmlChar *msg, ...) {
     va_list args;      va_list args;
     int ret;      int ret;
    
     if((buf == NULL) || (msg == NULL)) {      if((buf == NULL) || (msg == NULL)) {
         return(-1);          return(-1);
     }      }
    
     va_start(args, msg);      va_start(args, msg);
     ret = vsnprintf((char *) buf, len, (const char *) msg, args);      ret = vsnprintf((char *) buf, len, (const char *) msg, args);
     va_end(args);      va_end(args);
     buf[len - 1] = 0; /* be safe ! */      buf[len - 1] = 0; /* be safe ! */
    
     return(ret);      return(ret);
 }  }
   
Line 565  xmlStrPrintf(xmlChar *buf, int len, const xmlChar *msg Line 565  xmlStrPrintf(xmlChar *buf, int len, const xmlChar *msg
  *   *
  * Returns the number of characters written to @buf or -1 if an error occurs.   * Returns the number of characters written to @buf or -1 if an error occurs.
  */   */
int int
 xmlStrVPrintf(xmlChar *buf, int len, const xmlChar *msg, va_list ap) {  xmlStrVPrintf(xmlChar *buf, int len, const xmlChar *msg, va_list ap) {
     int ret;      int ret;
    
     if((buf == NULL) || (msg == NULL)) {      if((buf == NULL) || (msg == NULL)) {
         return(-1);          return(-1);
     }      }
    
     ret = vsnprintf((char *) buf, len, (const char *) msg, ap);      ret = vsnprintf((char *) buf, len, (const char *) msg, ap);
     buf[len - 1] = 0; /* be safe ! */      buf[len - 1] = 0; /* be safe ! */
    
     return(ret);      return(ret);
 }  }
   
Line 858  xmlChar * Line 858  xmlChar *
 xmlUTF8Strndup(const xmlChar *utf, int len) {  xmlUTF8Strndup(const xmlChar *utf, int len) {
     xmlChar *ret;      xmlChar *ret;
     int i;      int i;
    
     if ((utf == NULL) || (len < 0)) return(NULL);      if ((utf == NULL) || (len < 0)) return(NULL);
     i = xmlUTF8Strsize(utf, len);      i = xmlUTF8Strsize(utf, len);
     ret = (xmlChar *) xmlMallocAtomic((i + 1) * sizeof(xmlChar));      ret = (xmlChar *) xmlMallocAtomic((i + 1) * sizeof(xmlChar));

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>