# HG changeset patch # User thomas_-_s # Date 1210890291 0 # Node ID d1fbad5db5ce45f1df0453e90ecdd17cdfb1d9fb # Parent 2f7c7f3e4342c180cbdbcfdbf593d83f5317bbd0 Last corrections to shell script. So now they work on windows and on unix. git-svn-id: svn://svn.code.sf.net/p/universalindent/code/trunk@679 59b1889a-e5ac-428c-b0c7-476e01d41282 diff -r 2f7c7f3e4342 -r d1fbad5db5ce src/indenthandler.cpp --- a/src/indenthandler.cpp Thu May 15 21:07:47 2008 +0000 +++ b/src/indenthandler.cpp Thu May 15 22:24:51 2008 +0000 @@ -205,7 +205,7 @@ indenterCompleteCallString = indenterCompleteCallString.replace("%1", "%%G"); shellScript = shellScript.replace("__INDENTERCALLSTRING1__", indenterCompleteCallString + "\n" + replaceInputFileCommand); #else - QString shellScript(templateShellScript); + QString shellScript(templateBatchScript); shellScript = shellScript.replace("__INDENTERCALLSTRING2__", indenterCompleteCallString + "\n" + replaceInputFileCommand); indenterCompleteCallString = indenterCompleteCallString.replace("$1", "$file2indent"); shellScript = shellScript.replace("__INDENTERCALLSTRING1__", indenterCompleteCallString + "\n" + replaceInputFileCommand); diff -r 2f7c7f3e4342 -r d1fbad5db5ce src/templateBatchScript.h --- a/src/templateBatchScript.h Thu May 15 21:07:47 2008 +0000 +++ b/src/templateBatchScript.h Thu May 15 22:24:51 2008 +0000 @@ -1,170 +1,1 @@ -/*************************************************************************** - * Copyright (C) 2006-2008 by Thomas Schweitzer * - * thomas-schweitzer(at)arcor.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License version 2.0 as * - * published by the Free Software Foundation. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program in the file LICENSE.GPL; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#ifndef TEMPLATEBATCHSCRIPT_H -#define TEMPLATEBATCHSCRIPT_H - -static const char* templateBatchScript = -#if defined(Q_OS_WIN32) -"@echo off\n" -"\n" -"IF (%1)==() GOTO error\n" -"dir /b /ad %1 >nul 2>nul && GOTO indentDir\n" -"IF NOT EXIST %1 GOTO error\n" -"goto indentFile\n" -"\n" -":indentDir\n" -"set searchdir=%1\n" -"\n" -"GOTO assignSuffix\n" -"\n" -":assignDefaultDir\n" -"::echo !!!!DEFAULT DIR!!!\n" -"set searchdir=.\n" -"\n" -":assignSuffix\n" -"IF (%2)==() GOTO assignDefaultSuffix\n" -"set filesuffix=%2\n" -"\n" -"GOTO run\n" -"\n" -":assignDefaultSuffix\n" -"::echo !!!!DEFAULT SUFFIX!!!\n" -"set filesuffix=*\n" -"\n" -":run\n" -"FOR /F \"tokens=*\" %%G IN ('DIR /B /S %searchdir%\\*.%filesuffix%') DO (\n" - "echo Indenting file \"%%G\"\n" - "__INDENTERCALLSTRING1__\n" -")\n" -"GOTO ende\n" -"\n" -":indentFile\n" -"echo Indenting one file %1\n" -"__INDENTERCALLSTRING2__\n" -"\n" -"GOTO ende\n" -"\n" -":error\n" -"echo .\n" -"echo ERROR: As parameter given directory or file does not exist!\n" -"echo Syntax is: recurse.bat dirname filesuffix\n" -"echo Syntax is: recurse.bat filename\n" -"echo Example: recurse.bat temp cpp\n" -"echo .\n" -"\n" -":ende\n"; - -#else - -"#!/bin/sh \n" -"\n" -"if [ ! -n \"$1\" ]; then\n" - "echo \"Syntax is: recurse.sh dirname filesuffix\"\n" - "echo \"Syntax is: recurse.sh filename\"\n" - "echo \"Example: recurse.sh temp cpp\"\n" - "exit 1\n" -"fi\n" -"\n" -"if [ -d \"$1\" ]; then\n" - "#echo \"Dir ${1} exists\"\n" - "if [ -n \"$2\" ]; then\n" - "filesuffix=$2\n" - "else\n" - "filesuffix=\"*\"\n" - "fi\n" - "\n" - "#echo \"Filtering files using suffix ${filesuffix}\"\n" - "\n" - "file_list=`find temp -name \"*.${filesuffix}\" -type f`\n" - "for file2indent in $file_list\n" - "do \n" - "echo \"Indenting file $file2indent\"\n" - "__INDENTERCALLSTRING1__\n" - "done\n" -"else\n" - "if [ -f \"$1\" ]; then\n" - "echo \"Indenting one file $1\"\n" - "__INDENTERCALLSTRING2__\n" - "else\n" - "echo \"ERROR: As parameter given directory or file does not exist!\"\n" - "echo \"Syntax is: recurse.sh dirname filesuffix\"\n" - "echo \"Syntax is: recurse.sh filename\"\n" - "echo \"Example: recurse.sh temp cpp\"\n" - "exit 1\n" - "fi\n" -"fi\n"; -#endif // #if defined(Q_OS_WIN32) - -#endif // TEMPLATEBATCHSCRIPT_H - -/* Here comes the original batch script without the c++ markup -@echo off - -IF (%1)==() GOTO error -dir /b /ad %1 >nul 2>nul && GOTO indentDir -IF NOT EXIST %1 GOTO error -goto indentFile - -:indentDir -set searchdir=%1 - -GOTO assignSuffix - -:assignDefaultDir -::echo !!!!DEFAULT DIR!!! -set searchdir=. - -:assignSuffix -IF (%2)==() GOTO assignDefaultSuffix -set filesuffix=%2 - -GOTO run - -:assignDefaultSuffix -::echo !!!!DEFAULT SUFFIX!!! -set filesuffix=* - -:run -FOR /F "tokens=*" %%G IN ('DIR /B /S %searchdir%\*.%filesuffix%') DO ( - echo Indenting file "%%G" - ::call call_CSSTidy.bat "%%G" - "C:/Dokumente und Einstellungen/ts/Eigene Dateien/Visual Studio 2005/Projects/UiGuixy/indenters/csstidy.exe" "%%G" --timestamp=true --allow_html_in_templates=false --compress_colors=true --compress_font=true --lowercase_s=false --preserve_css=false --remove_last_;=false --remove_bslash=true --sort_properties=false --sort_selectors=false indentoutput.css - move /Y indentoutput.css "%%G" -) -GOTO ende - -:indentFile -echo Indenting one file %1 -"C:/Dokumente und Einstellungen/ts/Eigene Dateien/Visual Studio 2005/Projects/UiGuixy/indenters/csstidy.exe" %1 --timestamp=true --allow_html_in_templates=false --compress_colors=true --compress_font=true --lowercase_s=false --preserve_css=false --remove_last_;=false --remove_bslash=true --sort_properties=false --sort_selectors=false indentoutput.css -move /Y indentoutput.css %1 - -GOTO ende - -:error -echo . -echo ERROR: As parameter given directory or file does not exist! -echo Syntax is: recurse.bat dirname filesuffix -echo Syntax is: recurse.bat filename -echo Example: recurse.bat temp cpp -echo . - -:ende - -*/ +/*************************************************************************** * Copyright (C) 2006-2008 by Thomas Schweitzer * * thomas-schweitzer(at)arcor.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License version 2.0 as * * published by the Free Software Foundation. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program in the file LICENSE.GPL; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef TEMPLATEBATCHSCRIPT_H #define TEMPLATEBATCHSCRIPT_H static const char* templateBatchScript = #if defined(Q_OS_WIN32) "@echo off\n" "\n" "IF (%1)==() GOTO error\n" "dir /b /ad %1 >nul 2>nul && GOTO indentDir\n" "IF NOT EXIST %1 GOTO error\n" "goto indentFile\n" "\n" ":indentDir\n" "set searchdir=%1\n" "\n" "GOTO assignSuffix\n" "\n" ":assignDefaultDir\n" "::echo !!!!DEFAULT DIR!!!\n" "set searchdir=.\n" "\n" ":assignSuffix\n" "IF (%2)==() GOTO assignDefaultSuffix\n" "set filesuffix=%2\n" "\n" "GOTO run\n" "\n" ":assignDefaultSuffix\n" "::echo !!!!DEFAULT SUFFIX!!!\n" "set filesuffix=*\n" "\n" ":run\n" "FOR /F \"tokens=*\" %%G IN ('DIR /B /S %searchdir%\\*.%filesuffix%') DO (\n" "echo Indenting file \"%%G\"\n" "__INDENTERCALLSTRING1__\n" ")\n" "GOTO ende\n" "\n" ":indentFile\n" "echo Indenting one file %1\n" "__INDENTERCALLSTRING2__\n" "\n" "GOTO ende\n" "\n" ":error\n" "echo .\n" "echo ERROR: As parameter given directory or file does not exist!\n" "echo Syntax is: recurse.bat dirname filesuffix\n" "echo Syntax is: recurse.bat filename\n" "echo Example: recurse.bat temp cpp\n" "echo .\n" "\n" ":ende\n"; #else "#!/bin/sh \n" "\n" "if [ ! -n \"$1\" ]; then\n" "echo \"Syntax is: recurse.sh dirname filesuffix\"\n" "echo \"Syntax is: recurse.sh filename\"\n" "echo \"Example: recurse.sh temp cpp\"\n" "exit 1\n" "fi\n" "\n" "if [ -d \"$1\" ]; then\n" "#echo \"Dir ${1} exists\"\n" "if [ -n \"$2\" ]; then\n" "filesuffix=$2\n" "else\n" "filesuffix=\"*\"\n" "fi\n" "\n" "#echo \"Filtering files using suffix ${filesuffix}\"\n" "\n" "file_list=`find ${1} -name \"*.${filesuffix}\" -type f`\n" "for file2indent in $file_list\n" "do \n" "echo \"Indenting file $file2indent\"\n" "__INDENTERCALLSTRING1__\n" "done\n" "else\n" "if [ -f \"$1\" ]; then\n" "echo \"Indenting one file $1\"\n" "__INDENTERCALLSTRING2__\n" "else\n" "echo \"ERROR: As parameter given directory or file does not exist!\"\n" "echo \"Syntax is: recurse.sh dirname filesuffix\"\n" "echo \"Syntax is: recurse.sh filename\"\n" "echo \"Example: recurse.sh temp cpp\"\n" "exit 1\n" "fi\n" "fi\n"; #endif // #if defined(Q_OS_WIN32) #endif // TEMPLATEBATCHSCRIPT_H /* Here comes the original batch script without the c++ markup @echo off IF (%1)==() GOTO error dir /b /ad %1 >nul 2>nul && GOTO indentDir IF NOT EXIST %1 GOTO error goto indentFile :indentDir set searchdir=%1 GOTO assignSuffix :assignDefaultDir ::echo !!!!DEFAULT DIR!!! set searchdir=. :assignSuffix IF (%2)==() GOTO assignDefaultSuffix set filesuffix=%2 GOTO run :assignDefaultSuffix ::echo !!!!DEFAULT SUFFIX!!! set filesuffix=* :run FOR /F "tokens=*" %%G IN ('DIR /B /S %searchdir%\*.%filesuffix%') DO ( echo Indenting file "%%G" ::call call_CSSTidy.bat "%%G" "C:/Dokumente und Einstellungen/ts/Eigene Dateien/Visual Studio 2005/Projects/UiGuixy/indenters/csstidy.exe" "%%G" --timestamp=true --allow_html_in_templates=false --compress_colors=true --compress_font=true --lowercase_s=false --preserve_css=false --remove_last_;=false --remove_bslash=true --sort_properties=false --sort_selectors=false indentoutput.css move /Y indentoutput.css "%%G" ) GOTO ende :indentFile echo Indenting one file %1 "C:/Dokumente und Einstellungen/ts/Eigene Dateien/Visual Studio 2005/Projects/UiGuixy/indenters/csstidy.exe" %1 --timestamp=true --allow_html_in_templates=false --compress_colors=true --compress_font=true --lowercase_s=false --preserve_css=false --remove_last_;=false --remove_bslash=true --sort_properties=false --sort_selectors=false indentoutput.css move /Y indentoutput.css %1 GOTO ende :error echo . echo ERROR: As parameter given directory or file does not exist! echo Syntax is: recurse.bat dirname filesuffix echo Syntax is: recurse.bat filename echo Example: recurse.bat temp cpp echo . :ende */ \ No newline at end of file