Author: hbelusca Date: Mon May 20 17:43:37 2013 New Revision: 59055 URL: http://svn.reactos.org/svn/reactos?rev=59055&view=rev Log: [CMD] - Simplify CommandColor and document it. Checking whether one sets the same color for both foreground and background is now only checked inside SetScreenColor. Based on a patch by Victor CORE-7191 #resolve #comment Committed in rev.59055.
- Fix handling of /T:<color> option when starting cmd.exe - Remove unneeded error string. Modified: trunk/reactos/base/shell/cmd/cmd.c trunk/reactos/base/shell/cmd/cmd.h trunk/reactos/base/shell/cmd/color.c trunk/reactos/base/shell/cmd/lang/de-DE.rc trunk/reactos/base/shell/cmd/lang/el-GR.rc trunk/reactos/base/shell/cmd/lang/en-US.rc trunk/reactos/base/shell/cmd/lang/es-ES.rc trunk/reactos/base/shell/cmd/lang/fr-FR.rc trunk/reactos/base/shell/cmd/lang/hu-HU.rc trunk/reactos/base/shell/cmd/lang/id-ID.rc trunk/reactos/base/shell/cmd/lang/it-IT.rc trunk/reactos/base/shell/cmd/lang/ja-JP.rc trunk/reactos/base/shell/cmd/lang/no-NO.rc trunk/reactos/base/shell/cmd/lang/pl-PL.rc trunk/reactos/base/shell/cmd/lang/ro-RO.rc trunk/reactos/base/shell/cmd/lang/ru-RU.rc trunk/reactos/base/shell/cmd/lang/sk-SK.rc trunk/reactos/base/shell/cmd/lang/sv-SE.rc trunk/reactos/base/shell/cmd/lang/uk-UA.rc trunk/reactos/base/shell/cmd/lang/zh-CN.rc trunk/reactos/base/shell/cmd/resource.h trunk/reactos/base/shell/cmd/strtoclr.c Modified: trunk/reactos/base/shell/cmd/cmd.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmd.c?rev=59055&r1=59054&r2=59055&view=diff ============================================================================== --- trunk/reactos/base/shell/cmd/cmd.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/cmd.c [iso-8859-1] Mon May 20 17:43:37 2013 @@ -1733,9 +1733,9 @@ #ifdef INCLUDE_CMD_COLOR else if (!_tcsnicmp(ptr, _T("/T:"), 3)) { - /* process /t (color) argument */ + /* process /T (color) argument */ wDefColor = (WORD)_tcstoul(&ptr[3], &ptr, 16); - SetScreenColor(wDefColor, TRUE); + SetScreenColor(wDefColor, FALSE); } #endif else if (option == _T('U')) Modified: trunk/reactos/base/shell/cmd/cmd.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmd.h?rev=59055&r1=59054&r2=59055&view=diff ============================================================================== --- trunk/reactos/base/shell/cmd/cmd.h [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/cmd.h [iso-8859-1] Mon May 20 17:43:37 2013 @@ -144,7 +144,7 @@ LPCTSTR GetParsedEnvVar ( LPCTSTR varName, UINT* varNameLen, BOOL ModeSetA ); /* Prototypes for COLOR.C */ -VOID SetScreenColor(WORD wArgColor, BOOL bFill); +BOOL SetScreenColor(WORD wColor, BOOL bNoFill); INT CommandColor (LPTSTR); VOID ConInDummy (VOID); Modified: trunk/reactos/base/shell/cmd/color.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/color.c?rev=59055&r1=59054&r2=59055&view=diff ============================================================================== --- trunk/reactos/base/shell/cmd/color.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/color.c [iso-8859-1] Mon May 20 17:43:37 2013 @@ -24,34 +24,34 @@ #ifdef INCLUDE_CMD_COLOR -VOID SetScreenColor (WORD wColor, BOOL bNoFill) +BOOL SetScreenColor(WORD wColor, BOOL bNoFill) { HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); DWORD dwWritten; CONSOLE_SCREEN_BUFFER_INFO csbi; COORD coPos; + /* Foreground and Background colors can't be the same */ + if ((wColor & 0x0F) == (wColor & 0xF0) >> 4) + return FALSE; - if ((wColor & 0xF) == (wColor &0xF0) >> 4) + /* Fill the whole background if needed */ + if (bNoFill != TRUE) { - ConErrResPuts(STRING_COLOR_ERROR1); + GetConsoleScreenBufferInfo(hConsole, &csbi); + + coPos.X = 0; + coPos.Y = 0; + FillConsoleOutputAttribute(hConsole, + wColor & 0x00FF, + csbi.dwSize.X * csbi.dwSize.Y, + coPos, + &dwWritten); } - else - { - if (bNoFill != TRUE) - { - GetConsoleScreenBufferInfo (hConsole, &csbi); - coPos.X = 0; - coPos.Y = 0; - FillConsoleOutputAttribute (hConsole, - (WORD)(wColor & 0x00FF), - (csbi.dwSize.X)*(csbi.dwSize.Y), - coPos, - &dwWritten); - } - SetConsoleTextAttribute (hConsole, (WORD)(wColor & 0x00FF)); - } + /* Set the text attribute */ + SetConsoleTextAttribute(hConsole, wColor & 0x00FF); + return TRUE; } /* @@ -59,73 +59,77 @@ * * internal dir command */ -INT CommandColor (LPTSTR rest) +INT CommandColor(LPTSTR rest) { - WORD wColor; + WORD wColor = 0x00; - if (_tcsncmp (rest, _T("/?"), 2) == 0) + /* The user asked for help */ + if (_tcsncmp(rest, _T("/?"), 2) == 0) { - ConOutResPaging(TRUE,STRING_COLOR_HELP1); + ConOutResPaging(TRUE, STRING_COLOR_HELP1); return 0; } + /* Let's prepare %ERRORLEVEL% */ nErrorLevel = 0; + /* No parameter. Set the default colors */ if (rest[0] == _T('\0')) { - /* set default color */ - wColor = wDefColor; - SetScreenColor (wColor, FALSE); + SetScreenColor(wDefColor, FALSE); return 0; } - - if ( _tcslen(&rest[0])==1) + /* The parameter is just one character: Set color text */ + if (_tcslen(rest) == 1) { - HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); - if ( (_tcscmp(&rest[0], _T("0")) >=0 ) && (_tcscmp(&rest[0], _T("9")) <=0 ) ) - { - SetConsoleTextAttribute (hConsole, (WORD)_ttoi(rest)); - return 0; - } - else if ( (_tcscmp(&rest[0], _T("a")) >=0 ) && (_tcscmp(&rest[0], _T("f")) <=0 ) ) - { - SetConsoleTextAttribute (hConsole, (WORD) (rest[0] + 10 - _T('a')) ); - return 0; - } - else if ( (_tcscmp(&rest[0], _T("A")) >=0 ) && (_tcscmp(&rest[0], _T("F")) <=0 ) ) - { - SetConsoleTextAttribute (hConsole, (WORD) (rest[0] + 10 - _T('A')) ); - return 0; - } - ConErrResPuts(STRING_COLOR_ERROR2); - nErrorLevel = 1; - return 1; + if ((rest[0] >= _T('0')) && (rest[0] <= _T('9'))) + { + wColor = (WORD)_ttoi(rest); + } + else if ((rest[0] >= _T('a')) && (rest[0] <= _T('f'))) + { + wColor = (WORD)(rest[0] + 10 - _T('a')); + } + else if ((rest[0] >= _T('A')) && (rest[0] <= _T('F'))) + { + wColor = (WORD)(rest[0] + 10 - _T('A')); + } + else /* Invalid character */ + { + ConOutResPaging(TRUE, STRING_COLOR_HELP1); + nErrorLevel = 1; + return 1; + } } - - if (StringToColor(&wColor, &rest) == FALSE) + /* Color string: advanced choice: two-digits, "Color ON Color" , "Foreground ON Background" */ + else if (StringToColor(&wColor, &rest) == FALSE) { - ConErrResPuts(STRING_COLOR_ERROR2); + /* Invalid color string */ + ConOutResPaging(TRUE, STRING_COLOR_HELP1); nErrorLevel = 1; return 1; } - if (((bc) && (bc->bEcho)) || !bc) + /* Print the chosen color if we are in echo mode (NOTE: Not Windows-compliant) */ + if ((bc && bc->bEcho) || !bc) { ConErrResPrintf(STRING_COLOR_ERROR3, wColor); } - if ((wColor & 0xF) == (wColor &0xF0) >> 4) + /* + * Set the chosen color. Use also the following advanced flag: + * /-F to avoid changing already buffered foreground/background. + */ + if (SetScreenColor(wColor, (_tcsstr(rest, _T("/-F")) || _tcsstr(rest, _T("/-f")))) == FALSE) { - ConErrResPrintf(STRING_COLOR_ERROR4, wColor); + /* Failed because foreground and background colors were the same */ + ConErrResPuts(STRING_COLOR_ERROR1); nErrorLevel = 1; return 1; } - /* set color */ - SetScreenColor(wColor, - (_tcsstr (rest,_T("/-F")) || _tcsstr (rest,_T("/-f")))); - + /* Return success */ return 0; } Modified: trunk/reactos/base/shell/cmd/lang/de-DE.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/lang/de-DE.rc?rev=59055&r1=59054&r2=59055&view=diff ============================================================================== --- trunk/reactos/base/shell/cmd/lang/de-DE.rc [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/lang/de-DE.rc [iso-8859-1] Mon May 20 17:43:37 2013 @@ -634,7 +634,6 @@ STRING_COLOR_ERROR1, "Fehler: Hinter- und Vordergrund können nicht die selben Farben haben!" STRING_COLOR_ERROR2, "Fehler in der Farbangabe" STRING_COLOR_ERROR3, "Farbe %x\n" -STRING_COLOR_ERROR4, "Fehler: Die selben Farben!" STRING_CONSOLE_ERROR, "Unbekannter Fehler: %d\n" STRING_COPY_ERROR1, "Fehler: Quelle kann nicht geöffnet werden - %s!\n" STRING_COPY_ERROR2, "Fehler: Kann nicht über sich selbst kopiert werden.\n" Modified: trunk/reactos/base/shell/cmd/lang/el-GR.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/lang/el-GR.rc?rev=59055&r1=59054&r2=59055&view=diff ============================================================================== --- trunk/reactos/base/shell/cmd/lang/el-GR.rc [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/lang/el-GR.rc [iso-8859-1] Mon May 20 17:43:37 2013 @@ -634,7 +634,6 @@ STRING_COLOR_ERROR1, "Same colors error! (Background and foreground can't be the same color)" STRING_COLOR_ERROR2, "error in color specification" STRING_COLOR_ERROR3, "Color %x\n" -STRING_COLOR_ERROR4, "same colors error!" STRING_CONSOLE_ERROR, "ÎγνÏÏÏο ÏÏάλμα: %d\n" STRING_COPY_ERROR1, "ΣÏάλμα: Îεν ήÏαν Î´Ï Î½Î±ÏÏ Ïο άνοιγμα ÏÎ·Ï ÏÎ·Î³Î®Ï - %s!\n" STRING_COPY_ERROR2, "ΣÏάλμα: Can't copy onto itself!\n" Modified: trunk/reactos/base/shell/cmd/lang/en-US.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/lang/en-US.rc?rev=59055&r1=59054&r2=59055&view=diff ============================================================================== --- trunk/reactos/base/shell/cmd/lang/en-US.rc [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/lang/en-US.rc [iso-8859-1] Mon May 20 17:43:37 2013 @@ -637,7 +637,6 @@ STRING_COLOR_ERROR1, "Same colors error! (Background and foreground can't be the same color)" STRING_COLOR_ERROR2, "error in color specification" STRING_COLOR_ERROR3, "Color %x\n" -STRING_COLOR_ERROR4, "same colors error!" STRING_CONSOLE_ERROR, "Unknown error: %d\n" STRING_COPY_ERROR1, "Error: Cannot open source - %s!\n" STRING_COPY_ERROR2, "Error: Can't copy onto itself!\n" Modified: trunk/reactos/base/shell/cmd/lang/es-ES.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/lang/es-ES.rc?rev=59055&r1=59054&r2=59055&view=diff ============================================================================== --- trunk/reactos/base/shell/cmd/lang/es-ES.rc [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/lang/es-ES.rc [iso-8859-1] Mon May 20 17:43:37 2013 @@ -637,7 +637,6 @@ STRING_COLOR_ERROR1, "¡Mismos colores! (El color de frente y de fondo no pueden ser el mismo)" STRING_COLOR_ERROR2, "Error en la especificación del color" STRING_COLOR_ERROR3, "Color %x\n" -STRING_COLOR_ERROR4, "¡Error: mismos colores!" STRING_CONSOLE_ERROR, "Error desconocido: %d\n" STRING_COPY_ERROR1, "Error: No se puede abrir el origen - %s!\n" STRING_COPY_ERROR2, "Error: ¡No se puede copiar sobre si mismo!\n" Modified: trunk/reactos/base/shell/cmd/lang/fr-FR.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/lang/fr-FR.rc?rev=59055&r1=59054&r2=59055&view=diff ============================================================================== --- trunk/reactos/base/shell/cmd/lang/fr-FR.rc [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/lang/fr-FR.rc [iso-8859-1] Mon May 20 17:43:37 2013 @@ -652,7 +652,6 @@ STRING_COLOR_ERROR1, "L'arrière plan et l'avant plan ne peuvent être de la même couleur" STRING_COLOR_ERROR2, "Erreur dans la spécification des couleurs" STRING_COLOR_ERROR3, "Couleur %x\n" -STRING_COLOR_ERROR4, "Erreur : même couleur!" STRING_CONSOLE_ERROR, "Erreur inconnue : %d\n" STRING_COPY_ERROR1, "Erreur : Ne peut ouvrir la source - %s !\n" STRING_COPY_ERROR2, "Erreur : Ne peut copier le fichier sur lui-même !\n" Modified: trunk/reactos/base/shell/cmd/lang/hu-HU.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/lang/hu-HU.rc?rev=59055&r1=59054&r2=59055&view=diff ============================================================================== --- trunk/reactos/base/shell/cmd/lang/hu-HU.rc [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/lang/hu-HU.rc [iso-8859-1] Mon May 20 17:43:37 2013 @@ -616,7 +616,6 @@ STRING_COLOR_ERROR1, "Ugyanaz a szÃn nem lehet! (Az elõ- és háttérszÃn nem lehet ugyanolyan)" STRING_COLOR_ERROR2, "Hibás szÃn megadás" STRING_COLOR_ERROR3, "SzÃn %x\n" -STRING_COLOR_ERROR4, "Ugyanaz a szÃn nem lehet!" STRING_CONSOLE_ERROR, "Ismeretlen hiba: %d\n" STRING_COPY_ERROR1, "Hiba: a forrás nem nyitható meg - %s!\n" STRING_COPY_ERROR2, "Hiba: nem másolhatod önmagára az állományt!\n" Modified: trunk/reactos/base/shell/cmd/lang/id-ID.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/lang/id-ID.rc?rev=59055&r1=59054&r2=59055&view=diff ============================================================================== --- trunk/reactos/base/shell/cmd/lang/id-ID.rc [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/lang/id-ID.rc [iso-8859-1] Mon May 20 17:43:37 2013 @@ -636,7 +636,6 @@ STRING_COLOR_ERROR1, "Warna sama salah! (Latar belakang dan latar depan tidak bisa berwarna sama)" STRING_COLOR_ERROR2, "Kesalahan dalam spesifikasi warna" STRING_COLOR_ERROR3, "Warna %x\n" -STRING_COLOR_ERROR4, "warna sama salah!" STRING_CONSOLE_ERROR, "Kesalahan tidak dikenal: %d\n" STRING_COPY_ERROR1, "Salah: Tidak dapat membuka sumber - %s!\n" STRING_COPY_ERROR2, "Salah: Tidak dapat mengcopy ke dirinya sendiri!\n" Modified: trunk/reactos/base/shell/cmd/lang/it-IT.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/lang/it-IT.rc?rev=59055&r1=59054&r2=59055&view=diff ============================================================================== --- trunk/reactos/base/shell/cmd/lang/it-IT.rc [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/lang/it-IT.rc [iso-8859-1] Mon May 20 17:43:37 2013 @@ -642,7 +642,6 @@ STRING_COLOR_ERROR1, "Il colore di primo piano e sfondo non possono essere uguali" STRING_COLOR_ERROR2, "errore nella indicazione dei colori" STRING_COLOR_ERROR3, "Colore %x\n" -STRING_COLOR_ERROR4, "i colori non possono essere uguali!" STRING_CONSOLE_ERROR, "errore sconosciuto: %d\n" STRING_COPY_ERROR1, "Errore: Impossibile aprire il file sorgente - %s!\n" STRING_COPY_ERROR2, "Errore: Impossibile copiare un file su se stesso!\n" Modified: trunk/reactos/base/shell/cmd/lang/ja-JP.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/lang/ja-JP.rc?rev=59055&r1=59054&r2=59055&view=diff ============================================================================== --- trunk/reactos/base/shell/cmd/lang/ja-JP.rc [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/lang/ja-JP.rc [iso-8859-1] Mon May 20 17:43:37 2013 @@ -642,7 +642,6 @@ STRING_COLOR_ERROR1, "ã¨ã©ã¼! åãè²ãæå®ããã¾ããã\n (åæ¯è²ã¨èæ¯è²ãåãè²ã«ãããã¨ã¯ã§ãã¾ãã)" STRING_COLOR_ERROR2, "è²ã®æå®ã«åé¡ãããã¾ãã" STRING_COLOR_ERROR3, "Color %x\n" -STRING_COLOR_ERROR4, "ã¨ã©ã¼! åãè²ãæå®ããã¾ããã" STRING_CONSOLE_ERROR, "ä¸æãªã¨ã©ã¼: %d\n" STRING_COPY_ERROR1, "ã¨ã©ã¼: å ã®ãã¡ã¤ã« %s ãéãã¾ãã!\n" STRING_COPY_ERROR2, "ã¨ã©ã¼: ã³ãã¼å ã¨ã³ãã¼å ãä¸ç·ã§ã!\n" Modified: trunk/reactos/base/shell/cmd/lang/no-NO.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/lang/no-NO.rc?rev=59055&r1=59054&r2=59055&view=diff ============================================================================== --- trunk/reactos/base/shell/cmd/lang/no-NO.rc [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/lang/no-NO.rc [iso-8859-1] Mon May 20 17:43:37 2013 @@ -629,7 +629,6 @@ STRING_COLOR_ERROR1, "Samme farge feil! (Bakgrunn og forgrunn kan ikke ha samme farge)" STRING_COLOR_ERROR2, "feil i farge spesifikasjon" STRING_COLOR_ERROR3, "Farge %x\n" -STRING_COLOR_ERROR4, "samme farge feil!" STRING_CONSOLE_ERROR, "Ukjent feil: %d\n" STRING_COPY_ERROR1, "Feil: kan ikke Ã¥pne kilden - %s!\n" STRING_COPY_ERROR2, "Feil: kan ikke kopiere til seg selv!\n" Modified: trunk/reactos/base/shell/cmd/lang/pl-PL.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/lang/pl-PL.rc?rev=59055&r1=59054&r2=59055&view=diff ============================================================================== --- trunk/reactos/base/shell/cmd/lang/pl-PL.rc [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/lang/pl-PL.rc [iso-8859-1] Mon May 20 17:43:37 2013 @@ -637,7 +637,6 @@ STRING_COLOR_ERROR1, "BÅÄ d! Kolor tÅa i tekstu nie może byÄ taki sam" STRING_COLOR_ERROR2, "BÅÄ d w oznaczeniu kolorów." STRING_COLOR_ERROR3, "Kolor %x\n" -STRING_COLOR_ERROR4, "BÅÄ d - kolory takie same!" STRING_CONSOLE_ERROR, "Nieznany bÅÄ d: %d\n" STRING_COPY_ERROR1, "BÅÄ d: Nie można otworzyÄ ÅºródÅa - %s!\n" STRING_COPY_ERROR2, "BÅÄ d: Nie można przekopiowaÄ pliku na niego samego!\n" Modified: trunk/reactos/base/shell/cmd/lang/ro-RO.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/lang/ro-RO.rc?rev=59055&r1=59054&r2=59055&view=diff ============================================================================== --- trunk/reactos/base/shell/cmd/lang/ro-RO.rc [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/lang/ro-RO.rc [iso-8859-1] Mon May 20 17:43:37 2013 @@ -681,7 +681,6 @@ STRING_COLOR_ERROR1, "Eroare de culoare identicÄ! (Culorile nu trebuie sÄ fie identice)" STRING_COLOR_ERROR2, "Eroare la specificarea culorii" STRING_COLOR_ERROR3, "Culoare %x\n" -STRING_COLOR_ERROR4, "Eroare de culoare identicÄ!" STRING_CONSOLE_ERROR, "Eroare necunoscutÄ: %d\n" STRING_COPY_ERROR1, "Eroare: Nu se poate deschide fiÈierul - «%s»!\n" STRING_COPY_ERROR2, "Eroare: Nu se poate copia peste el însuÈi!\n" Modified: trunk/reactos/base/shell/cmd/lang/ru-RU.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/lang/ru-RU.rc?rev=59055&r1=59054&r2=59055&view=diff ============================================================================== --- trunk/reactos/base/shell/cmd/lang/ru-RU.rc [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/lang/ru-RU.rc [iso-8859-1] Mon May 20 17:43:37 2013 @@ -641,7 +641,6 @@ STRING_COLOR_ERROR1, "ÐдинаковÑе ÑвеÑа! (ЦвеÑа Ñона и ÑекÑÑа не могÑÑ Ð±ÑÑÑ Ð¾Ð´Ð¸Ð½Ð°ÐºÐ¾Ð²Ñми)" STRING_COLOR_ERROR2, "оÑибка в Ñказании ÑвеÑа" STRING_COLOR_ERROR3, "Ð¦Ð²ÐµÑ %x\n" -STRING_COLOR_ERROR4, "ÐдинаковÑе ÑвеÑа!" STRING_CONSOLE_ERROR, "ÐеизвеÑÑÐ½Ð°Ñ Ð¾Ñибка: %d\n" STRING_COPY_ERROR1, "ÐÑибка: Ðевозможно оÑкÑÑÑÑ Ð¸ÑÑоÑник - %s!\n" STRING_COPY_ERROR2, "ÐÑибка: Ðевозможно копиÑоваÑÑ Ð² ÑебÑ!\n" Modified: trunk/reactos/base/shell/cmd/lang/sk-SK.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/lang/sk-SK.rc?rev=59055&r1=59054&r2=59055&view=diff ============================================================================== --- trunk/reactos/base/shell/cmd/lang/sk-SK.rc [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/lang/sk-SK.rc [iso-8859-1] Mon May 20 17:43:37 2013 @@ -641,7 +641,6 @@ STRING_COLOR_ERROR1, "Same colors error! (Background and foreground can't be the same color)" STRING_COLOR_ERROR2, "error in color specification" STRING_COLOR_ERROR3, "Color %x\n" -STRING_COLOR_ERROR4, "same colors error!" STRING_CONSOLE_ERROR, "Neznáma chyba: %d\n" STRING_COPY_ERROR1, "Chyba: Cannot open source - %s!\n" STRING_COPY_ERROR2, "Chyba: Can't copy onto itself!\n" Modified: trunk/reactos/base/shell/cmd/lang/sv-SE.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/lang/sv-SE.rc?rev=59055&r1=59054&r2=59055&view=diff ============================================================================== --- trunk/reactos/base/shell/cmd/lang/sv-SE.rc [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/lang/sv-SE.rc [iso-8859-1] Mon May 20 17:43:37 2013 @@ -629,7 +629,6 @@ STRING_COLOR_ERROR1, "Samme farge feil! (Bakgrunn och forgrunn kan inte ha samme farge)" STRING_COLOR_ERROR2, "feil i farge spesifikasjon" STRING_COLOR_ERROR3, "Farge %x\n" -STRING_COLOR_ERROR4, "samme farge feil!" STRING_CONSOLE_ERROR, "Ukjent feil: %d\n" STRING_COPY_ERROR1, "Feil: kan inte Ã¥pne kilden - %s!\n" STRING_COPY_ERROR2, "Feil: kan inte kopiere til seg selv!\n" Modified: trunk/reactos/base/shell/cmd/lang/uk-UA.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/lang/uk-UA.rc?rev=59055&r1=59054&r2=59055&view=diff ============================================================================== --- trunk/reactos/base/shell/cmd/lang/uk-UA.rc [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/lang/uk-UA.rc [iso-8859-1] Mon May 20 17:43:37 2013 @@ -643,7 +643,6 @@ STRING_COLOR_ERROR1, "помилка - однаковi колÑоÑи! (Ñло Ñа ÑекÑÑ Ð½Ðµ можÑÑÑ Ð±ÑÑи однакового колÑоÑÑ)" STRING_COLOR_ERROR2, "помилка пÑи вказаннi колÑоÑÑ" STRING_COLOR_ERROR3, "ÐолiÑ %x\n" -STRING_COLOR_ERROR4, "помилка - однаковi колÑоÑи!" STRING_CONSOLE_ERROR, "Ðевiдома помилка: %d\n" STRING_COPY_ERROR1, "Ðомилка: Ðеможливо вiдкÑиÑи джеÑело - %s!\n" STRING_COPY_ERROR2, "Ðомилка: Ðеможливо копiÑваÑи в Ñебе!\n" Modified: trunk/reactos/base/shell/cmd/lang/zh-CN.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/lang/zh-CN.rc?rev=59055&r1=59054&r2=59055&view=diff ============================================================================== --- trunk/reactos/base/shell/cmd/lang/zh-CN.rc [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/lang/zh-CN.rc [iso-8859-1] Mon May 20 17:43:37 2013 @@ -601,7 +601,6 @@ STRING_COLOR_ERROR1, "åæ ·é¢è²éè¯¯ï¼ (èæ¯ååæ¯ä¸è½åè²)" STRING_COLOR_ERROR2, "é¢è²æå®é误" STRING_COLOR_ERROR3, "é¢è² %x\n" -STRING_COLOR_ERROR4, "åæ ·é¢è²é误ï¼" STRING_CONSOLE_ERROR, "æªç¥é误ï¼%d\n" STRING_COPY_ERROR1, "é误ï¼æ æ³æå¼æº - %sï¼\n" STRING_COPY_ERROR2, "é误ï¼æ æ³å¤å¶å°èªèº«ï¼\n" Modified: trunk/reactos/base/shell/cmd/resource.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/resource.h?rev=59055&r1=59054&r2=59055&view=diff ============================================================================== --- trunk/reactos/base/shell/cmd/resource.h [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/resource.h [iso-8859-1] Mon May 20 17:43:37 2013 @@ -34,13 +34,12 @@ #define STRING_COLOR_ERROR1 314 #define STRING_COLOR_ERROR2 315 #define STRING_COLOR_ERROR3 316 -#define STRING_COLOR_ERROR4 317 -#define STRING_CONSOLE_ERROR 318 -#define STRING_COPY_ERROR1 319 -#define STRING_COPY_ERROR2 320 -#define STRING_COPY_ERROR3 321 -#define STRING_COPY_ERROR4 322 -#define STRING_DATE_ERROR 323 +#define STRING_CONSOLE_ERROR 317 +#define STRING_COPY_ERROR1 320 +#define STRING_COPY_ERROR2 321 +#define STRING_COPY_ERROR3 322 +#define STRING_COPY_ERROR4 323 +#define STRING_DATE_ERROR 324 #define STRING_DEL_ERROR5 328 #define STRING_DEL_ERROR6 329 #define STRING_DEL_ERROR7 330 Modified: trunk/reactos/base/shell/cmd/strtoclr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/strtoclr.c?rev=59055&r1=59054&r2=59055&view=diff ============================================================================== --- trunk/reactos/base/shell/cmd/strtoclr.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/strtoclr.c [iso-8859-1] Mon May 20 17:43:37 2013 @@ -10,10 +10,12 @@ * */ -/*only -BOOL StringToColor(LPWORD lpColor, LPTSTR*str) -is to be called -other are internal service functions*/ +/* + * Only + * BOOL StringToColor(LPWORD lpColor, LPTSTR*str) + * has to be called. + * Other are internal service functions. + */ #include "precomp.h" @@ -23,14 +25,14 @@ #define _I FOREGROUND_INTENSITY -/*return values for chop_blank*/ -#define CP_OK 0 -#define CP_BLANK_NOT_FOUND 1 -#define CP_END_OF_STRING 2 - +/* Return values for chop_blank */ +#define CP_OK 0 +#define CP_BLANK_NOT_FOUND 1 +#define CP_END_OF_STRING 2 + +/* NOTE: See the description for these flags in the StringToColor()'s description */ #define SC_HEX 0x0100 #define SC_TXT 0x0200 - typedef struct _CLRTABLE @@ -42,58 +44,55 @@ CLRTABLE clrtable[] = { - {_T("bla") ,0 }, - {_T("blu") ,_B }, - {_T("gre") ,_G }, - {_T("cya") ,_B|_G }, - {_T("red") ,_R }, - {_T("mag") ,_B|_R }, - {_T("yel") ,_R|_G }, - {_T("whi") ,_R|_G|_B }, - {_T("gra") ,_I }, - - - {_T("0") ,0 }, - {_T("2") ,_G }, - {_T("3") ,_B|_G }, - {_T("4") ,_R }, - {_T("5") ,_B|_R }, - {_T("6") ,_R|_G }, - {_T("7") ,_R|_G|_B }, - - {_T("8") ,_I }, - {_T("9") ,_I|_B }, - {_T("10") ,_I|_G }, - {_T("11") ,_I|_B|_G }, - {_T("12") ,_I|_R }, - {_T("13") ,_I|_B|_R }, - {_T("14") ,_I|_R|_G }, - {_T("15") ,_I|_R|_G|_B }, - - - /* note that 1 is at the end of list - to avoid to confuse it with 10-15*/ - {_T("1") ,_B }, - - /*cyan synonimous*/ - {_T("aqu") ,_B|_G }, - /*magenta synonimous*/ - {_T("pur") ,_B|_R }, - + {_T("bla"), 0 }, + {_T("blu"), _B }, + {_T("gre"), _G }, + {_T("cya"), _B|_G }, + {_T("red"), _R }, + {_T("mag"), _B|_R }, + {_T("yel"), _R|_G }, + {_T("whi"), _R|_G|_B }, + {_T("gra"), _I }, + + {_T("0") , 0 }, + {_T("2") , _G }, + {_T("3") , _B|_G }, + {_T("4") , _R }, + {_T("5") , _B|_R }, + {_T("6") , _R|_G }, + {_T("7") , _R|_G|_B }, + + {_T("8") , _I }, + {_T("9") , _I|_B }, + {_T("10") , _I|_G }, + {_T("11") , _I|_B|_G }, + {_T("12") , _I|_R }, + {_T("13") , _I|_B|_R }, + {_T("14") , _I|_R|_G }, + {_T("15") , _I|_R|_G|_B }, + + /* + * Note that 1 is at the end of list + * to avoid to confuse it with 10-15 + */ + {_T("1") , _B }, + + /* Cyan synonym */ + {_T("aqu"), _B|_G }, + /* Magenta synonym */ + {_T("pur"), _B|_R }, {_T("") ,0}, }; - -/* -move string pointer to next word (skip all spaces) -on erro retunr nonzero value -*/ +/* + * Move string pointer to next word (skip all spaces). + * On error return nonzero value. + */ static INT chop_blank(LPTSTR *arg_str) { - LPTSTR str; str = _tcschr(*arg_str,_T(' ')); if(!str) @@ -104,8 +103,6 @@ return CP_BLANK_NOT_FOUND; } - - while(_istspace(*str)) str++; @@ -121,11 +118,10 @@ } - -/* -read a color value in hex (like win nt's cmd syntax) -if an error occurs return -1 -*/ +/* + * Read a color value in hex (like win nt's cmd syntax). + * If an error occurs return -1. + */ static WORD hex_clr(LPTSTR str) { @@ -146,7 +142,6 @@ return (WORD)-1; } - ch = str[0]; if(_istdigit(ch)) @@ -166,9 +161,9 @@ /* -read a color value from a string (like 4nt's syntax) -if an error occurs return -1 -*/ + * Read a color value from a string (like 4nt's syntax). + * If an error occurs return -1. + */ static WORD txt_clr(LPTSTR str) { @@ -182,8 +177,7 @@ } - -/*search for x on y*/ +/* Search for "x on y" */ static WORD str_to_color(LPTSTR* arg_str) { @@ -197,8 +191,7 @@ if (!(*str)) return (WORD)-1; - - /*foreground*/ + /* foreground */ bBri = FALSE; if (_tcsnicmp(str,_T("bri"),3) == 0) @@ -214,13 +207,13 @@ return (WORD)-1; } - /*skip spaces and "on"*/ + /* skip spaces and "on" keyword */ if (chop_blank(&str) || chop_blank(&str)) return (WORD)-1; ret_clr = tmp_clr | (bBri << 3); - /*background*/ + /* background */ bBri = FALSE; if(_tcsnicmp(str,_T("bri"),3) == 0 ) @@ -231,7 +224,6 @@ return (WORD)-1; } - if( (tmp_clr = txt_clr(str)) == (WORD)-1 ) return (WORD)-1; @@ -239,29 +231,28 @@ *arg_str = str; - return SC_HEX | ret_clr | tmp_clr << 4 | bBri << 7; -} - - - -/****main function****/ -/* -the only parameter is arg_str, a pointer to a string. -the string is modified so it will begin to first word after -color specification -(only the char* is moved, no chars in the string are modfied) - - -it returns the color in the l.o. byte, plus two flags in the -h.o. byte, they are: -SC_HEX win nt's cmd syntax (for exampl a0) -SC_TXT 4nt's syntax ( "bri gre on bla" or "10 on 0") - -if succedes also move the LPTSTR to end of -string that specify color -*/ - - + /* NOTE: See the note on SC_HEX in the StringToColor()'s description */ + return /* SC_HEX | */ ret_clr | tmp_clr << 4 | bBri << 7; +} + + +/**** Main function ****/ +/* + * The only parameter is arg_str, a pointer to a string. + * The string is modified so it will begin to first word after + * color specification + * (only the char* is moved, no chars in the string are modfied). + * + * **** NOTE: The following functionality is deactivated **** + * it returns the color in the l.o. byte, plus two flags in the + * h.o. byte, they are: + * SC_HEX win nt's cmd syntax (for exampl a0) + * SC_TXT 4nt's syntax ( "bri gre on bla" or "10 on 0") + * ********************************************************** + * + * If succedes also move the LPTSTR to end of + * string that specify color. + */ BOOL StringToColor(LPWORD lpColor, LPTSTR*str) { WORD wRet;