Diff for /XML/encoding.c between versions 1.51 and 1.52

version 1.51, 2000/08/23 13:23:16 version 1.52, 2000/10/25 19:26:52
Line 46 Line 46
 #ifdef LIBXML_HTML_ENABLED  #ifdef LIBXML_HTML_ENABLED
 #include <libxml/HTMLparser.h>  #include <libxml/HTMLparser.h>
 #endif  #endif
   #include <libxml/xmlerror.h>
   
 xmlCharEncodingHandlerPtr xmlUTF16LEHandler = NULL;  xmlCharEncodingHandlerPtr xmlUTF16LEHandler = NULL;
 xmlCharEncodingHandlerPtr xmlUTF16BEHandler = NULL;  xmlCharEncodingHandlerPtr xmlUTF16BEHandler = NULL;
Line 585  UTF8ToUTF16LE(unsigned char* outb, int * Line 586  UTF8ToUTF16LE(unsigned char* outb, int *
             *outlen = 2;              *outlen = 2;
             *inlen = 0;              *inlen = 0;
 #ifdef DEBUG_ENCODING  #ifdef DEBUG_ENCODING
             fprintf(stderr, "Added FFFE Byte Order Mark\n");              xmlGenericError(xmlGenericErrorContext,
                       "Added FFFE Byte Order Mark\n");
 #endif  #endif
             return(2);              return(2);
         }          }
Line 795  UTF8ToUTF16BE(unsigned char* outb, int * Line 797  UTF8ToUTF16BE(unsigned char* outb, int *
             *outlen = 2;              *outlen = 2;
             *inlen = 0;              *inlen = 0;
 #ifdef DEBUG_ENCODING  #ifdef DEBUG_ENCODING
             fprintf(stderr, "Added FEFF Byte Order Mark\n");              xmlGenericError(xmlGenericErrorContext,
                       "Added FEFF Byte Order Mark\n");
 #endif  #endif
             return(2);              return(2);
         }          }
Line 1146  xmlParseCharEncoding(const char* name) Line 1149  xmlParseCharEncoding(const char* name)
     if (!strcmp(upper, "EUC-JP")) return(XML_CHAR_ENCODING_EUC_JP);      if (!strcmp(upper, "EUC-JP")) return(XML_CHAR_ENCODING_EUC_JP);
   
 #ifdef DEBUG_ENCODING  #ifdef DEBUG_ENCODING
     fprintf(stderr, "Unknown encoding %s\n", name);      xmlGenericError(xmlGenericErrorContext, "Unknown encoding %s\n", name);
 #endif  #endif
     return(XML_CHAR_ENCODING_ERROR);      return(XML_CHAR_ENCODING_ERROR);
 }  }
