utf8proc

diff utf8proc.c @ 10:00d2bcbdc945

Version 1.1.4

- replaced C++ style comments for compatibility reasons
- added typecasts to suppress compiler warnings
- removed redundant source files for ruby-gemfile generation
- Changed copyright notice for Public Software Group e. V.
- Minor changes in the README file
author jbe
date Wed Aug 19 12:00:00 2009 +0200 (2009-08-19)
parents 951e73a98021
children 2c7384f1fac1
line diff
     1.1 --- a/utf8proc.c	Fri May 01 12:00:00 2009 +0200
     1.2 +++ b/utf8proc.c	Wed Aug 19 12:00:00 2009 +0200
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - *  Copyright (c) 2006-2007 Jan Behrens, FlexiGuided GmbH, Berlin
     1.6 + *  Copyright (c) 2009 Public Software Group e. V., Berlin, Germany
     1.7   *
     1.8   *  Permission is hereby granted, free of charge, to any person obtaining a
     1.9   *  copy of this software and associated documentation files (the "Software"),
    1.10 @@ -33,8 +33,6 @@
    1.11  
    1.12  /*
    1.13   *  File name:    utf8proc.c
    1.14 - *  Version:      1.1.1
    1.15 - *  Last changed: 2007-07-22
    1.16   *
    1.17   *  Description:
    1.18   *  Implementation of libutf8proc.
    1.19 @@ -72,7 +70,7 @@
    1.20  #define UTF8PROC_HANGUL_TCOUNT 28
    1.21  #define UTF8PROC_HANGUL_NCOUNT 588
    1.22  #define UTF8PROC_HANGUL_SCOUNT 11172
    1.23 -// END is exclusive
    1.24 +/* END is exclusive */
    1.25  #define UTF8PROC_HANGUL_L_START  0x1100
    1.26  #define UTF8PROC_HANGUL_L_END    0x115A
    1.27  #define UTF8PROC_HANGUL_L_FILLER 0x115F
    1.28 @@ -196,7 +194,7 @@
    1.29  }
    1.30  
    1.31  const utf8proc_property_t *utf8proc_get_property(int32_t uc) {
    1.32 -  // ASSERT: uc >= 0 && uc < 0x110000
    1.33 +  /* ASSERT: uc >= 0 && uc < 0x110000 */
    1.34    return utf8proc_properties + (
    1.35      utf8proc_stage2table[
    1.36        utf8proc_stage1table[uc >> 8] + (uc & 0xFF)
    1.37 @@ -210,7 +208,7 @@
    1.38  
    1.39  ssize_t utf8proc_decompose_char(int32_t uc, int32_t *dst, ssize_t bufsize,
    1.40      int options, int *last_boundclass) {
    1.41 -  // ASSERT: uc >= 0 && uc < 0x110000
    1.42 +  /* ASSERT: uc >= 0 && uc < 0x110000 */
    1.43    const utf8proc_property_t *property;
    1.44    utf8proc_propval_t category;
    1.45    int32_t hangul_sindex;
    1.46 @@ -357,7 +355,7 @@
    1.47    const uint8_t *str, ssize_t strlen,
    1.48    int32_t *buffer, ssize_t bufsize, int options
    1.49  ) {
    1.50 -  // strlen will be ignored, if UTF8PROC_NULLTERM is set in options
    1.51 +  /* strlen will be ignored, if UTF8PROC_NULLTERM is set in options */
    1.52    ssize_t wpos = 0;
    1.53    if ((options & UTF8PROC_COMPOSE) && (options & UTF8PROC_DECOMPOSE))
    1.54      return UTF8PROC_ERROR_INVALIDOPTS;
    1.55 @@ -372,8 +370,8 @@
    1.56      while (1) {
    1.57        if (options & UTF8PROC_NULLTERM) {
    1.58          rpos += utf8proc_iterate(str + rpos, -1, &uc);
    1.59 -        // checking of return value is not neccessary,
    1.60 -        // as 'uc' is < 0 in case of error
    1.61 +        /* checking of return value is not neccessary,
    1.62 +           as 'uc' is < 0 in case of error */
    1.63          if (uc < 0) return UTF8PROC_ERROR_INVALIDUTF8;
    1.64          if (rpos < 0) return UTF8PROC_ERROR_OVERFLOW;
    1.65          if (uc == 0) break;
    1.66 @@ -388,7 +386,7 @@
    1.67        );
    1.68        if (decomp_result < 0) return decomp_result;
    1.69        wpos += decomp_result;
    1.70 -      // prohibiting integer overflows due to too long strings:
    1.71 +      /* prohibiting integer overflows due to too long strings: */
    1.72        if (wpos < 0 || wpos > SSIZE_MAX/sizeof(int32_t)/2)
    1.73          return UTF8PROC_ERROR_OVERFLOW;
    1.74      }
    1.75 @@ -416,8 +414,8 @@
    1.76  }
    1.77  
    1.78  ssize_t utf8proc_reencode(int32_t *buffer, ssize_t length, int options) {
    1.79 -  // UTF8PROC_NULLTERM option will be ignored, 'length' is never ignored
    1.80 -  // ASSERT: 'buffer' has one spare byte of free space at the end!
    1.81 +  /* UTF8PROC_NULLTERM option will be ignored, 'length' is never ignored
    1.82 +     ASSERT: 'buffer' has one spare byte of free space at the end! */
    1.83    if (options & (UTF8PROC_NLF2LS | UTF8PROC_NLF2PS | UTF8PROC_STRIPCC)) {
    1.84      ssize_t rpos;
    1.85      ssize_t wpos = 0;
    1.86 @@ -461,7 +459,7 @@
    1.87        current_char = buffer[rpos];
    1.88        current_property = utf8proc_get_property(current_char);
    1.89        if (starter && current_property->combining_class > max_combining_class) {
    1.90 -        // combination perhaps possible
    1.91 +        /* combination perhaps possible */
    1.92          int32_t hangul_lindex;
    1.93          int32_t hangul_sindex;
    1.94          hangul_lindex = *starter - UTF8PROC_HANGUL_LBASE;
    1.95 @@ -552,7 +550,7 @@
    1.96    }
    1.97    {
    1.98      int32_t *newptr;
    1.99 -    newptr = realloc(buffer, result+1);
   1.100 +    newptr = realloc(buffer, (size_t)result+1);
   1.101      if (newptr) buffer = newptr;
   1.102    }
   1.103    *dstptr = (uint8_t *)buffer;

Impressum / About Us