File: determineaction.cc

package info (click to toggle)
xd 5.00.03-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 708 kB
  • sloc: cpp: 1,852; fortran: 161; makefile: 107; sh: 36; ansic: 30
file content (41 lines) | stat: -rw-r--r-- 1,149 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "command.ih"

    // by command1.cc

void Command::determineAction()
{
    switch (int ch = d_arguments[0])     // Interpret the first character
    {
        case '0':               // from parent 0 or cwd
            d_action = FROM_CWD;
        break;

        case '/':           // explicitly from the root
            d_action = FROM_ROOT;
        break;              // breaks remove the 1st char from args

        // start from a parent
        case '1' ... '9':
            d_parent = ch - '0';
            d_action = FROM_PARENT;
        break;

        // other characters: 1st char. of directory or homedir char (~).
        default:
            if (ch == d_homedirChar)
            {
                d_action = FROM_HOME;
                break;
            }

            d_action =  FROM_CONFIG;
        return;
    }

    do
        d_arguments.erase(0, 1);      // remove the 1st (location) character
    while (d_arguments.front() == '/'); // and a possible initial / sep.

    imsg << "After removing the initial location/dir character(s): `" <<
                                            d_arguments << '\'' << endl;
}