Changeset 838e14e2 in mainline


Ignore:
Timestamp:
2008-08-09T22:14:20Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0516fd7
Parents:
b3105ff6
Message:

Cstyle for string.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/generic/string.c

    rb3105ff6 r838e14e2  
    6767               
    6868        for (j = 0; j < n % sizeof(unsigned long); j++)
    69                 ((unsigned char *) (((unsigned long *) dst) + i))[j] = ((unsigned char *) (((unsigned long *) src) + i))[j];
     69                ((unsigned char *) (((unsigned long *) dst) + i))[j] =
     70                    ((unsigned char *) (((unsigned long *) src) + i))[j];
    7071               
    7172        return (char *) src;
     
    7677        int i, j;
    7778
    78         if (((long) dst & (sizeof(long) - 1)) || ((long) src & (sizeof(long) - 1)))
     79        if (((long) dst & (sizeof(long) - 1)) ||
     80            ((long) src & (sizeof(long) - 1)))
    7981                return unaligned_memcpy(dst, src, n);
    8082
     
    8385               
    8486        for (j = 0; j < n % sizeof(unsigned long); j++)
    85                 ((unsigned char *) (((unsigned long *) dst) + i))[j] = ((unsigned char *) (((unsigned long *) src) + i))[j];
     87                ((unsigned char *) (((unsigned long *) dst) + i))[j] =
     88                    ((unsigned char *) (((unsigned long *) src) + i))[j];
    8689               
    8790        return (char *) src;
     
    9699
    97100        for (j = (n % sizeof(unsigned long)) - 1; j >= 0; j--)
    98                 ((unsigned char *) ((unsigned long *) dst))[j] = ((unsigned char *) ((unsigned long *) src))[j];
     101                ((unsigned char *) ((unsigned long *) dst))[j] =
     102                    ((unsigned char *) ((unsigned long *) src))[j];
    99103
    100104        for (i = n / sizeof(unsigned long) - 1; i >=0 ; i--)
     
    106110/** Compare two memory areas.
    107111 *
    108  * @param s1    Pointer to the first area to compare.
    109  * @param s2    Pointer to the second area to compare.
    110  * @param len   Size of the first area in bytes. Both areas must have the same
    111  *              length.
    112  * @return      If len is 0, return zero. If the areas match, return zero.
    113  *              Otherwise return non-zero.
     112 * @param s1            Pointer to the first area to compare.
     113 * @param s2            Pointer to the second area to compare.
     114 * @param len           Size of the first area in bytes. Both areas must have
     115 *                      the same length.
     116 * @return              If len is 0, return zero. If the areas match, return
     117 *                      zero. Otherwise return non-zero.
    114118 */
    115119int bcmp(const char *s1, const char *s2, size_t len)
     
    121125
    122126/** Count the number of characters in the string, not including terminating 0.
    123  * @param str string
    124  * @return number of characters in string.
     127 *
     128 * @param str           String.
     129 * @return              Number of characters in string.
    125130 */
    126131size_t strlen(const char *str)
     
    156161}
    157162
    158 /** Return pointer to the first occurence of character c in string
    159  * @param str scanned string
    160  * @param c searched character (taken as one byte)
    161  * @return pointer to the matched character or NULL if it is not found in given string.
     163/** Return pointer to the first occurence of character c in string.
     164 *
     165 * @param str           Scanned string.
     166 * @param c             Searched character (taken as one byte).
     167 * @return              Pointer to the matched character or NULL if it is not
     168 *                      found in given string.
    162169 */
    163170char *strchr(const char *str, int c)
     
    172179}
    173180
    174 /** Return pointer to the last occurence of character c in string
    175  * @param str scanned string
    176  * @param c searched character (taken as one byte)
    177  * @return pointer to the matched character or NULL if it is not found in given string.
     181/** Return pointer to the last occurence of character c in string.
     182 *
     183 * @param str           Scanned string.
     184 * @param c             Searched character (taken as one byte).
     185 * @return              Pointer to the matched character or NULL if it is not
     186 *                      found in given string.
    178187 */
    179188char *strrchr(const char *str, int c)
     
    192201/** Convert string to a number.
    193202 * Core of strtol and strtoul functions.
    194  * @param nptr pointer to string
    195  * @param endptr if not NULL, function stores here pointer to the first invalid character
    196  * @param base zero or number between 2 and 36 inclusive
    197  * @param sgn its set to 1 if minus found
    198  * @return result of conversion.
    199  */
    200 static unsigned long _strtoul(const char *nptr, char **endptr, int base, char *sgn)
     203 *
     204 * @param nptr          Pointer to string.
     205 * @param endptr        If not NULL, function stores here pointer to the first
     206 *                      invalid character.
     207 * @param base          Zero or number between 2 and 36 inclusive.
     208 * @param sgn           It's set to 1 if minus found.
     209 * @return              Result of conversion.
     210 */
     211static unsigned long
     212_strtoul(const char *nptr, char **endptr, int base, char *sgn)
    201213{
    202214        unsigned char c;
     
    220232                        return 0;
    221233                }
    222                 if ((base == 16) && (*str == '0') && ((str[1] == 'x') || (str[1] == 'X'))) {
     234                if ((base == 16) && (*str == '0') && ((str[1] == 'x') ||
     235                    (str[1] == 'X'))) {
    223236                        str += 2;
    224237                }
     
    239252        while (*str) {
    240253                c = *str;
    241                 c = (c >= 'a' ? c - 'a' + 10 : (c >= 'A' ? c - 'A' + 10 : (c <= '9' ? c - '0' : 0xff)));
     254                c = (c >= 'a' ? c - 'a' + 10 : (c >= 'A' ? c - 'A' + 10 :
     255                    (c <= '9' ? c - '0' : 0xff)));
    242256                if (c > base) {
    243257                        break;
     
    258272       
    259273        if (str == tmpptr) {
    260                 /* no number was found => first invalid character is the first character of the string */
     274                /*
     275                 * No number was found => first invalid character is the first
     276                 * character of the string.
     277                 */
    261278                /* FIXME: set errno to EINVAL */
    262279                str = nptr;
     
    276293
    277294/** Convert initial part of string to long int according to given base.
    278  * The number may begin with an arbitrary number of whitespaces followed by optional sign (`+' or `-').
    279  * If the base is 0 or 16, the prefix `0x' may be inserted and the number will be taken as hexadecimal one.
    280  * If the base is 0 and the number begin with a zero, number will be taken as octal one (as with base 8).
    281  * Otherwise the base 0 is taken as decimal.
    282  * @param nptr pointer to string
    283  * @param endptr if not NULL, function stores here pointer to the first invalid character
    284  * @param base zero or number between 2 and 36 inclusive
    285  * @return result of conversion.
     295 * The number may begin with an arbitrary number of whitespaces followed by
     296 * optional sign (`+' or `-'). If the base is 0 or 16, the prefix `0x' may be
     297 * inserted and the number will be taken as hexadecimal one. If the base is 0
     298 * and the number begin with a zero, number will be taken as octal one (as with
     299 * base 8). Otherwise the base 0 is taken as decimal.
     300 *
     301 * @param nptr          Pointer to string.
     302 * @param endptr        If not NULL, function stores here pointer to the first
     303 *                      invalid character.
     304 * @param base          Zero or number between 2 and 36 inclusive.
     305 * @return              Result of conversion.
    286306 */
    287307long int strtol(const char *nptr, char **endptr, int base)
     
    306326
    307327/** Convert initial part of string to unsigned long according to given base.
    308  * The number may begin with an arbitrary number of whitespaces followed by optional sign (`+' or `-').
    309  * If the base is 0 or 16, the prefix `0x' may be inserted and the number will be taken as hexadecimal one.
    310  * If the base is 0 and the number begin with a zero, number will be taken as octal one (as with base 8).
    311  * Otherwise the base 0 is taken as decimal.
    312  * @param nptr pointer to string
    313  * @param endptr if not NULL, function stores here pointer to the first invalid character
    314  * @param base zero or number between 2 and 36 inclusive
    315  * @return result of conversion.
     328 * The number may begin with an arbitrary number of whitespaces followed by
     329 * optional sign (`+' or `-'). If the base is 0 or 16, the prefix `0x' may be
     330 * inserted and the number will be taken as hexadecimal one. If the base is 0
     331 * and the number begin with a zero, number will be taken as octal one (as with
     332 * base 8). Otherwise the base 0 is taken as decimal.
     333 *
     334 * @param nptr          Pointer to string.
     335 * @param endptr        If not NULL, function stores here pointer to the first
     336 *                      invalid character
     337 * @param base          Zero or number between 2 and 36 inclusive.
     338 * @return              Result of conversion.
    316339 */
    317340unsigned long strtoul(const char *nptr, char **endptr, int base)
Note: See TracChangeset for help on using the changeset viewer.