home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / utils / shell / xd-2.08 / xd-2 / xd / Command / Command.cc next >
Encoding:
C/C++ Source or Header  |  1994-05-09  |  687 b   |  31 lines

  1. #include "Command.h"
  2.  
  3. Command::Command(Args const &args, Config const &cf)
  4. {
  5.     char const
  6.          *cp;
  7.     register unsigned
  8.         len;
  9.     
  10.     config = &cf;                // only a reference. no copy
  11.     pattern = 0;                // initialize pattern to 0
  12.  
  13.     command = new char;            // initialize to empty str.
  14.     *command = 0;
  15.     len = 1;                // strlen(command)
  16.  
  17.     for                    // walk all arguments
  18.     (
  19.         register int index = 1;        // as long as there are any
  20.              cp = args.get_string(index);
  21.                 index++
  22.     )
  23.     {
  24.         len += strlen(cp) + 1;        // new length of command
  25.         command = (char *)realloc(command, len);
  26.         strcat(command, cp);        // append the arg, and
  27.         strcat(command, "/");        // append a '/' separator
  28.     }
  29. }                        // all args catenated
  30.  
  31.