Changeset 44 for trunk/src/kShell/kShell.c
- Timestamp:
- Mar 28, 2003, 12:22:18 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kShell/kShell.c
r23 r44 254 254 #define KSHELL_WILDCHAR(ch) ( (ch) == '*' || (ch) == '?' ) 255 255 256 /** 257 * the a default kShell slash. 258 */ 259 #define KSHELL_SLASH '/' 260 261 /** 262 * Checks if the character is a slash or not. 263 */ 264 #define KSHELL_ISSLASH(ch) ( (ch) == KSHELL_SLASH ) 256 265 257 266 … … 432 441 pWords = kshellWordsParse(pszCmd, 1, NULL); 433 442 if (!pWords) 434 return KSHELL_ERROR_NOT_ENOUGH T_MEMORY;443 return KSHELL_ERROR_NOT_ENOUGH_MEMORY; 435 444 if (!pWords->cWords) 436 445 return 0; … … 455 464 pWords = kshellWordsParse(pszCmd, aCmds[i].cWords, pWords); 456 465 if (!pWords) 457 return KSHELL_ERROR_NOT_ENOUGH T_MEMORY;466 return KSHELL_ERROR_NOT_ENOUGH_MEMORY; 458 467 } 459 468 rc = aCmds[i].pfnCmd(pszCmd, pWords); … … 688 697 int kshellCmd_copy(const char *pszCmd, PKSHELLWORDS pWords) 689 698 { 699 int iDst = pWords->cWords - 1; /* Last word is destination. */ 700 KBOOL fDstDir = -1; 701 int iSrc; 702 703 /* 704 * Syntax validation. 705 */ 706 if (pWords->cWords < 3) 707 return kshellSyntaxError("copy", "too few arguments."); 708 709 /* 710 * Figure out if the destion is a directory or file specification. 711 */ 712 if (KSHELL_ISSLASH(pWords->aWords[iDst].pszWord[pWords->aWords[iDst].cchWord - 1])) 713 { 714 fDstDir = TRUE; 715 while (KSHELL_ISSLASH(pWords->aWords[iDst].pszWord[pWords->aWords[iDst].cchWord - 1])) 716 pWords->aWords[iDst].cchWord--; 717 pWords->aWords[iDst].pszWord[pWords->aWords[iDst].cchWord] = '\0'; 718 } 719 else 720 fDstDir = kDirExist(pWords->aWords[iDst].pszWord); 721 722 /* 723 * Copy sources to destination. 724 */ 725 for (iSrc = 1; iSrc < iDst && !rc; iSrc++) 726 { 727 if (pWords->aWords[iSrc].fFlags & KSWORD_FLAGS_PATTERN) 728 { 729 /* 730 * 731 */ 732 } 733 else 734 { /* 735 * Construct destination name. 736 */ 737 char *pszDst; 738 KBOOL fDstFree = FALSE; 739 if (fDstDir) 740 { 741 fDstFree = TRUE; 742 pszDst = malloc(pWords->aWords[iDst].cchWord + 1 + pWords->aWords[iSrc].cchWord + 1); 743 if (pszDst) 744 return KSHELL_ERROR_NOT_ENOUGH_MEMORY; 745 kMemCpy(pszDst, pWords->aWords[iDst].pszWord, pWords->aWords[iDst].cchWord); 746 pszDst[pWords->aWords[iDst].cchWord] = KSHELL_SLASH; 747 kMemCpy(pszDst + pWords->aWords[iDst].cchWord + 1, 748 pWords->aWords[iSrc].pszWord 749 pWords->aWords[iSrc].cchWord + 1); 750 } 751 else 752 pszDst = pWords->aWords[iDst].pszWord; 753 754 /* 755 * Do the copy. 756 */ 757 rc = kFileCopy(pWords->aWords[iSrc].pszWord, pszDst); 758 if (rc) 759 { 760 kshellError("copy", "failed to copy '%s' to '%s' rc=%d.", 761 pWords->aWords[iSrc].pszWord, 762 pDst, rc); 763 } 764 765 if (fDstFree) 766 free(pszDst); 767 } 768 } 769 690 770 return -1; 691 771 } … … 787 867 if (pWords->cWords >= 2) 788 868 { 789 unsigned uMsgLevel = kStrToU nsigned(pWords->aWords[1].pszWord, -2);869 unsigned uMsgLevel = kStrToUDef(pWords->aWords[1].pszWord, -2, 0); 790 870 if (uMsgLevel != -2) 791 871 { 792 if (uMsgLevel <= kEnvGetU nsigned("KBUILD_MSG_LEVEL", 0))872 if (uMsgLevel <= kEnvGetUDef("KBUILD_MSG_LEVEL", 0, 0)) 793 873 { 794 874 /* output all the words forcing one space separation */
Note:
See TracChangeset
for help on using the changeset viewer.