Line 1265  xmlNewCharEncodingHandler(const char *na Line 1268  xmlNewCharEncodingHandler(const char *na
      * Keep only the uppercase version of the encoding.       * Keep only the uppercase version of the encoding.
      */       */
     if (name == NULL) {      if (name == NULL) {
         fprintf(stderr, "xmlNewCharEncodingHandler : no name !\n");          xmlGenericError(xmlGenericErrorContext,
                   "xmlNewCharEncodingHandler : no name !\n");
         return(NULL);          return(NULL);
     }      }
     for (i = 0;i < 499;i++) {      for (i = 0;i < 499;i++) {
Line 1275  xmlNewCharEncodingHandler(const char *na Line 1279  xmlNewCharEncodingHandler(const char *na
     upper[i] = 0;      upper[i] = 0;
     up = xmlMemStrdup(upper);      up = xmlMemStrdup(upper);
     if (up == NULL) {      if (up == NULL) {
         fprintf(stderr, "xmlNewCharEncodingHandler : out of memory !\n");          xmlGenericError(xmlGenericErrorContext,
                   "xmlNewCharEncodingHandler : out of memory !\n");
         return(NULL);          return(NULL);
     }      }
   
Line 1285  xmlNewCharEncodingHandler(const char *na Line 1290  xmlNewCharEncodingHandler(const char *na
     handler = (xmlCharEncodingHandlerPtr)      handler = (xmlCharEncodingHandlerPtr)
               xmlMalloc(sizeof(xmlCharEncodingHandler));                xmlMalloc(sizeof(xmlCharEncodingHandler));
     if (handler == NULL) {      if (handler == NULL) {
         fprintf(stderr, "xmlNewCharEncodingHandler : out of memory !\n");          xmlGenericError(xmlGenericErrorContext,
                   "xmlNewCharEncodingHandler : out of memory !\n");
         return(NULL);          return(NULL);
     }      }
     handler->input = input;      handler->input = input;
Line 1302  xmlNewCharEncodingHandler(const char *na Line 1308  xmlNewCharEncodingHandler(const char *na
      */       */
     xmlRegisterCharEncodingHandler(handler);      xmlRegisterCharEncodingHandler(handler);
 #ifdef DEBUG_ENCODING  #ifdef DEBUG_ENCODING
     fprintf(stderr, "Registered encoding handler for %s\n", name);      xmlGenericError(xmlGenericErrorContext,
               "Registered encoding handler for %s\n", name);
 #endif  #endif
     return(handler);      return(handler);
 }  }
Line 1327  xmlInitCharEncodingHandlers(void) { Line 1334  xmlInitCharEncodingHandlers(void) {
   
     if (*ptr == 0x12) xmlLittleEndian = 0;      if (*ptr == 0x12) xmlLittleEndian = 0;
     else if (*ptr == 0x34) xmlLittleEndian = 1;      else if (*ptr == 0x34) xmlLittleEndian = 1;
     else fprintf(stderr, "Odd problem at endianness detection\n");      else xmlGenericError(xmlGenericErrorContext,
               "Odd problem at endianness detection\n");
   
     if (handlers == NULL) {      if (handlers == NULL) {
         fprintf(stderr, "xmlInitCharEncodingHandlers : out of memory !\n");          xmlGenericError(xmlGenericErrorContext,
                   "xmlInitCharEncodingHandlers : out of memory !\n");
         return;          return;
     }      }
     xmlNewCharEncodingHandler("UTF-8", NULL, NULL);      xmlNewCharEncodingHandler("UTF-8", NULL, NULL);
Line 1381  void Line 1390  void
 xmlRegisterCharEncodingHandler(xmlCharEncodingHandlerPtr handler) {  xmlRegisterCharEncodingHandler(xmlCharEncodingHandlerPtr handler) {
     if (handlers == NULL) xmlInitCharEncodingHandlers();      if (handlers == NULL) xmlInitCharEncodingHandlers();
     if (handler == NULL) {      if (handler == NULL) {
         fprintf(stderr, "xmlRegisterCharEncodingHandler: NULL handler !\n");          xmlGenericError(xmlGenericErrorContext,
                   "xmlRegisterCharEncodingHandler: NULL handler !\n");
         return;          return;
     }      }
   
     if (nbCharEncodingHandler >= MAX_ENCODING_HANDLERS) {      if (nbCharEncodingHandler >= MAX_ENCODING_HANDLERS) {
         fprintf(stderr,           xmlGenericError(xmlGenericErrorContext, 
         "xmlRegisterCharEncodingHandler: Too many handler registered\n");          "xmlRegisterCharEncodingHandler: Too many handler registered\n");
         fprintf(stderr, "\tincrease MAX_ENCODING_HANDLERS : %s\n", __FILE__);          xmlGenericError(xmlGenericErrorContext,
                   "\tincrease MAX_ENCODING_HANDLERS : %s\n", __FILE__);
         return;          return;
     }      }
     handlers[nbCharEncodingHandler++] = handler;      handlers[nbCharEncodingHandler++] = handler;
Line 1518  xmlGetCharEncodingHandler(xmlCharEncodin Line 1529  xmlGetCharEncodingHandler(xmlCharEncodin
     }      }
           
 #ifdef DEBUG_ENCODING  #ifdef DEBUG_ENCODING
     fprintf(stderr, "No handler found for encoding %d\n", enc);      xmlGenericError(xmlGenericErrorContext,
               "No handler found for encoding %d\n", enc);
 #endif  #endif
     return(NULL);      return(NULL);
 }  }
Line 1567  xmlFindCharEncodingHandler(const char *n Line 1579  xmlFindCharEncodingHandler(const char *n
     for (i = 0;i < nbCharEncodingHandler; i++)      for (i = 0;i < nbCharEncodingHandler; i++)
         if (!strcmp(upper, handlers[i]->name)) {          if (!strcmp(upper, handlers[i]->name)) {
 #ifdef DEBUG_ENCODING  #ifdef DEBUG_ENCODING
             fprintf(stderr, "Found registered handler for encoding %s\n", name);              xmlGenericError(xmlGenericErrorContext,
                       "Found registered handler for encoding %s\n", name);
 #endif  #endif
             return(handlers[i]);              return(handlers[i]);
         }          }
Line 1590  xmlFindCharEncodingHandler(const char *n Line 1603  xmlFindCharEncodingHandler(const char *n
             enc->iconv_in = icv_in;              enc->iconv_in = icv_in;
             enc->iconv_out = icv_out;              enc->iconv_out = icv_out;
 #ifdef DEBUG_ENCODING  #ifdef DEBUG_ENCODING
             fprintf(stderr, "Found iconv handler for encoding %s\n", name);              xmlGenericError(xmlGenericErrorContext,
                       "Found iconv handler for encoding %s\n", name);
 #endif  #endif
             return enc;              return enc;
     } else if ((icv_in != (iconv_t) -1) || icv_out != (iconv_t) -1) {      } else if ((icv_in != (iconv_t) -1) || icv_out != (iconv_t) -1) {
             fprintf(stderr, "iconv : problems with filters for '%s'\n", name);              xmlGenericError(xmlGenericErrorContext,
                       "iconv : problems with filters for '%s'\n", name);
     }      }
 #endif /* LIBXML_ICONV_ENABLED */  #endif /* LIBXML_ICONV_ENABLED */
   
 #ifdef DEBUG_ENCODING  #ifdef DEBUG_ENCODING
     fprintf(stderr, "No handler found for encoding %s\n", name);      xmlGenericError(xmlGenericErrorContext,
               "No handler found for encoding %s\n", name);
 #endif  #endif
   
     /*      /*
Line 1739  xmlCharEncFirstLine(xmlCharEncodingHandl Line 1755  xmlCharEncFirstLine(xmlCharEncodingHandl
 #ifdef DEBUG_ENCODING  #ifdef DEBUG_ENCODING
     switch (ret) {      switch (ret) {
         case 0:          case 0:
             fprintf(stderr, "converted %d bytes to %d bytes of input\n",              xmlGenericError(xmlGenericErrorContext,
                       "converted %d bytes to %d bytes of input\n",
                     toconv, written);                      toconv, written);
             break;              break;
         case -1:          case -1:
             fprintf(stderr,"converted %d bytes to %d bytes of input, %d left\n",              xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of input, %d left\n",
                     toconv, written, in->use);                      toconv, written, in->use);
             break;              break;
         case -2:          case -2:
             fprintf(stderr, "input conversion failed due to input error\n");              xmlGenericError(xmlGenericErrorContext,
                       "input conversion failed due to input error\n");
             break;              break;
         case -3:          case -3:
             fprintf(stderr,"converted %d bytes to %d bytes of input, %d left\n",              xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of input, %d left\n",
                     toconv, written, in->use);                      toconv, written, in->use);
             break;              break;
         default:          default:
             fprintf(stderr,"Unknown input conversion failed %d\n", ret);              xmlGenericError(xmlGenericErrorContext,"Unknown input conversion failed %d\n", ret);
     }      }
 #endif  #endif
     /*      /*
Line 1817  xmlCharEncInFunc(xmlCharEncodingHandler Line 1835  xmlCharEncInFunc(xmlCharEncodingHandler
     switch (ret) {      switch (ret) {
 #ifdef DEBUG_ENCODING  #ifdef DEBUG_ENCODING
         case 0:          case 0:
             fprintf(stderr, "converted %d bytes to %d bytes of input\n",              xmlGenericError(xmlGenericErrorContext,
                       "converted %d bytes to %d bytes of input\n",
                     toconv, written);                      toconv, written);
             break;              break;
         case -1:          case -1:
             fprintf(stderr,"converted %d bytes to %d bytes of input, %d left\n",              xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of input, %d left\n",
                     toconv, written, in->use);                      toconv, written, in->use);
             break;              break;
         case -3:          case -3:
             fprintf(stderr,"converted %d bytes to %d bytes of input, %d left\n",              xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of input, %d left\n",
                     toconv, written, in->use);                      toconv, written, in->use);
             break;              break;
 #endif  #endif
         case -2:          case -2:
             fprintf(stderr, "input conversion failed due to input error\n");              xmlGenericError(xmlGenericErrorContext,
             fprintf(stderr, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",                      "input conversion failed due to input error\n");
               xmlGenericError(xmlGenericErrorContext,
                       "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
                     in->content[0], in->content[1],                      in->content[0], in->content[1],
                     in->content[2], in->content[3]);                      in->content[2], in->content[3]);
     }      }
Line 1895  retry: Line 1916  retry:
         }          }
 #endif /* LIBXML_ICONV_ENABLED */  #endif /* LIBXML_ICONV_ENABLED */
 #ifdef DEBUG_ENCODING  #ifdef DEBUG_ENCODING
         fprintf(stderr, "initialized encoder\n");          xmlGenericError(xmlGenericErrorContext,
                   "initialized encoder\n");
 #endif  #endif
         return(0);          return(0);
     }      }
Line 1928  retry: Line 1950  retry:
     }      }
 #endif /* LIBXML_ICONV_ENABLED */  #endif /* LIBXML_ICONV_ENABLED */
     else {      else {
         fprintf(stderr, "xmlCharEncOutFunc: no output function !\n");          xmlGenericError(xmlGenericErrorContext,
                   "xmlCharEncOutFunc: no output function !\n");
         return(-1);          return(-1);
     }      }
   
Line 1940  retry: Line 1963  retry:
     switch (ret) {      switch (ret) {
 #ifdef DEBUG_ENCODING  #ifdef DEBUG_ENCODING
         case 0:          case 0:
             fprintf(stderr, "converted %d bytes to %d bytes of output\n",              xmlGenericError(xmlGenericErrorContext,
                       "converted %d bytes to %d bytes of output\n",
                     toconv, written);                      toconv, written);
             break;              break;
         case -1:          case -1:
             fprintf(stderr, "output conversion failed by lack of space\n");              xmlGenericError(xmlGenericErrorContext,
                       "output conversion failed by lack of space\n");
             break;              break;
         case -3:          case -3:
             fprintf(stderr,"converted %d bytes to %d bytes of output %d left\n",              xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of output %d left\n",
                     toconv, written, in->use);                      toconv, written, in->use);
             break;              break;
 #endif  #endif
Line 1961  retry: Line 1986  retry:
                 xmlChar charref[20];                  xmlChar charref[20];
   
 #ifdef DEBUG_ENCODING  #ifdef DEBUG_ENCODING
                 fprintf(stderr, "handling output conversion error\n");                  xmlGenericError(xmlGenericErrorContext,
                 fprintf(stderr, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",                          "handling output conversion error\n");
                   xmlGenericError(xmlGenericErrorContext,
                           "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
                         in->content[0], in->content[1],                          in->content[0], in->content[1],
                         in->content[2], in->content[3]);                          in->content[2], in->content[3]);
 #endif  #endif
Line 1977  retry: Line 2004  retry:
   
                 goto retry;                  goto retry;
             } else {              } else {
                 fprintf(stderr, "output conversion failed due to conv error\n");                  xmlGenericError(xmlGenericErrorContext,
                 fprintf(stderr, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",                          "output conversion failed due to conv error\n");
                   xmlGenericError(xmlGenericErrorContext,
                           "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
                         in->content[0], in->content[1],                          in->content[0], in->content[1],
                         in->content[2], in->content[3]);                          in->content[2], in->content[3]);
                 in->content[0] = ' ';                  in->content[0] = ' ';
Line 2026  xmlCharEncCloseFunc(xmlCharEncodingHandl Line 2055  xmlCharEncCloseFunc(xmlCharEncodingHandl
 #endif /* LIBXML_ICONV_ENABLED */  #endif /* LIBXML_ICONV_ENABLED */
 #ifdef DEBUG_ENCODING  #ifdef DEBUG_ENCODING
     if (ret)      if (ret)
         fprintf(stderr, "failed to close the encoding handler\n");          xmlGenericError(xmlGenericErrorContext,
                   "failed to close the encoding handler\n");
     else      else
         fprintf(stderr, "closed the encoding handler\n");          xmlGenericError(xmlGenericErrorContext,
                   "closed the encoding handler\n");
   
 #endif  #endif
     return(ret);      return(ret);

Removed from v.1.51  
changed lines
  Added in v.1.52


Webmaster