Changeset a35b458 in mainline for uspace/srv/fs/udf/udf_osta.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/udf/udf_osta.c

    r3061bc1 ra35b458  
    5959        if ((ch == 0x0000) || (ch == 0x002F))
    6060                return false;
    61        
     61
    6262        return true;
    6363}
     
    8585        /* Use udf_compressed to store current byte being read. */
    8686        uint8_t comp_id = udf_compressed[0];
    87        
     87
    8888        /* First check for valid compID. */
    8989        if ((comp_id != 8) && (comp_id != 16))
    9090                return 0;
    91        
     91
    9292        size_t unicode_idx = 0;
    9393        size_t byte_idx = 1;
    94        
     94
    9595        /* Loop through all the bytes. */
    9696        while ((byte_idx < number_of_bytes) && (unicode_idx < unicode_max_len)) {
     
    103103                } else
    104104                        unicode[unicode_idx] = 0;
    105                
     105
    106106                if (byte_idx < number_of_bytes) {
    107107                        /* Then the next byte to the low bits. */
    108108                        unicode[unicode_idx] |= udf_compressed[byte_idx++];
    109109                }
    110                
     110
    111111                unicode_idx++;
    112112        }
    113        
     113
    114114        return unicode_idx;
    115115}
     
    136136        size_t new_idx = 0;
    137137        size_t new_ext_idx = 0;
    138        
     138
    139139        for (size_t idx = 0; idx < udf_len; idx++) {
    140140                uint16_t current = udf_name[idx];
    141                
     141
    142142                if ((!legal_check(current)) || (!ascii_check(current))) {
    143143                        needs_crc = true;
    144                        
     144
    145145                        /*
    146146                         * Replace Illegal and non-displayable chars with
     
    148148                         */
    149149                        current = ILLEGAL_CHAR_MARK;
    150                        
     150
    151151                        /*
    152152                         * Skip any other illegal or non-displayable
     
    158158                                idx++;
    159159                }
    160                
     160
    161161                /* Record position of extension, if one is found. */
    162162                if ((current == PERIOD) && ((udf_len - idx - 1) <= EXT_SIZE)) {
     
    170170                        }
    171171                }
    172                
     172
    173173                if (new_idx < MAXLEN)
    174174                        new_name[new_idx++] = current;
     
    176176                        needs_crc = true;
    177177        }
    178        
     178
    179179        if (needs_crc) {
    180180                uint16_t ext[EXT_SIZE];
    181181                size_t local_ext_idx = 0;
    182                
     182
    183183                if (has_ext) {
    184184                        size_t max_filename_len;
    185                        
     185
    186186                        /* Translate extension, and store it in ext. */
    187187                        for (size_t idx = 0; (idx < EXT_SIZE) &&
    188188                            (ext_idx + idx + 1 < udf_len); idx++) {
    189189                                uint16_t current = udf_name[ext_idx + idx + 1];
    190                                
     190
    191191                                if ((!legal_check(current)) || (!ascii_check(current))) {
    192192                                        needs_crc = true;
    193                                        
     193
    194194                                        /*
    195195                                         * Replace Illegal and non-displayable
     
    197197                                         */
    198198                                        current = ILLEGAL_CHAR_MARK;
    199                                        
     199
    200200                                        /*
    201201                                         * Skip any other illegal or
     
    207207                                                idx++;
    208208                                }
    209                                
     209
    210210                                ext[local_ext_idx++] = current;
    211211                        }
    212                        
     212
    213213                        /*
    214214                         * Truncate filename to leave room for extension and
     
    224224                        new_idx = MAXLEN - 5;
    225225                }
    226                
     226
    227227                /* Add mark for CRC. */
    228228                new_name[new_idx++] = CRC_MARK;
    229                
     229
    230230                /* Calculate CRC from original filename. */
    231231                uint16_t value_crc = udf_unicode_cksum(udf_name, udf_len);
    232                
     232
    233233                /* Convert 16-bits of CRC to hex characters. */
    234234                const char hex_char[] = "0123456789ABCDEF";
    235                
     235
    236236                new_name[new_idx++] = hex_char[(value_crc & 0xf000) >> 12];
    237237                new_name[new_idx++] = hex_char[(value_crc & 0x0f00) >> 8];
    238238                new_name[new_idx++] = hex_char[(value_crc & 0x00f0) >> 4];
    239239                new_name[new_idx++] = hex_char[(value_crc & 0x000f)];
    240                
     240
    241241                /* Place a translated extension at end, if found. */
    242242                if (has_ext) {
    243243                        new_name[new_idx++] = PERIOD;
    244                        
     244
    245245                        for (size_t idx = 0; idx < local_ext_idx; idx++)
    246246                                new_name[new_idx++] = ext[idx];
    247247                }
    248248        }
    249        
     249
    250250        return new_idx;
    251251}
     
    265265        const char *osta_id = "OSTA Compressed Unicode";
    266266        size_t ucode_chars, nice_uchars;
    267        
     267
    268268        uint16_t *raw_name = malloc(MAX_BUF * sizeof(uint16_t));
    269269        uint16_t *unix_name = malloc(MAX_BUF * sizeof(uint16_t));
    270        
     270
    271271        // FIXME: Check for malloc returning NULL
    272        
     272
    273273        bool is_osta_typ0 = (chsp->type == 0) &&
    274274            (str_cmp((char *) chsp->info, osta_id) == 0);
    275        
     275
    276276        if (is_osta_typ0) {
    277277                *raw_name = 0;
    278278                *unix_name = 0;
    279                
     279
    280280                ucode_chars =
    281281                    udf_uncompress_unicode(len, (uint8_t *) id, raw_name, MAX_BUF);
     
    283283                nice_uchars =
    284284                    udf_translate_name(unix_name, raw_name, ucode_chars);
    285                
     285
    286286                /* Output UTF-8 */
    287287                unix_name[nice_uchars] = 0;
     
    292292                    str_size((char *) (id + 1)));
    293293        }
    294        
     294
    295295        free(raw_name);
    296296        free(unix_name);
Note: See TracChangeset for help on using the changeset viewer.