Changeset ec7f8b1 in mainline for uspace/app/bdsh


Ignore:
Timestamp:
2011-08-21T15:35:03Z (13 years ago)
Author:
Petr Koupy <petr.koupy@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bb74dabe
Parents:
c4a8e4a (diff), 5935c079 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
uspace/app/bdsh
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/Makefile

    rc4a8e4a rec7f8b1  
    2929
    3030USPACE_PREFIX = ../..
    31 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBCLUI_PREFIX)/libclui.a
    32 EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I$(LIBCLUI_PREFIX) -I. -Icmds/ \
    33         -Icmds/builtins -Icmds/modules
     31LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBCLUI_PREFIX)/libclui.a \
     32        $(LIBFMTUTIL_PREFIX)/libfmtutil.a
     33EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I$(LIBCLUI_PREFIX) \
     34        -I$(LIBFMTUTIL_PREFIX) -I. -Icmds/ -Icmds/builtins -Icmds/modules
    3435BINARY = bdsh
    3536
  • uspace/app/bdsh/cmds/modules/help/help.c

    rc4a8e4a rec7f8b1  
    11/*
    22 * Copyright (c) 2008 Tim Post
     3 * Copyright (c) 2011 Martin Sucha
    34 * All rights reserved.
    45 *
     
    3031#include <stdlib.h>
    3132#include <str.h>
     33#include <fmtutil.h>
    3234
    3335#include "config.h"
     
    128130static void help_survival(void)
    129131{
    130         printf("Don't panic!\n\n");
    131 
    132         printf("This is Bdsh, the Brain dead shell, currently "
     132        print_wrapped_console(
     133            "Don't panic!\n\n"
     134
     135            "This is Bdsh, the Brain dead shell, currently "
    133136            "the primary user interface to HelenOS. Bdsh allows you to enter "
    134137            "commands and supports history (Up, Down arrow keys), "
    135138            "line editing (Left Arrow, Right Arrow, Home, End, Backspace), "
    136139            "selection (Shift + movement keys), copy and paste (Ctrl-C, "
    137             "Ctrl-V), similar to common desktop environments.\n\n");
    138 
    139         printf("The most basic filesystem commands are Bdsh builtins. Type "
     140            "Ctrl-V), similar to common desktop environments.\n\n"
     141
     142            "The most basic filesystem commands are Bdsh builtins. Type "
    140143            "'help commands' [Enter] to see the list of Bdsh builtin commands. "
    141144            "Other commands are external executables located in the /app and "
    142145            "/srv directories. Type 'ls /app' [Enter] and 'ls /srv' [Enter] "
    143146            "to see their list. You can execute an external command simply "
    144             "by entering its name (e.g. type 'tetris' [Enter]).\n\n");
    145 
    146         printf("HelenOS has virtual consoles (VCs). You can switch between "
    147             "these using the F1-F11 keys.\n\n");
    148 
    149         printf("This is but a small glimpse of what you can do with HelenOS. "
     147            "by entering its name (e.g. type 'tetris' [Enter]).\n\n"
     148
     149            "HelenOS has virtual consoles (VCs). You can switch between "
     150            "these using the F1-F11 keys.\n\n"
     151
     152            "This is but a small glimpse of what you can do with HelenOS. "
    150153            "To learn more please point your browser to the HelenOS User's "
    151             "Guide: http://trac.helenos.org/trac.fcgi/wiki/UsersGuide\n\n");
     154            "Guide: http://trac.helenos.org/wiki/UsersGuide\n\n",
     155            ALIGN_LEFT);
    152156}
    153157
  • uspace/app/bdsh/compl.c

    rc4a8e4a rec7f8b1  
    9090{
    9191        compl_t *cs = NULL;
    92         size_t pref_size;
    9392        char *stext = NULL;
    9493        char *prefix = NULL;
    9594        char *dirname = NULL;
     95        int retval;
     96       
     97        token_t *tokens = calloc(WORD_MAX, sizeof(token_t));
     98        if (tokens == NULL) {
     99                retval = ENOMEM;
     100                goto error;
     101        }
     102       
     103        size_t pref_size;
    96104        char *rpath_sep;
    97105        static const char *dirlist_arg[] = { ".", NULL };
    98         int retval;
    99106        tokenizer_t tok;
    100         token_t tokens[WORD_MAX];
    101         unsigned int current_token;
     107        ssize_t current_token;
    102108        size_t tokens_length;
    103 
     109       
    104110        cs = calloc(1, sizeof(compl_t));
    105111        if (!cs) {
     
    107113                goto error;
    108114        }
    109 
     115       
    110116        /* Convert text buffer to string */
    111117        stext = wstr_to_astr(text);
     
    127133       
    128134        /* Find the current token */
    129         for (current_token = 0; current_token < tokens_length; current_token++) {
     135        for (current_token = 0; current_token < (ssize_t) tokens_length;
     136            current_token++) {
    130137                token_t *t = &tokens[current_token];
    131138                size_t end = t->char_start + t->char_length;
    132                 /* Check if the caret lies inside the token or immediately
     139               
     140                /*
     141                 * Check if the caret lies inside the token or immediately
    133142                 * after it
    134143                 */
     
    138147        }
    139148       
    140         if (tokens[current_token].type != TOKTYPE_SPACE) {
     149        if (tokens_length == 0)
     150                current_token = -1;
     151       
     152        if ((current_token >= 0) && (tokens[current_token].type != TOKTYPE_SPACE))
    141153                *cstart = tokens[current_token].char_start;
    142         }
    143         else {
     154        else
    144155                *cstart = pos;
    145         }
    146        
    147         /* Extract the prefix being completed
     156       
     157        /*
     158         * Extract the prefix being completed
    148159         * XXX: handle strings, etc.
    149160         */
     
    154165                goto error;
    155166        }
    156 
    157         str_ncpy(prefix, pref_size + 1, stext +
    158             tokens[current_token].byte_start, pref_size);
     167        prefix[pref_size] = 0;
     168
     169        if (current_token >= 0) {
     170                str_ncpy(prefix, pref_size + 1, stext +
     171                    tokens[current_token].byte_start, pref_size);
     172        }
    159173
    160174        /*
     
    165179
    166180        /* Skip any whitespace before current token */
    167         int prev_token = current_token - 1;
    168         if (prev_token != -1 && tokens[prev_token].type == TOKTYPE_SPACE) {
     181        ssize_t prev_token = current_token - 1;
     182        if ((prev_token >= 0) && (tokens[prev_token].type == TOKTYPE_SPACE))
    169183                prev_token--;
    170         }
    171 
     184       
    172185        /*
    173186         * It is a command if it is the first token or if it immediately
    174187         * follows a pipe token.
    175188         */
    176         if (prev_token == -1 || tokens[prev_token].type == TOKTYPE_SPACE)
     189        if ((prev_token < 0) || (tokens[prev_token].type == TOKTYPE_SPACE))
    177190                cs->is_command = true;
    178191        else
     
    249262        if (cs != NULL)
    250263                free(cs);
     264        if (tokens != NULL)
     265                free(tokens);
    251266
    252267        return retval;
  • uspace/app/bdsh/input.c

    rc4a8e4a rec7f8b1  
    6767int process_input(cliuser_t *usr)
    6868{
     69        token_t *tokens = calloc(WORD_MAX, sizeof(token_t));
     70        if (tokens == NULL)
     71                return ENOMEM;
     72       
    6973        char *cmd[WORD_MAX];
    70         token_t tokens_space[WORD_MAX];
    71         token_t *tokens = tokens_space;
    7274        int rc = 0;
    7375        tokenizer_t tok;
     
    7779        char *redir_to = NULL;
    7880
    79         if (NULL == usr->line)
     81        if (usr->line == NULL) {
     82                free(tokens);
    8083                return CL_EFAIL;
     84        }
    8185
    8286        rc = tok_init(&tok, usr->line, tokens, WORD_MAX);
     
    209213        }
    210214        tok_fini(&tok);
     215        free(tokens);
    211216
    212217        return rc;
Note: See TracChangeset for help on using the changeset viewer.