Changeset 43e02a6 in mainline


Ignore:
Timestamp:
2008-08-29T11:07:22Z (16 years ago)
Author:
Tim Post <echo@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0c4f46a
Parents:
3771a6e
Message:

Just make cli_count_args() a function

Location:
uspace/app/bdsh
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/builtins/cd/cd.c

    r3771a6e r43e02a6  
    6363        int argc, rc = 0;
    6464
    65         for (argc = 0; argv[argc] != NULL; argc ++);
     65        argc = cli_count_args(argv);
    6666
    6767        /* We don't yet play nice with whitespace, a getopt implementation should
  • uspace/app/bdsh/cmds/modules/cat/cat.c

    r3771a6e r43e02a6  
    139139        int c, opt_ind;
    140140
    141         for (argc = 0; argv[argc] != NULL; argc ++);
     141        argc = cli_count_args(argv);
    142142
    143143        for (c = 0, optind = 0, opt_ind = 0; c != -1;) {
  • uspace/app/bdsh/cmds/modules/help/help.c

    r3771a6e r43e02a6  
    3232#include <stdlib.h>
    3333#include <string.h>
     34
     35#include "config.h"
    3436#include "entry.h"
    3537#include "help.h"
     
    3840#include "builtins.h"
    3941#include "errors.h"
     42#include "util.h"
    4043
    4144static char *cmdname = "help";
     
    9699        int level = HELP_SHORT;
    97100
    98         for (argc = 0; argv[argc] != NULL; argc ++);
     101        argc = cli_count_args(argv);
    99102
    100103        if (argc > 3) {
  • uspace/app/bdsh/cmds/modules/ls/ls.c

    r3771a6e r43e02a6  
    153153        DIR *dirp;
    154154
    155         /* Count the arguments */
    156         for (argc = 0; argv[argc] != NULL; argc ++);
     155        argc = cli_count_args(argv);
    157156
    158157        buff = (char *) malloc(PATH_MAX);
  • uspace/app/bdsh/cmds/modules/mkdir/mkdir.c

    r3771a6e r43e02a6  
    189189        char *cwd;
    190190
    191         for (argc = 0; argv[argc] != NULL; argc ++);
     191        argc = cli_count_args(argv);
    192192
    193193        for (c = 0, optind = 0, opt_ind = 0; c != -1;) {
  • uspace/app/bdsh/cmds/modules/rm/rm.c

    r3771a6e r43e02a6  
    174174        char *buff = NULL;
    175175
    176         for (argc = 0; argv[argc] != NULL; argc ++);
     176        argc = cli_count_args(argv);
     177
    177178        if (argc < 2) {
    178179                cli_error(CL_EFAIL,
  • uspace/app/bdsh/cmds/modules/touch/touch.c

    r3771a6e r43e02a6  
    7171        DIR *dirp;
    7272
    73         /* Count the arguments */
    74         for (argc = 0; argv[argc] != NULL; argc ++);
     73        argc = cli_count_args(argv);
    7574
    7675        if (argc == 1) {
  • uspace/app/bdsh/util.c

    r3771a6e r43e02a6  
    238238        return (cli_strtok_r(s, delim, &last));
    239239}
     240
     241/* Count and return the # of elements in an array */
     242unsigned int cli_count_args(char **args)
     243{
     244        unsigned int i;
     245
     246        for (i=0; args[i] != NULL; i++);
     247        return i;
     248}
     249
  • uspace/app/bdsh/util.h

    r3771a6e r43e02a6  
    88extern char * cli_strtok_r(char *, const char *, char **);
    99extern char * cli_strtok(char *, const char *);
     10extern unsigned int cli_count_args(char **);
    1011
    1112#endif
Note: See TracChangeset for help on using the changeset viewer.