Changeset a35b458 in mainline for uspace/app/bdsh/cmds


Ignore:
Timestamp:
2018-03-02T20:10:49Z (6 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.

Location:
uspace/app/bdsh/cmds
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/builtin_cmds.c

    r3061bc1 ra35b458  
    107107
    108108        cmd += builtin;
    109        
     109
    110110        iostate_t *old_iostate = get_iostate();
    111111        set_iostate(new_iostate);
    112        
     112
    113113        if (NULL != cmd->entry) {
    114114                rc = ((int)cmd->entry(argv, usr));
     
    116116                rc = CL_ENOENT;
    117117        }
    118        
     118
    119119        set_iostate(old_iostate);
    120120
  • uspace/app/bdsh/cmds/mod_cmds.c

    r3061bc1 ra35b458  
    129129
    130130        mod += module;
    131        
     131
    132132        iostate_t *old_iostate = get_iostate();
    133133        set_iostate(new_iostate);
     
    138138                rc = CL_ENOENT;
    139139        }
    140        
     140
    141141        set_iostate(old_iostate);
    142142
  • uspace/app/bdsh/cmds/modules/cat/cat.c

    r3061bc1 ra35b458  
    110110        console_set_pos(console, 0, console_rows-1);
    111111        console_set_color(console, COLOR_WHITE, COLOR_BLUE, 0);
    112        
     112
    113113        printf("ENTER/SPACE/PAGE DOWN - next page, "
    114114               "ESC/Q - quit, C - continue unpaged");
    115115        fflush(stdout);
    116        
     116
    117117        console_set_style(console, STYLE_NORMAL);
    118118}
     
    122122        cons_event_t ev;
    123123        kbd_event_t *kev;
    124        
     124
    125125        while (true) {
    126126                if (!console_get_event(console, &ev)) {
     
    129129                if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) {
    130130                        kev = &ev.ev.key;
    131                        
     131
    132132                        if (kev->key == KC_ESCAPE || kev->key == KC_Q) {
    133133                                should_quit = true;
     
    190190
    191191        bool reading_stdin = dash_represents_stdin && (str_cmp(fname, "-") == 0);
    192        
     192
    193193        if (reading_stdin) {
    194194                fd = fileno(stdin);
     
    201201                }
    202202        }
    203        
     203
    204204        if (fd < 0) {
    205205                printf("Unable to open %s\n", fname);
     
    255255                        }
    256256                }
    257                
     257
    258258                rc = vfs_read(fd, &pos, buff + copied_bytes, bytes_to_read,
    259259                    &bytes);
     
    283283                                        paged_char(c);
    284284                                }
    285                                
     285
    286286                        }
    287287                        count += bytes;
    288288                        reads++;
    289289                }
    290                
     290
    291291                if (reading_stdin)
    292292                        fflush(stdout);
     
    317317        sysarg_t rows, cols;
    318318        errno_t rc;
    319        
     319
    320320        /*
    321321         * reset global state
     
    392392        if (buffer < 4)
    393393                buffer = CAT_DEFAULT_BUFLEN;
    394        
     394
    395395        if (more) {
    396396                rc = console_get_size(console, &cols, &rows);
  • uspace/app/bdsh/cmds/modules/cmp/cmp.c

    r3061bc1 ra35b458  
    120120        unsigned int argc;
    121121        int c, opt_ind;
    122        
     122
    123123        argc = cli_count_args(argv);
    124124
  • uspace/app/bdsh/cmds/modules/cp/cp.c

    r3061bc1 ra35b458  
    196196                str_cpy(src_path, src_len + 1, src);
    197197                str_rtrim(src_path, '/');
    198                
     198
    199199                /* Get the last component name from the src path */
    200200                src_fname = get_last_path_component(src_path);
    201                
     201
    202202                /* Initialize dest_path with the dest argument */
    203203                str_cpy(dest_path, PATH_MAX, dest);
     
    206206                        /* e.g. cp file_name /data */
    207207                        /* e.g. cp file_name /data/ */
    208                        
     208
    209209                        /* dest is a directory,
    210210                         * append the src filename to it.
  • uspace/app/bdsh/cmds/modules/kcon/kcon.c

    r3061bc1 ra35b458  
    4343{
    4444        printf("`kcon' switches to the kernel debug console.\n");
    45        
     45
    4646        if (level != HELP_SHORT)
    4747                printf("Usage: %s\n", cmdname);
    48        
     48
    4949        return;
    5050}
     
    5454{
    5555        unsigned int argc = cli_count_args(argv);
    56        
     56
    5757        if (argc != 1) {
    5858                printf("%s - incorrect number of arguments. Try `%s --help'\n",
     
    6060                return CMD_FAILURE;
    6161        }
    62        
     62
    6363        if (console_kcon())
    6464                return CMD_SUCCESS;
  • uspace/app/bdsh/cmds/modules/ls/ls.c

    r3061bc1 ra35b458  
    111111        struct dir_elem_t const *da = a;
    112112        struct dir_elem_t const *db = b;
    113        
     113
    114114        if ((da->s.is_directory && db->s.is_file) ||
    115115            ((da->s.is_directory == db->s.is_directory) &&
     
    141141        struct dir_elem_t *tosort;
    142142        struct dirent *dp;
    143        
     143
    144144        if (!dirp)
    145145                return -1;
     
    150150                return -1;
    151151        }
    152        
     152
    153153        tosort = (struct dir_elem_t *) malloc(alloc_blocks * sizeof(*tosort));
    154154        if (!tosort) {
     
    157157                return -1;
    158158        }
    159        
     159
    160160        while ((dp = readdir(dirp))) {
    161161                if (nbdirs + 1 > alloc_blocks) {
    162162                        alloc_blocks += alloc_blocks;
    163                        
     163
    164164                        tmp = (struct dir_elem_t *) realloc(tosort,
    165165                            alloc_blocks * sizeof(struct dir_elem_t));
     
    170170                        tosort = tmp;
    171171                }
    172                
     172
    173173                /* fill the name field */
    174174                tosort[nbdirs].name = (char *) malloc(str_size(dp->d_name) + 1);
     
    189189                }
    190190        }
    191        
     191
    192192        if (ls.sort)
    193193                qsort(&tosort[0], nbdirs, sizeof(struct dir_elem_t), ls_cmp);
    194        
     194
    195195        for (i = 0; i < nbdirs; i++)
    196196                ls_print(&tosort[i]);
     
    214214                }
    215215        }
    216        
     216
    217217out:
    218218        for(i = 0; i < nbdirs; i++)
     
    239239        DIR *subdirp;
    240240        struct dir_elem_t *dir_list;
    241        
     241
    242242        const char * const trailing_slash = "/";
    243243
     
    294294                }
    295295        }
    296    
     296
    297297        ret = CMD_SUCCESS;
    298298
     
    355355
    356356        argc = cli_count_args(argv);
    357        
     357
    358358        for (c = 0, optreset = 1, optind = 0, opt_ind = 0; c != -1;) {
    359359                c = getopt_long(argc, argv, "hur", long_options, &opt_ind);
  • uspace/app/bdsh/cmds/modules/mkfile/mkfile.c

    r3061bc1 ra35b458  
    171171        if (create_sparse && file_size > 0) {
    172172                const char byte = 0x00;
    173                
     173
    174174                pos = file_size - 1;
    175175                rc = vfs_write(fd, &pos, &byte, sizeof(char), &nwritten);
  • uspace/app/bdsh/cmds/modules/printf/printf.c

    r3061bc1 ra35b458  
    5555        }
    5656
    57        
     57
    5858        return;
    5959}
  • uspace/app/bdsh/cmds/modules/rm/rm.c

    r3061bc1 ra35b458  
    189189
    190190        closedir(dirp);
    191        
     191
    192192        return ret;
    193193}
  • uspace/app/bdsh/cmds/modules/touch/touch.c

    r3061bc1 ra35b458  
    6969                    cmdname);
    7070        }
    71        
     71
    7272        return;
    7373}
     
    8585        int fd = -1;
    8686        char *buff = NULL;
    87        
     87
    8888        DIR *dirp;
    89        
     89
    9090        for (c = 0, optreset = 1, optind = 0, longind = 0; c != -1; ) {
    9191                c = getopt_long(argc, argv, "c", long_options, &longind);
     
    9696                }
    9797        }
    98        
     98
    9999        if (argc - optind < 1) {
    100100                printf("%s: Incorrect number of arguments. Try `help %s extended'\n",
     
    102102                return CMD_FAILURE;
    103103        }
    104        
     104
    105105        for (i = optind; argv[i] != NULL; i++) {
    106106                buff = str_dup(argv[i]);
     
    110110                        continue;
    111111                }
    112                
     112
    113113                dirp = opendir(buff);
    114114                if (dirp) {
     
    119119                        continue;
    120120                }
    121                
     121
    122122                /* Check whether file exists if -c (--no-create) option is given */
    123123                if ((!no_create) ||
     
    128128                        }
    129129                }
    130                
     130
    131131                if (fd < 0) {
    132132                        cli_error(CL_EFAIL, "Could not update or create `%s'", buff);
     
    138138                        fd = -1;
    139139                }
    140                
     140
    141141                free(buff);
    142142        }
    143        
     143
    144144        if (ret)
    145145                return CMD_FAILURE;
Note: See TracChangeset for help on using the changeset viewer.