[GRASS-SVN] r53033 - in grass/trunk/mswindows/external: . rbatch

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Aug 31 12:34:51 PDT 2012


Author: hellik
Date: 2012-08-31 12:34:51 -0700 (Fri, 31 Aug 2012)
New Revision: 53033

Added:
   grass/trunk/mswindows/external/README.license
   grass/trunk/mswindows/external/rbatch/
   grass/trunk/mswindows/external/rbatch/#Rscript.bat
   grass/trunk/mswindows/external/rbatch/ANNOUNCE
   grass/trunk/mswindows/external/rbatch/COPYING
   grass/trunk/mswindows/external/rbatch/COPYRIGHTS
   grass/trunk/mswindows/external/rbatch/NEWS
   grass/trunk/mswindows/external/rbatch/R.bat
   grass/trunk/mswindows/external/rbatch/README
   grass/trunk/mswindows/external/rbatch/README.grass
   grass/trunk/mswindows/external/rbatch/RESOURCES
   grass/trunk/mswindows/external/rbatch/Rcmd.bat
   grass/trunk/mswindows/external/rbatch/Rgui.bat
   grass/trunk/mswindows/external/rbatch/RguiStart.bat
   grass/trunk/mswindows/external/rbatch/Rscript.bat
   grass/trunk/mswindows/external/rbatch/Rtidy.bat
   grass/trunk/mswindows/external/rbatch/Rtools.bat
   grass/trunk/mswindows/external/rbatch/RtoolsVersion.bat
   grass/trunk/mswindows/external/rbatch/Rversions.bat
   grass/trunk/mswindows/external/rbatch/Stangle.bat
   grass/trunk/mswindows/external/rbatch/Sweave.bat
   grass/trunk/mswindows/external/rbatch/THANKS
   grass/trunk/mswindows/external/rbatch/WISHLIST
   grass/trunk/mswindows/external/rbatch/clip2r.js
   grass/trunk/mswindows/external/rbatch/copydir.bat
   grass/trunk/mswindows/external/rbatch/el.js
   grass/trunk/mswindows/external/rbatch/find-miktex.hta
   grass/trunk/mswindows/external/rbatch/movedir.bat
   grass/trunk/mswindows/external/rbatch/rterm.bat
   grass/trunk/mswindows/external/rbatch/show-svn-info.hta
Log:
better GRASS-R-integration (Ticket #1149) - step 1: check in Windows batchfiles for use with R

Added: grass/trunk/mswindows/external/README.license
===================================================================
--- grass/trunk/mswindows/external/README.license	                        (rev 0)
+++ grass/trunk/mswindows/external/README.license	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,21 @@
+
+
+In the following directories you will find code which was not
+written by The GRASS Development Team.
+
+Parts of GRASS are not copyright by The GRASS Development Team.
+The original authors hold the copyrights and you have to abide
+to their licensing terms where noted.
+(Keep in mind that code linking into GRASS can only be distributed
+if compatible with the GPL.)
+
+Specifically the source code below this directory is not necessarily
+licensed under the GPL. Check the READMEs and source code header
+comments carefully.
+
+
+
+ * Windows batchfiles for use with R / (GNU GPL v2)
+   http://code.google.com/p/batchfiles/
+
+

Added: grass/trunk/mswindows/external/rbatch/#Rscript.bat
===================================================================
--- grass/trunk/mswindows/external/rbatch/#Rscript.bat	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/#Rscript.bat	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,239 @@
+
+ at echo off
+rem if /i "%1"==path (path %2) && goto:eof
+
+setlocal
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: Placing this file in your path will allow rcmd to be run anywhere
+:: without changing your path environment variable.  See comments
+:: below on how it finds where R is.  Your path can be listed by
+:: the Windows console command:  path
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+rem at one tine this script had only been tested on XP
+rem recent tests have only been on Vista
+rem ver | findstr XP >NUL
+rem if errorlevel 1 echo Warning: This script has only been tested on Windows XP.
+
+set scriptdir_=%~dp0
+set lookin=.;%userprofile%;%scriptdir_%
+if not defined R_BATCHFILES_RC (
+	for %%f in ("rbatchfilesrc.bat") do set "R_BATCHFILES_RC=%%~$lookin:f"
+)
+if defined R_BATCHFILES_RC (
+	if exist "%R_BATCHFILES_RC%" call %R_BATCHFILES_RC%
+)
+
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: use environment variable R_HOME if defined
+:: else current folder if bin\rcmd.exe exists 
+:: else most current R as determined by registry entry
+:: else error
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+if not defined R_HOME if exist bin\r.exe set R_HOME=%CD%
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\R-core\R /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\r-core\r /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+if not defined R_HOME echo "Error: R not found" & goto:eof
+
+call :process_arch %*
+
+:: add R_MIKTEX to PATH if defined.  Otherwise if its not 
+:: in the PATH already then check \Program Files\miktex* or \miktex* 
+:: and if found add that to PATH.
+
+:: if miktex found in PATH skip searching for it
+PATH | findstr /i miktex > nul
+if not errorlevel 1 goto:end_miktex
+
+:: check for presence of %ProgramFiles%\miktex* or \miktex*
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on "%ProgramFiles%"\miktex* 2^>NUL'
+) do set R_MIKTEX=%ProgramFiles%\%%a
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on %SystemDrive%:\miktex* 2^>NUL'
+) do set R_MIKTEX=%SystemDrive%:\miktex\%%a
+
+:end_miktex
+if defined R_MIKTEX PATH %R_MIKTEX%\miktex\bin;%PATH%
+
+if not defined MYSQL_HOME for /f "delims=" %%a in (
+    'dir /b /on "%ProgramFiles%"\MySQL\* 2^>NUL'
+) do set MYSQL_HOME=%ProgramFiles%\MySQL\%%a
+
+if not defined R_TOOLS for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\R-core\Rtools /v InstallPath 2^>NUL ^| findstr InstallPath'
+ ) do set R_TOOLS=%%~b
+if not defined R_TOOLS for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\Rtools /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_TOOLS=%%~b
+
+set PATHQ=%PATH%
+:WHILE
+    if "%PATHQ%"=="" goto WEND
+    for /F "delims=;" %%i in ("%PATHQ%") do if exist "%%~sfi" set PATH2=%PATH2%;%%~sfi
+    for /F "delims=; tokens=1,*" %%i in ("%PATHQ%") do set PATHQ=%%j
+    goto WHILE 
+:WEND
+
+set path2=%path2:~1%
+
+if defined R_TOOLS (
+    set path2=%R_TOOLS%\bin;%R_TOOLS%\perl\bin;%R_TOOLS%\MinGW\bin;%PATH2%
+)
+
+path %path2%
+
+set here=%CD%
+set args=%*
+
+:: get name by which this command was called
+:: this allows same file to be used for Rgui, Rterm, etc. by just renaming it
+for %%i in (%0) do set cmd=%%~ni.exe
+
+if /i %cmd%==rtools.exe (endlocal & set path=%path2%) && goto:eof
+
+cd %R_HOME%\bin
+if /i not %cmd%==rguistart.exe goto:notRguiStart
+  set cmd=rgui.exe
+  set firstArgument=%1
+  if defined firstArgument (
+    dir %1 | findstr "<DIR>" > nul
+    if errorlevel 1 goto:notRguiStart
+    set here=%~1
+    set firstArgument=
+  )
+  set args=
+  shift
+  :startloop
+  set firstArgument=%1
+  if defined firstArgument (
+     set args=%args% "%~1" 
+     shift
+     goto:startloop
+  )
+:notRguiStart
+
+set st=
+if /i %cmd%==rgui.exe set st=start
+
+if /i not %cmd%==#Rscript.exe goto:not#Rscript
+set cmd=Rscript.exe
+if [%1]==[] goto:help#Rscript
+call :rsarg1 %*
+goto:not#Rscript
+:rsarg1
+set args=%*
+set arg1=%~1
+set arg1=%arg1:.bat.bat=.bat%
+set last4=%arg1:~-4%
+if /i not "%last4%"==".bat" set arg1=%arg1%.bat
+for %%a in ("%R_HOME%\bin\Rscript.exe") do set RSCRIPT=%%~sfa
+call set args=%%args:%1="%arg1%"%%
+rem call set args=%%args:%1=%%
+goto:eof
+:not#Rscript
+
+cd %here%
+
+:: Look in architecture specific subdirectory of bin. If not there look in bin.
+set cmdpath=%R_HOME%\bin\%R_ARCH0%\%cmd%
+if exist "%cmdpath%" goto:cmdpathfound
+set cmdpath=%R_HOME%\bin\%cmd%
+if exist "%cmdpath%" goto:cmdpathfound
+echo "Error: %cmd% not found" & goto:eof
+:cmdpathfound
+
+:: if called as jgr.bat locate the JGR package to find jgr.exe
+if /i not %cmd%==jgr.exe goto:notJGR
+  set st=start
+  set cmdpath=jgr.exe
+  if not defined JGR_LIBS set JGR_LIBS=%R_LIBS%
+  for %%a in ("%R_HOME%\bin\Rscript.exe") do set RSCRIPT=%%~sfa
+  if not defined JGR_LIBS for /f "usebackq delims=" %%a in (
+		`%RSCRIPT% -e "cat(.libPaths(),sep=';')"`
+  ) do set JGR_LIBS=%%~a
+  if not defined JGR_LIBS (
+	echo "Error: JGR package not found in R library" & goto:eof
+  )
+  for %%f in ("JGR") do set "jgrpkg=%%~$JGR_LIBS:f"
+  set JGR_LIB=%jgrpkg:~0,-4%
+  for %%a in ("%JGR_LIB%") do set JGR_LIB_SHORT=%%~sfa
+  for %%a in ("%R_HOME%") do set R_HOME_SHORT=%%~sfa
+  set args=--libpath=%JGR_LIB_SHORT% --rhome=%R_HOME_SHORT%
+
+:notJGR
+
+rem set R_ARCH
+rem set R_ARCH0
+rem set cmdpath
+rem if defined st set st
+rem set args
+
+set cygwin=nodosfilewarning
+if not defined args goto:noargs
+if defined st (start "" "%cmdpath%" %args%) else "%cmdpath%" %args%
+goto:eof
+:noargs
+if defined st (start "" "%cmdpath%") else "%cmdpath%"
+goto:eof
+
+:help#Rscript
+echo Usage: #Rscript %%0 %%*
+echo If the above is the first line in a file 
+echo containing only R code and the file is 
+echo given a .bat extension then it can be 
+echo run as a batch file.
+goto:eof
+
+
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: processing of --arch= where value can be 32, 64, i386, x64, /i386, /x64
+
+:: Call it like this: call :process_arch %*
+:: On return R_ARCH will be set from --arch or R_ARCH or default
+:: and R_ARCH0 will be R_ARCH without the / prefix
+:: It will look for the architecture in these places in this order:
+:: - first arg if its --arch
+:: - environment variable R_ARCH
+:: - check if R_HOME\bin\i386 exists
+:: - if R_HOME\bin\x64 exists
+:: - if none of the above then use R_ARCH=/i386
+:: Note that R_HOME should be defined before calling this routine
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+:process_arch
+	if defined R_ARCH goto:process_arch_cont
+	:: The loop searches for --arch and sets R_ARCH to the next argument
+    :process_arch_loop 
+    set arg=%~1
+    shift 
+    if not defined arg goto :process_arch_cont 
+	if "%arg%"=="--arch" set R_ARCH=%1
+	if defined R_ARCH goto:process_arch_cont
+	goto:process_arch_loop
+    :process_arch_cont
+	if defined process_arg_arch goto:process_arch_defined
+	if exist %R_HOME%\bin\i386 (set R_ARCH=/i386) & goto:process_arch_defined
+	if exist %R_HOME%\bin\x64 (set R_ARCH=/x64) & goto:process_arch_defined
+	(set R_ARCH=/i386)
+	:process_arch_defined
+	if "%R_ARCH%"=="32" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="386" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="i386" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="64" (set R_ARCH=/x64)
+	if "%R_ARCH%"=="x64" (set R_ARCH=/x64)
+	:: if R_ARCH does not begin with a slash add one as a prefix
+	(set first_char=%R_ARCH:~0,1%)
+	if not "%first_char%" == "/" (set R_ARCH=/%R_ARCH%)
+	:: R_ARCH0 is like R_ARCH but without the beginning /
+	(set R_ARCH0=%R_ARCH:~1%)
+	goto:eof
+
+endlocal

Added: grass/trunk/mswindows/external/rbatch/ANNOUNCE
===================================================================
--- grass/trunk/mswindows/external/rbatch/ANNOUNCE	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/ANNOUNCE	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,63 @@
+
+batchfiles is a set of batch, javascript and HTML
+Application files that are useful for running R and
+associated programs.
+
+Version 0.6-0 updates them for the new architecture
+specific directory structure in R 2.12.0 .
+
+A few of the lesser used utilities have been dropped.
+
+Each batchfile is self contained.  To install just
+place all or just any that you wish to use anywhere on
+your path.  The batch command:
+
+	path
+
+will show you which folders are on your path.
+
+
+DOWNLOAD
+
+They can be downloaded individually from the svn
+repository available via the home page or they can be
+downloaded all at one in a zip file from CRAN here:
+http://cran.r-project.org/contrib/extra/batchfiles/
+
+
+MORE INFO
+
+More info is available from the home page:
+http://batchfiles.googlecode.com
+
+
+LIST OF PROGRAMS
+
+Legend:
+h = no args gives help
+0 = common usage is to enter command name without arguments
+d = in development
+* = all files marked with one star are the same.  Program checks name by which its called to determine action.
+** = all files marked with two stars are the same.  Program checks name by which its called to determine action.
+
+#Rscript.bat - put at top of R file to make it a batch file (h) (*)
+clip2r.js - pastes clipboard into Rgui.  See comments in file for use from vim. (0)(d)
+copydir.bat - copy a library from one version of R to another (h)
+el.js - run elevated - Vista and up, e.g. el Rgui  runs R elevated
+find-miktex.hta - GUI to find MiKTeX (0)
+kopy.bat - copy Rcmd to other batch files (h)(d)
+movedir.bat - move library from one version of R to another (h) 
+R.bat - like R.exe but finds R from registry (0) (*)
+Rcmd.bat - like Rcmd.exe but finds R from registry (h) (*)
+Rgui.bat - like Rgui.exe but finds R from registry (0) (*)
+RguiStart.bat - like Rgui.bat but arg1 defines folder to start R in (*)
+Rscript.bat - run .R script (h) (*)
+Rterm.bat - like rterm.exe but finds R from registry (h) (*)
+Rtidy.bat - reformat a .R file, e.g. Rtidy myfile.R > outfile.R (d)
+Rtools.bat - place Rtools on path for remainder of console session (0) (*)
+Rversions.bat - list R and set R version in registry, e.g. on Vista: el cmd/c Rversions R-2.12.0 (0)
+show-svn-info.hta - show svn info if current folder is an svn checkout (0)
+Stangle.bat - run arg1 through Stangle (h) (**)
+Sweave.bat - run arg1 through Sweave (h) (**)
+
+

Added: grass/trunk/mswindows/external/rbatch/COPYING
===================================================================
--- grass/trunk/mswindows/external/rbatch/COPYING	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/COPYING	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,340 @@
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    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; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year  name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.

Added: grass/trunk/mswindows/external/rbatch/COPYRIGHTS
===================================================================
--- grass/trunk/mswindows/external/rbatch/COPYRIGHTS	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/COPYRIGHTS	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,10 @@
+COPYRIGHT STATUS
+----------------
+
+This code is:
+
+  Copyright (C) 2005 Gabor Grothendieck
+
+All code is subject to the GNU General Public License, Version 2. See
+the file COPYING for the exact conditions under which you may
+redistribute it.

Added: grass/trunk/mswindows/external/rbatch/NEWS
===================================================================
--- grass/trunk/mswindows/external/rbatch/NEWS	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/NEWS	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,296 @@
+Changes in version 0.6-6
+
+  o bug fixes
+
+Changes in version 0.6-5
+
+  o if MYSQL_HOME has not already been set then it set it to the last file
+    among these, if any:
+
+		%ProgramFiles%\MySQL\*
+
+    This allows one to install and run RMySQL without setting any environment 
+    variables.  (Note that MySQL should be installed from the mysql site.
+    xampp and wamp do not include the header files needed by RMySQL.)
+
+Changes in version 0.6-4
+
+  o fixed bugs
+
+Changes in version 0.6-3
+
+  o fixed bugs
+
+Changes in version 0.6-1
+
+  o fixed bugs
+
+  o R_ARCH and --arch can consistently be any of 32, i386, 64, x64, /i386 or /64
+    (vs R itself which otherwise uses different values for R_ARCH and --arch)
+
+Changes in version 0.6
+
+  o enhancements to handle architecture specific directory structure in R 2.12.0
+    Supports R_ARCH environment variable and --arch= first argument.  Valid
+    values are 32, 64, i386, x64.  Default is i386.
+
+Changes in version 0.5-1
+
+  o new experimental command clip2r.js
+
+  o bug fixes
+
+Changes in version 0.5-0
+
+  o new command show-svn-info.hta when run from a Tortoise SVN checkout
+    folder shows some info about it.  Requires Tortoise SVN version 1.5
+    or higher.
+
+  o new command find-miktex.hta can be run without arguments from the
+    Windows command line or double clicked from Windows Explorer 
+    to show path to the MiKTeX bin directory.
+
+  o Rversions.hta now also changes the .RData association and has
+    been verified to work on both XP and Vista.
+
+  o new RExcelversion.hta (also distributed with RExcel) that is like
+    Rversions.hta but also sets the version for Rexcel at the same time
+    and has been verified to work on both XP and Vista.
+
+  o jgr.bat now passes the Windows library and R home to jgr.exe automatically
+
+  o added defensive code to allow code to work even in the presence of
+    certain bad PATH variables
+
+  o testing on XP32, XPx64, Vista32, Win7x64 (thanks to Nicholas Hirschey)
+
+Changes in version 0.4-3
+
+  o Sweave.bat and Stangle.bat were not automatically finding MiKTeX.  
+    Fixed.
+
+Changes in version 0.4-2
+
+  o can optionally work off initialization files in place of registry.
+    Place rbatchfilesrc.bat in current directory or %userprofile% (so 
+    different directories can work off different versions of R, say) 
+    or same directory as the other batchfiles and it will run it first.
+    Typically rbatchfiles.bat would constain these two lines or similar:
+		set R_HOME=C:\Program Files\R\R-2.7.0
+		set R_TOOLS=C:\Rtools
+
+  o added Stangle.bat
+
+Changes in version 0.4-1
+
+  o it is no longer necessary to set any paths to build R packages
+    provided Rtools 2.7 or later is used.  Rcmd.bat and the other
+    scripts automatically find Rtools from the registry (including perl)
+    and if MikTeX is at %ProgramFiles%\MiKTeX* or %SystemDrive%:\MiKTex  
+    then it will find MiKTeX too.  New optional environment variables 
+    R_TOOLS and R_MIKTEX are available to force specified paths to be used.
+
+  o new Rtools.bat command that sets the path for the current cmd instance
+    to the one that R*.bat files use internally.  That is, rtools/bin,
+    rtools/perl/bin, rtools/MinGW/bin and MiKTeX .../miktex/bin are added 
+    to the path.  This is not needed to run or install R programs but only
+    if you want to access the rtools for other purposes.
+
+  o new el.js command which runs the command given as its argument elevated.
+    e.g. el cmd
+
+Changes in version 0.4-0
+
+  o as of 0.4-0 batchfiles is being developed and tested on Vista.
+    It may still work on XP but if any of the commands do not then use
+    version 0.3-2 instead since that was exclusively tested on XP.
+
+  o added RguiStart.bat which is like Rgui.bat but takes a single argument
+    which is a directory and starts up there
+
+  o the dependency of sweave.bat on Rterm.bat was eliminated so all
+    batch and javascript programs in this collection are now independent
+    of each other and have no dependencies aside form R.  (The perl
+    program, toggleDoc.pl, is does depend on perl and toggleDoc.js.)
+
+  o added info on how to use RguiStart.bat and sweave.bat with SendTo
+    folder
+
+  o misc improvements to README file
+
+  o improved help message given by sweave.bat when issued with no arguments
+
+  o removed only tested on XP messages since they work on Vista
+
+  o changed algorithm in Rversions.bat.  Now it checks current directory,
+    R_HOME and all keys in R's portion of the registry plus all sibling
+    folders of those mentioned.  Also it runs RSetReg.exe elevated
+    on Vista.  New version has not been tested on XP; however, older
+    versions are still available and were tested on XP.
+
+  o updated copydir.bat portion of README to discuss additional alternatives
+
+  o removed find-miktex.bat, Rfind.bat and makepkg.bat (they are still
+    available in batchfiles version 0.3-2)
+
+  o added toggleDoc.pl/toggleDoc.js which adds a toggle box to each 00Index.html
+    which when checked collapses similar HTML help lines into one.  Contributed
+    by Dieter Menne.
+
+Changes in version 0.3-2
+ 
+  o sweave.bat now uses Rterm.bat rather than Rcmd.bat which makes it usable
+    with a basic R installation (i.e. sh.exe not needed).  Previously it
+    required Rcmd.bat but now it requires Rterm.bat instead.
+
+  o added Rterm.bat (just a copy of Rcmd.bat)
+
+Changes in Version 0.3-1
+
+  o new find-miktex.bat which lists the mixktex folders from the registry
+
+  o new Rscript.bat which allows one to use the Rscript facility in 
+    R 2.5.0 and later without changing pathnames.  Just place Rscript.bat
+    in any existing path and it will automatically find the
+    current version of R from the registry and run the Rscript.exe that
+    is there.
+
+  o runR.bat.  If you have an R script such as myfile.R then you can create
+    a batch script for it by copying runR.bat to myfile.bat.  Then when you
+    issue the command myfile or myfile.bat it will run the R script in
+    myfile.R .  Just place myfile.bat and myfile.R anywhere in your path.  
+    This uses Rscript.bat .
+
+  o #Rscript.  If you have an Rscript called myfile.R, say, then if you
+    copy the script to myfile.bat and place 
+       #Rscript %0 %*  
+    as the first line with the remainder being the R commands then issuing
+    the command myfile or myfile.bat will run the R script.  The advantage
+    over the runR.bat method is that there is only one file, myfile.bat.
+    You don't need myfile.R anymore.  The disadvantage is that it will 
+    echo the #Rscript line to stdout.  This will be fixed if and when 
+    Rscript ever gets the perl/python/ruby -x flag.  (The runR approach will 
+    not echo additional lines but does require two files.)  
+
+  o new Rtidy.bat is a sample Rscript that uses the #Rscript facility
+    based on George Georgalis' UNIX code
+
+  o withgs.bat now checks for latest ghostscript version.  (Previously 
+    version was hard coded and it only worked for that version.)
+
+Changes in Version 0.3-0
+
+  o sweave now generates a second .pdf ending which is a copy of the first
+    but has a unique name and displays that.  This works around a problem
+    with acrobat that it will not display two files with the same name
+    at the same time.
+
+  o new --tex, --pdf, --nobck.pdf switches are available on sweave.  Also
+    expanded help when entering sweave without args.
+    
+Changes in Version 0.2-9
+
+  o updated README and other documentation files and inline documentation
+
+  o added sweave.bat
+ 
+  o new google code home page and svn repository
+    http://code.google.com/p/batchfiles/
+
+Changes in Version 0.2-8
+
+  o bug fix in copydir.bat and movedir.bat
+
+Changes in Version 0.2-7
+
+  o removed extra popup from Rversions.hta
+
+  o Rfind.bat now looks in registry for MiKTeX, replacing
+    previous heuristic.  [Thanks for help from Duncan
+    Murdoch].  Also RToolsDir typo fixed in Rfind.bat.
+
+Changes in Version 0.2-6
+
+  o batch files no longer use short names internally since this
+    triggers a bug in Windows batch in the case of the new R
+    folder naming conventions.
+
+  o Rversions.hta - fix for path names with spaces
+
+  o Rrefresh.bat has been removed (after having been deprecated in
+    in previous versions of batchfiles).
+
+  o tested movedir.bat by using it to upgrade R-2.2.0pat to R-2.2.1.  
+    See instructions in README.
+
+Changes in Version 0.2-5
+
+  o added movedir.bat which moves libraries from one version of
+    R to another.  This is like copydir.bat but is much faster and
+    can be used when the older version of R is no longer needed
+    (unlike copydir.bat which preserves the older version).  See
+    README for usage.
+
+Changes in Version 0.2-3
+
+  o added copydir.bat which can copy libraries from one version of
+    R to another.  (This is a temporary solution until R provides
+    facilities for upgrading the libraries, expected in R 2.3.0 .)
+    See README for usage.
+    
+  o eliminated all code associated with reading and manipulation of
+    R_ENVIRON, R_PROFILE and R_LIBS simplifying the batch files.  Use
+    copydir.bat instead.
+
+  o Rversions.hta is a javascript GUI version of Rversions.bat 
+
+Changes in Version 0.2-2
+
+  o added jgr.bat which starts up the JGR GUI.
+
+  o added Rversions.bat which can list the directories of all R versions 
+    available and can set one to become the current R version.
+
+  o all batch scripts which used the environment variable name Rrw now 
+    use the environment variable name R_HOME instead.
+
+  o Rcmd.bat, Rgui.bat, R.bat, jgr.bat files will now read R_ENVIRON, 
+    if present, and set the R_LIBS definition in it, if present (unless
+    R_LIBS is already defined as an environment variable).  All R_ENVIRON
+    file syntax accepted by R is supported including comments (#), 
+    var=value, var=${foo-bar} and recursions, var=${A-${B-C}}.
+
+  o makepkg.bat internals were simplified due to previous point.
+
+  o updated WISHLIST.
+
+  o updated THANKS.
+
+  o updated README.  More introductory information.  Also instructions 
+    for Rgui shortcut will disable screen flash on startup. Corrections.
+
+Changes in Version 0.2-1
+
+  o improvements to README
+
+Changes in Version 0.2-0
+
+  o can now support configurations without *.site files (as well as
+    configurations with *.site files) thereby reducing the minimum 
+    configuration even further.  
+
+  o Rcmd.bat, Rgui.bat and R.bat now temporarily set R_ENVIRON,
+    R_PROFILE and R_LIBS as needed so that it is no longer necessary to 
+    copy the *.site files into the etc directory eliminating all
+    reconfiguration when upgrading to a new version of R (except for
+    refreshing MiKTeX).
+
+  o new command miktex-refresh.bat is used to refresh MiKTeX after a
+    new version of R is installed. Previously this was done in
+    Rrefresh.bat which is now deprecated.  Rrefresh.bat is no longer 
+    needed (unless you want each R version to have its own *.site files).
+
+  o new NEWS, WISHLIST and RESOURCES files.
+
+  o README provides additional details.
+

Added: grass/trunk/mswindows/external/rbatch/R.bat
===================================================================
--- grass/trunk/mswindows/external/rbatch/R.bat	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/R.bat	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,239 @@
+
+ at echo off
+rem if /i "%1"==path (path %2) && goto:eof
+
+setlocal
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: Placing this file in your path will allow rcmd to be run anywhere
+:: without changing your path environment variable.  See comments
+:: below on how it finds where R is.  Your path can be listed by
+:: the Windows console command:  path
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+rem at one tine this script had only been tested on XP
+rem recent tests have only been on Vista
+rem ver | findstr XP >NUL
+rem if errorlevel 1 echo Warning: This script has only been tested on Windows XP.
+
+set scriptdir_=%~dp0
+set lookin=.;%userprofile%;%scriptdir_%
+if not defined R_BATCHFILES_RC (
+	for %%f in ("rbatchfilesrc.bat") do set "R_BATCHFILES_RC=%%~$lookin:f"
+)
+if defined R_BATCHFILES_RC (
+	if exist "%R_BATCHFILES_RC%" call %R_BATCHFILES_RC%
+)
+
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: use environment variable R_HOME if defined
+:: else current folder if bin\rcmd.exe exists 
+:: else most current R as determined by registry entry
+:: else error
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+if not defined R_HOME if exist bin\r.exe set R_HOME=%CD%
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\R-core\R /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\r-core\r /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+if not defined R_HOME echo "Error: R not found" & goto:eof
+
+call :process_arch %*
+
+:: add R_MIKTEX to PATH if defined.  Otherwise if its not 
+:: in the PATH already then check \Program Files\miktex* or \miktex* 
+:: and if found add that to PATH.
+
+:: if miktex found in PATH skip searching for it
+PATH | findstr /i miktex > nul
+if not errorlevel 1 goto:end_miktex
+
+:: check for presence of %ProgramFiles%\miktex* or \miktex*
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on "%ProgramFiles%"\miktex* 2^>NUL'
+) do set R_MIKTEX=%ProgramFiles%\%%a
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on %SystemDrive%:\miktex* 2^>NUL'
+) do set R_MIKTEX=%SystemDrive%:\miktex\%%a
+
+:end_miktex
+if defined R_MIKTEX PATH %R_MIKTEX%\miktex\bin;%PATH%
+
+if not defined MYSQL_HOME for /f "delims=" %%a in (
+    'dir /b /on "%ProgramFiles%"\MySQL\* 2^>NUL'
+) do set MYSQL_HOME=%ProgramFiles%\MySQL\%%a
+
+if not defined R_TOOLS for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\R-core\Rtools /v InstallPath 2^>NUL ^| findstr InstallPath'
+ ) do set R_TOOLS=%%~b
+if not defined R_TOOLS for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\Rtools /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_TOOLS=%%~b
+
+set PATHQ=%PATH%
+:WHILE
+    if "%PATHQ%"=="" goto WEND
+    for /F "delims=;" %%i in ("%PATHQ%") do if exist "%%~sfi" set PATH2=%PATH2%;%%~sfi
+    for /F "delims=; tokens=1,*" %%i in ("%PATHQ%") do set PATHQ=%%j
+    goto WHILE 
+:WEND
+
+set path2=%path2:~1%
+
+if defined R_TOOLS (
+    set path2=%R_TOOLS%\bin;%R_TOOLS%\perl\bin;%R_TOOLS%\MinGW\bin;%PATH2%
+)
+
+path %path2%
+
+set here=%CD%
+set args=%*
+
+:: get name by which this command was called
+:: this allows same file to be used for Rgui, Rterm, etc. by just renaming it
+for %%i in (%0) do set cmd=%%~ni.exe
+
+if /i %cmd%==rtools.exe (endlocal & set path=%path2%) && goto:eof
+
+cd %R_HOME%\bin
+if /i not %cmd%==rguistart.exe goto:notRguiStart
+  set cmd=rgui.exe
+  set firstArgument=%1
+  if defined firstArgument (
+    dir %1 | findstr "<DIR>" > nul
+    if errorlevel 1 goto:notRguiStart
+    set here=%~1
+    set firstArgument=
+  )
+  set args=
+  shift
+  :startloop
+  set firstArgument=%1
+  if defined firstArgument (
+     set args=%args% "%~1" 
+     shift
+     goto:startloop
+  )
+:notRguiStart
+
+set st=
+if /i %cmd%==rgui.exe set st=start
+
+if /i not %cmd%==#Rscript.exe goto:not#Rscript
+set cmd=Rscript.exe
+if [%1]==[] goto:help#Rscript
+call :rsarg1 %*
+goto:not#Rscript
+:rsarg1
+set args=%*
+set arg1=%~1
+set arg1=%arg1:.bat.bat=.bat%
+set last4=%arg1:~-4%
+if /i not "%last4%"==".bat" set arg1=%arg1%.bat
+for %%a in ("%R_HOME%\bin\Rscript.exe") do set RSCRIPT=%%~sfa
+call set args=%%args:%1="%arg1%"%%
+rem call set args=%%args:%1=%%
+goto:eof
+:not#Rscript
+
+cd %here%
+
+:: Look in architecture specific subdirectory of bin. If not there look in bin.
+set cmdpath=%R_HOME%\bin\%R_ARCH0%\%cmd%
+if exist "%cmdpath%" goto:cmdpathfound
+set cmdpath=%R_HOME%\bin\%cmd%
+if exist "%cmdpath%" goto:cmdpathfound
+echo "Error: %cmd% not found" & goto:eof
+:cmdpathfound
+
+:: if called as jgr.bat locate the JGR package to find jgr.exe
+if /i not %cmd%==jgr.exe goto:notJGR
+  set st=start
+  set cmdpath=jgr.exe
+  if not defined JGR_LIBS set JGR_LIBS=%R_LIBS%
+  for %%a in ("%R_HOME%\bin\Rscript.exe") do set RSCRIPT=%%~sfa
+  if not defined JGR_LIBS for /f "usebackq delims=" %%a in (
+		`%RSCRIPT% -e "cat(.libPaths(),sep=';')"`
+  ) do set JGR_LIBS=%%~a
+  if not defined JGR_LIBS (
+	echo "Error: JGR package not found in R library" & goto:eof
+  )
+  for %%f in ("JGR") do set "jgrpkg=%%~$JGR_LIBS:f"
+  set JGR_LIB=%jgrpkg:~0,-4%
+  for %%a in ("%JGR_LIB%") do set JGR_LIB_SHORT=%%~sfa
+  for %%a in ("%R_HOME%") do set R_HOME_SHORT=%%~sfa
+  set args=--libpath=%JGR_LIB_SHORT% --rhome=%R_HOME_SHORT%
+
+:notJGR
+
+rem set R_ARCH
+rem set R_ARCH0
+rem set cmdpath
+rem if defined st set st
+rem set args
+
+set cygwin=nodosfilewarning
+if not defined args goto:noargs
+if defined st (start "" "%cmdpath%" %args%) else "%cmdpath%" %args%
+goto:eof
+:noargs
+if defined st (start "" "%cmdpath%") else "%cmdpath%"
+goto:eof
+
+:help#Rscript
+echo Usage: #Rscript %%0 %%*
+echo If the above is the first line in a file 
+echo containing only R code and the file is 
+echo given a .bat extension then it can be 
+echo run as a batch file.
+goto:eof
+
+
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: processing of --arch= where value can be 32, 64, i386, x64, /i386, /x64
+
+:: Call it like this: call :process_arch %*
+:: On return R_ARCH will be set from --arch or R_ARCH or default
+:: and R_ARCH0 will be R_ARCH without the / prefix
+:: It will look for the architecture in these places in this order:
+:: - first arg if its --arch
+:: - environment variable R_ARCH
+:: - check if R_HOME\bin\i386 exists
+:: - if R_HOME\bin\x64 exists
+:: - if none of the above then use R_ARCH=/i386
+:: Note that R_HOME should be defined before calling this routine
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+:process_arch
+	if defined R_ARCH goto:process_arch_cont
+	:: The loop searches for --arch and sets R_ARCH to the next argument
+    :process_arch_loop 
+    set arg=%~1
+    shift 
+    if not defined arg goto :process_arch_cont 
+	if "%arg%"=="--arch" set R_ARCH=%1
+	if defined R_ARCH goto:process_arch_cont
+	goto:process_arch_loop
+    :process_arch_cont
+	if defined process_arg_arch goto:process_arch_defined
+	if exist %R_HOME%\bin\i386 (set R_ARCH=/i386) & goto:process_arch_defined
+	if exist %R_HOME%\bin\x64 (set R_ARCH=/x64) & goto:process_arch_defined
+	(set R_ARCH=/i386)
+	:process_arch_defined
+	if "%R_ARCH%"=="32" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="386" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="i386" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="64" (set R_ARCH=/x64)
+	if "%R_ARCH%"=="x64" (set R_ARCH=/x64)
+	:: if R_ARCH does not begin with a slash add one as a prefix
+	(set first_char=%R_ARCH:~0,1%)
+	if not "%first_char%" == "/" (set R_ARCH=/%R_ARCH%)
+	:: R_ARCH0 is like R_ARCH but without the beginning /
+	(set R_ARCH0=%R_ARCH:~1%)
+	goto:eof
+
+endlocal

Added: grass/trunk/mswindows/external/rbatch/README
===================================================================
--- grass/trunk/mswindows/external/rbatch/README	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/README	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,367 @@
+
+batchfiles contains GPL-2 batch files for installing and maintaining R.  
+
+Each is self contained, independent of the others and need no installation. 
+Just place it anywhere on your path.
+
+---
+
+PROGRAM LIST
+
+Legend:
+h = no args gives help
+0 = common usage is to enter command name without arguments
+d = in development
+2.11 = only works with R 2.11
+* = all files marked with one star are the same.  Program checks name by which its called to determine action.
+** = all files marked with two stars are the same.  Program checks name by which its called to determine action.
+
+#Rscript.bat - put at top of R file to make it a batch file (h) (*)
+clip2r.js - pastes clipboard into Rgui.  See comments in file for use from vim. (0)(d)
+copydir.bat - copy a library from one version of R to another (h)
+el.js - run elevated - Vista and up, e.g. el Rgui  runs R elevated
+find-miktex.hta - GUI to find MiKTeX (0)
+kopy.bat - copy Rcmd to other batch files (h)(d)
+movedir.bat - move library from one version of R to another (h) 
+R.bat - like R.exe but finds R from registry (0) (*)
+Rcmd.bat - like Rcmd.exe but finds R from registry (h) (*)
+Rgui.bat - like Rgui.exe but finds R from registry (0) (*)
+RguiStart.bat - like Rgui.bat but arg1 defines folder to start R in (*)
+Rscript.bat - run .R script (h) (*)
+Rterm.bat - like rterm.exe but finds R from registry (h) (*)
+Rtidy.bat - reformat a .R file, e.g. Rtidy myfile.R > outfile.R (d)
+Rtools.bat - place Rtools on path for remainder of console session (0) (*)
+Rversions.bat - list R and set R version in registry, e.g. on Vista: el cmd/c Rversions R-2.10.1 (0)
+Rversions.hta - GUI interface to RSetReg.  List and set R version, e.g. on Vista: el cmd /c Rversions.hta (0)(2.11)
+show-svn-info.hta - show svn info if current folder is an svn checkout (0)
+Stangle.bat - run arg1 through Stangle (h) (**)
+Sweave.bat - run arg1 through Sweave (h) (**)
+
+---
+
+DESCRIPTIONS
+
+R.bat, Rcmd.bat, Rscript.bat, Rgui.bat, and RguiStart.bat are all the same
+file.  They query the name by which they were called to determine what they do.
+Similarly Sweave.bat and Stangle.bat are the same file.
+
+The home page and NEWS file provide more info.
+
+BATCH PROGRAMS
+
+0. Rtools.bat
+1. R.bat, Rcmd.bat, Rscript.bat, Rgui.bat
+2. #Rscript.bat
+3. RguiStart.bat
+4. Sweave.bat and Stangle.bat
+5. copydir.bat
+6. movedir.bat
+7. find-miktex.hta
+
+
+0. Rtools.bat.  Sets path to what Rcmd.bat and others use internally.
+This only sets the path for the current command shell instance.
+
+1. R.bat, Rcmd.bat, Rscript.bat, Rgui.bat, Rscript.bat - are front
+ends to  the corresponding .exe files.  They locate R in the registry (and also
+look in a few other places if not found there).  Then they look for Rtools and
+MiKTeX and if found they add them temporarily to the path.  (Rtools and MiKTeX
+are needed when building R packages from source but are not needed for just
+running R nor are they need to download and install binary packages from CRAN.)
+Then they run R.exe, Rcmd.exe, Rscript.exe, Rgui.exe or JGR.exe with the same
+arguments.    They are actually all the same file just renamed.  (RguiStart.bat
+described separately is also the same file and all the code from this file is
+also at the end of Sweave.bat, also described separately.)  The file checks
+what name it was called by and acts accordingly.
+
+Their main advantages are:
+- you don't have to modify your path just to run R.
+- you don't have to modify your path to build R packages from source.
+- when you upgrade R they automatically work without change
+  since they will pick up the new version of R from the registry
+  automatically.
+- Sweave.bat and Stangle.bat, unlike, Rcmd Sweave and Rcmd Stangle
+  do not depend on rtools.
+
+You can put Rgui.bat on your desktop and associate a Windows
+ShortCut key (http://support.microsoft.com/kb/310417) with
+it so that you can just press the Windows key and
+R, say, to activate R.
+
+Here are some examples of using them from the command line.
+It assumes you have placed el.js, Rcmd.bat and Rgui.bat in
+your path.  el cmd spawns a command console with Administrator
+rights.  This is needed to build HTML help but you can omit
+the el command if you don't need that.
+
+    el cmd
+	Rcmd check mypackage 
+	Rcmd build mypackage
+	Rcmd build mypackage --binary
+	Rcmd INSTALL mypackage_1.0-0.tar.gz
+	Rcmd INSTALL mypackage_1.0-0.tar.gz -l library
+	Rscript myprog.R < mydata.dat
+	Rgui
+
+(When installing packages on Vista it is recommended that
+you do this from within a console session that has Administrator
+rights.  It will typically work even without that; however, the
+HTML help will not be created.)
+
+Older version of the Rcmd BATCH command in R had problems
+with spaces in pathnames so be sure you use a sufficiently
+recent version of R.  If you are using an old version of R
+that has problems use the short name corresponding to any
+long name with spaces:
+
+For example, suppose we have a file 
+   C:\Documents and Settings\Administrator\myfile.R .
+Then try this:
+
+	cd \
+	dir/x doc*
+	Rcmd BATCH c:\docume~1\Administrator\myfile.R
+
+where the dir/x command showed us the short name corresponding to
+the longer space-embedded name: Documents and Settings.  
+
+2. #Rscript.bat
+
+#Rscript.bat can be used as the first line of an R script to make 
+it callable as a batch file.  For example, if we have a myfile.R
+file then we can create a myfile.bat file that looks like this:
+
+#Rscript %0 %*
+...R code from myfile.R goes here...
+
+and now we can just issue the command myfile to run it.  We
+no longer need myfile.R.
+
+See the Rtidy.bat file for an example.  Note that it does have 
+the disadvantage that the output of the R program starts off 
+with the command itself.  R needs to be able to handle the 
+perl/python/ruby -x switch.  In the meantime #Rscript.bat 
+will mainly be useful for those scripts where the output does 
+not go to the standard output or where the addition of this 
+line is acceptable.
+
+3. RguiStart.bat
+
+This is like Rgui.bat except it intercepts the first argument
+and interprets it as the folder in which to start R (or if its
+an .Rdata file then it interprets it as the .Rdata file to start 
+R with).  The main reason for its existence is so that you can 
+place it in your SendTo folder.  On Vista do this:
+
+  copy RguiStart.bat %APPDATA%\Microsoft\Windows\SendTo
+
+(or to locate locate the SendTo folder in Windows Explorer on Vista
+enter shell:sendto into the Windows Explorer address bar and copy
+your RguiStart.bat file there.)
+
+Then, on Vista, when you are in Windows Explorer you can right click 
+on any folder in your user area and choose SendTo.  From the SendTo
+menu choose RGuiStart.bat to start up R in that folder.  If you 
+right click on an .Rdata file rather than a folder then R will
+start up with that file loaded (although in that case its probably
+easier to just double click the .Rdata file provided you have
+file type associations set up -- if you don't then the RguiStart.bat
+will provide an alternative).
+
+A second possibility is to place RguiStart.bat on your desktop and
+then drag a folder to it to start R in that folder.
+
+A third possibility is to just shift right click a folder in Windows
+Explorer and choose Open Command Window Here and then when the command
+window opens enter Rgui assuming you have placed Rgui.bat somewhere in
+your path.
+
+4. Sweave.bat and Stangle.bat - will run Sweave, then pdflatex and then
+display latex file.  Stangle.bat will run Stangle producing an R file.
+Unlike Rcmd Sweave and Rcmd Stangle these do not depend on rtools.
+Sweave.bat and Stangle.bat are actually the same file.  The file determines
+what to do by looking at the name by which it was called.
+
+      Sweave mydoc.Rnw
+   or
+      Sweave mydoc 
+
+The script runs Sweave, pdflatex and then displays the pdf
+file (assuming the user has .pdf extension associated with a
+pdf viewer).  If there is an error in Sweave or the .tex
+file is not newer than the Sweave'd file the script stops.
+Similarly if there is an error in pdflatex or the .pdf is
+not newer than the .tex file then the script stops.  Note
+that _two_ .pdf files are generated.  They are identical
+except one has a unique name created by suffixing the base
+with the date and time and .bck.pdf.  The one with the unique name 
+is the one viewed.  This overcomes problems of not being able to
+view the .pdf if the .pdf from a prior run is current being
+viewed (which would happen since by default the Acrobat viewer 
+won't allow you to view two files of the same name concurrently).
+Every so often the user should delete all *.bck.pdf files.
+
+Try:
+
+sweave
+
+without arguments to see options and get more info.
+
+Aside from using sweave from the command line, if you place
+sweave.bat in your SendTo folder as discussed under
+RguiStart.bat you can right click .Rnw files and choose
+SendTo > sweave to sweave them.
+
+You may need to copy Sweave.sty to the directory containing
+your .Rnw sweave file to use sweave.bat .
+
+5. Rversions.bat - similar to Rversions.hta but 
+-- its batch whereas Rversions.hta is GUI
+-- uses slightly different heuristic to find R versions
+-- run without args to list versions available; run with any of
+   the listed versions to set that as the new version
+-- both forms work on XP; to run arg form on Vista run it elevated
+   e.g. el cmd /c Rversions.bat R-2.10.0
+
+Examples:
+
+	:: list R versions
+	rversions.bat
+
+	:: check mypkg using R current version, 2.4.0, say
+	Rcmd check mypkg
+
+	:: switch to version R-2.5.0 and recheck
+	rversions R-2.5.0
+	Rcmd check mypkg
+
+	:: reset back to version 2.4.0
+	rversions.bat R-2.4.0
+
+6. copydir.bat - can be used to copy the libraries from an
+old version of R to your new one.  It will not overwrite any
+libraries already there so it should be safe to use. e.g. to
+upgrade R to a new version
+
+  :: Example is for upgrading from R-2.4.1 to R-2.5.0
+
+  :: first, download and install R-2.11.0
+  :: now perform the next two commands at the Windows console
+
+  cd %userprofile%\Documents\R\win-library
+  :: you can use movedir instead of copydir if you prefer to move them
+  copydir 2.10\library 2.11\library
+  
+  :: ... now startup new version of R (R 2.11.0 in this example)
+  # issue this command in R 2.5.0
+  update.packages(checkBuilt = TRUE, ask = "graphics")
+  # or (see note below)
+  update.packages(ask = "graphics")
+
+  :: press OK and it will update those packages as necessary
+
+  # ... optionally check for deprecated packages
+  # 1. first select all repositories that you use with menu:
+  #    Packages | Repositories
+  # 2. second check if there are any deprecated packages that
+  #    were copied over but are not longer on CRAN or other repository
+  dp <- setdiff(installed.packages()[,1], available.packages()[,1])
+  # look at what we have
+  dp
+  # if you wish to remove them issue the remove.packages command:
+  # remove.packages(dp)
+
+  :: ... exit R and start it up again ...
+
+Note that the checkBuilt=TRUE argument will potentially
+cause all your packages to be downloaded again so you could
+try leaving it off and then reissue the command with
+checkBuilt=TRUE later only if you run into problems.  I
+normally do it without the checkBuilt=TRUE.
+
+It is anticipated that this command will ultimately be
+superceded by functionality in the R setup procedure at
+which time this will be deprecated.  Note that this method
+of just copying libraries may not work depending on the
+versions of R involved.  If its necessary to re-install most
+packages it can be done by issuing the following R command
+after performing the copydir.bat:
+install.packages(installed.packages()[,1])
+ 
+(Note that 2.8 of the R Windows FAQ
+
+http://cran.r-project.org/bin/windows/base/rw-FAQ.html#What_0027s-the-best-way-to-upgrade_003f
+
+refers to copying any installed package to the library
+folder but does not address how to accomplish that.  That
+omission is what copydir.bat addresses.)
+
+An alternative to copydir is to reinstall all packages
+
+	# Alternative to copydir.bat #1
+	# this example is for moving from 2.4.1 to 2.5.0
+	# run this in R 2.5.0
+	setwd(R.home())
+	ip <- installed.packages(lib.loc = "../R-2.4.1/library")
+	ip <- ip[ip[,1]!="base" ,1]
+	install.packages(ip)
+
+The above is taken from:
+https://www.stat.math.ethz.ch/pipermail/r-help/2007-May/131806.html
+Note that you may still have to use movedir.bat or copydir.bat
+after the above if it fails to install everything.  Since movedir.bat
+and copydir.bat won't overwrite anything this should be safe.
+
+	# Alternative to copydir.bat #2
+	#---run in previous version, e.g. R 2.4.1
+	packages <- installed.packages()[,"Package"]
+	save(packages, file = "~/Rpackages")
+
+	#---run in new version, e.g. R 2.5.0
+	load("~/Rpackages")
+	install.packages(setdiff(packages, installed.packages()[,"Package"]))
+
+	file.remove("~/Rpackages")
+
+This copydir alternative is based on:
+https://www.stat.math.ethz.ch/pipermail/r-help/2007-May/131131.html
+
+7. movedir - same arguments as copydir.  Only difference is
+that it moves the directories rather than copying them.  This
+can be used if you are no longer interested in using the
+packages with the old version of R other than by
+reinstalling them.)  This has the advantage that its much
+faster than copydir.  The example under copydir works with
+movedir too.  Just replace copydir with movedir in that
+example.  Comments under copydir.bat apply here too.  I
+mostly use movedir.bat myself instead of copydir.bat since
+its so much faster.
+
+8. show-svn-info.hta - Just run this from any Tortoise SVN folder
+and it will display some information about it.  Requires version 1.5
+or higher of Tortoise SVN.
+
+9. find-miktex.hta - displays the path to the MiKTeX bin directory.
+Just enter find-miktex.hta at the Windows command line (no arguments 
+are needed) or double click it from Windows Explorer.  
+
+ADDITIONAL FILES
+
+1. RESOURCES - additional information on writing Windows XP
+batch files.
+
+2. COPYRIGHT and COPYING - this is free software subject to
+   the GPL license as described.
+
+3. THANKS - acknowledgments.
+
+DEPRECATED AND CHANGED
+
+- Rfind.bat
+- makepkg.bat
+- Rversions.hta
+- toggerDoc.pl
+
+These are no longer distributed but can be found in older distributions of this
+package.  It is unknown whether they work with recent versions of R.  (I found
+I was not using these so am no longer maintaining them.)

Added: grass/trunk/mswindows/external/rbatch/README.grass
===================================================================
--- grass/trunk/mswindows/external/rbatch/README.grass	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/README.grass	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,22 @@
+README.grass - written by Helmut Kudrnovsky - alectoria gmx.at
+
+This directory contains windows batch files for installing and maintaining R, for 
+an improved coupling of GRASS GIS and R (www.r-project.org) in a windows environment.
+
+--
+
+Files integrated from 
+
+svn checkout http://batchfiles.googlecode.com/svn/trunk/
+
+at svn-revision 104 (2012-08-31).
+
+--
+
+For more information on 'Windows batchfiles for use with R' see their home page at
+
+http://code.google.com/p/batchfiles/
+
+or read the README file in this directory.
+
+--
\ No newline at end of file

Added: grass/trunk/mswindows/external/rbatch/RESOURCES
===================================================================
--- grass/trunk/mswindows/external/rbatch/RESOURCES	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/RESOURCES	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,146 @@
+XP BATCH COMMAND RESOURCES
+
+This file contains R-specific resources for Windows XP batch file
+creation and also general resources for Windows XP batch file creation.
+
+A. MAKING A WINDOWS PACKAGE IN R
+--------------------------------
+
+Make sure that:
+
+- you have read:
+   "Writing R Extensions" manual
+   http://www.murdoch-sutherland.com/Rtools/
+
+- you have downloaded and installed the tools from
+  http://www.murdoch-sutherland.com/Rtools/tools.zip.
+
+- you have installed LaTeX (MiKTeX), perl, the Microsoft help
+  compiler, and (if the package contains C or Fortran source code) the
+  MinGW compilers, as described at
+    http://www.murdoch-sutherland.com/Rtools/.
+  
+- read
+  http://www.murdoch-sutherland.com/Rtools/miktex.html
+
+- your path contains the tools, htmlhelp, and the bin directories for R,
+  LaTeX, Perl, and (if the package contains C or Fortran source code
+  to be compiled with MinGW) MinGW.  The tools directory should be the
+  first item in the path.  This link shows how to set your path:
+  http://www.computerhope.com/issues/ch000549.htm
+
+Assuming that the R installation is in \Program Files\R\R-x.y-z
+
+1. Assuming your source package tree is in \Rpkgs\mypackage
+   then at a Windows command prompt:
+
+        cd \Rpkgs
+        Rcmd INSTALL mypackage
+
+   which will install it to \Program Files\R\R-x.y-z\library\mypackage
+   Or if you want to install it to a separate library:
+
+        cd \Rpkgs
+        md library
+        Rcmd INSTALL -l library mypackage
+
+2. Now in R:
+
+        library(mypackage)
+        ... test it out ...
+
+   or if you installed it to a separate library:
+
+        library(mypackage, lib = "/Rpkgs/library")
+
+3. Once it seems reasonably OK, see whether it passes Rcmd check:
+
+        cd \Rpkgs
+        Rcmd check mypackage
+
+   and fix it up until it does.
+
+4. Now create versions for Unix and Windows that you can distribute:
+
+        cd \Rpkgs
+        Rcmd build mypackage
+        Rcmd build mypackage --binary
+
+5. If you want to submit it to CRAN then upload the .tar.gz
+   file that was created from the "Rcmd build mypackage"
+   command in #4 to ftp://cran.R-project.org/incoming .
+   I usually use FileZilla to do the upload.
+   http://filezilla.sourceforge.net/
+
+
+B. Some R Resources on making packages
+--------------------------------------
+
+John Fox provides a batch file for making packages:
+
+	http://tolstoy.newcastle.edu.au/R/help/04/11/6729.html
+
+Henrik Bengtsson provides a batch file for setting environment
+variables:
+
+	http://tolstoy.newcastle.edu.au/R/devel/04a/0594.html
+
+Information on building packages can be found in the Writing
+Extensions Manual.    The following link is also useful although
+the enclosed batch files eliminate the need for some of the 
+procedures discussed:
+
+	http://www.murdoch-sutherland.com/Rtools/
+
+Googling for
+
+	creating making R packages
+
+will find links to a number of privately written tutorials.
+(I have not reviewed these.)
+
+C. GENERAL RESOURCES ON WINDOWS BATCH FILE PROGRAMMMING
+-------------------------------------------------------
+
+The Windows command line commands will bring up help information 
+that is particularly useful:
+
+	help set
+	help for
+	help if
+
+Here are some links on Windows batch file programmming.
+
+	ftp://garbo.uwasa.fi/pc/link/tscmd.zip - FAQ with many idioms
+
+	http://gearbox.maem.umr.edu/batch/f_w_util/ - Frank Westlake utilities
+
+	http://gearbox.maem.umr.edu/fwu/ - more Frank Westlake utilities
+
+	http://groups-beta.google.com/group/alt.msdos.batch.nt/msg/5a9587e871c27a75 - cmd bugs
+
+	http://groups-beta.google.com/group/alt.msdos.batch/msg/7b1d22945c89af75 - cmd help resources 
+
+	http://msdn.microsoft.com/downloads/list/webdev.asp - Windows script downloads
+
+	http://thesystemguard.com/TheGuardBook/CCS-Int/ - info on batch commands
+
+	http://www.allenware.com/icsw/icswref.htm - info on batch commands
+
+	http://www.commandline.co.uk - Ritchie Lawrence cmd line utilities
+
+	http://www.cybermesa.com/~bstewart/ - Bill Stewart’s scripting tools
+
+	http://www.fpschultze.de - FP Shcultze’s batch tricks
+
+	http://www.microsoft.com/technet/community/columns/scripts - MS TechNet scripting
+
+	http://www.murdoch-sutherland.com/Rtools - R package building tools
+
+	http://www.paulsadowski.com/WSH/cmdutils.htm - Paul Sadowski batch info
+
+	http://www.ss64.com/nt/index.html - batch command reference
+
+	http://www.vlaurie.com/computers2/Articles/rundll32.htm - rundll for batch scripts
+
+

Added: grass/trunk/mswindows/external/rbatch/Rcmd.bat
===================================================================
--- grass/trunk/mswindows/external/rbatch/Rcmd.bat	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/Rcmd.bat	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,239 @@
+
+ at echo off
+rem if /i "%1"==path (path %2) && goto:eof
+
+setlocal
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: Placing this file in your path will allow rcmd to be run anywhere
+:: without changing your path environment variable.  See comments
+:: below on how it finds where R is.  Your path can be listed by
+:: the Windows console command:  path
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+rem at one tine this script had only been tested on XP
+rem recent tests have only been on Vista
+rem ver | findstr XP >NUL
+rem if errorlevel 1 echo Warning: This script has only been tested on Windows XP.
+
+set scriptdir_=%~dp0
+set lookin=.;%userprofile%;%scriptdir_%
+if not defined R_BATCHFILES_RC (
+	for %%f in ("rbatchfilesrc.bat") do set "R_BATCHFILES_RC=%%~$lookin:f"
+)
+if defined R_BATCHFILES_RC (
+	if exist "%R_BATCHFILES_RC%" call %R_BATCHFILES_RC%
+)
+
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: use environment variable R_HOME if defined
+:: else current folder if bin\rcmd.exe exists 
+:: else most current R as determined by registry entry
+:: else error
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+if not defined R_HOME if exist bin\r.exe set R_HOME=%CD%
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\R-core\R /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\r-core\r /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+if not defined R_HOME echo "Error: R not found" & goto:eof
+
+call :process_arch %*
+
+:: add R_MIKTEX to PATH if defined.  Otherwise if its not 
+:: in the PATH already then check \Program Files\miktex* or \miktex* 
+:: and if found add that to PATH.
+
+:: if miktex found in PATH skip searching for it
+PATH | findstr /i miktex > nul
+if not errorlevel 1 goto:end_miktex
+
+:: check for presence of %ProgramFiles%\miktex* or \miktex*
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on "%ProgramFiles%"\miktex* 2^>NUL'
+) do set R_MIKTEX=%ProgramFiles%\%%a
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on %SystemDrive%:\miktex* 2^>NUL'
+) do set R_MIKTEX=%SystemDrive%:\miktex\%%a
+
+:end_miktex
+if defined R_MIKTEX PATH %R_MIKTEX%\miktex\bin;%PATH%
+
+if not defined MYSQL_HOME for /f "delims=" %%a in (
+    'dir /b /on "%ProgramFiles%"\MySQL\* 2^>NUL'
+) do set MYSQL_HOME=%ProgramFiles%\MySQL\%%a
+
+if not defined R_TOOLS for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\R-core\Rtools /v InstallPath 2^>NUL ^| findstr InstallPath'
+ ) do set R_TOOLS=%%~b
+if not defined R_TOOLS for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\Rtools /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_TOOLS=%%~b
+
+set PATHQ=%PATH%
+:WHILE
+    if "%PATHQ%"=="" goto WEND
+    for /F "delims=;" %%i in ("%PATHQ%") do if exist "%%~sfi" set PATH2=%PATH2%;%%~sfi
+    for /F "delims=; tokens=1,*" %%i in ("%PATHQ%") do set PATHQ=%%j
+    goto WHILE 
+:WEND
+
+set path2=%path2:~1%
+
+if defined R_TOOLS (
+    set path2=%R_TOOLS%\bin;%R_TOOLS%\perl\bin;%R_TOOLS%\MinGW\bin;%PATH2%
+)
+
+path %path2%
+
+set here=%CD%
+set args=%*
+
+:: get name by which this command was called
+:: this allows same file to be used for Rgui, Rterm, etc. by just renaming it
+for %%i in (%0) do set cmd=%%~ni.exe
+
+if /i %cmd%==rtools.exe (endlocal & set path=%path2%) && goto:eof
+
+cd %R_HOME%\bin
+if /i not %cmd%==rguistart.exe goto:notRguiStart
+  set cmd=rgui.exe
+  set firstArgument=%1
+  if defined firstArgument (
+    dir %1 | findstr "<DIR>" > nul
+    if errorlevel 1 goto:notRguiStart
+    set here=%~1
+    set firstArgument=
+  )
+  set args=
+  shift
+  :startloop
+  set firstArgument=%1
+  if defined firstArgument (
+     set args=%args% "%~1" 
+     shift
+     goto:startloop
+  )
+:notRguiStart
+
+set st=
+if /i %cmd%==rgui.exe set st=start
+
+if /i not %cmd%==#Rscript.exe goto:not#Rscript
+set cmd=Rscript.exe
+if [%1]==[] goto:help#Rscript
+call :rsarg1 %*
+goto:not#Rscript
+:rsarg1
+set args=%*
+set arg1=%~1
+set arg1=%arg1:.bat.bat=.bat%
+set last4=%arg1:~-4%
+if /i not "%last4%"==".bat" set arg1=%arg1%.bat
+for %%a in ("%R_HOME%\bin\Rscript.exe") do set RSCRIPT=%%~sfa
+call set args=%%args:%1="%arg1%"%%
+rem call set args=%%args:%1=%%
+goto:eof
+:not#Rscript
+
+cd %here%
+
+:: Look in architecture specific subdirectory of bin. If not there look in bin.
+set cmdpath=%R_HOME%\bin\%R_ARCH0%\%cmd%
+if exist "%cmdpath%" goto:cmdpathfound
+set cmdpath=%R_HOME%\bin\%cmd%
+if exist "%cmdpath%" goto:cmdpathfound
+echo "Error: %cmd% not found" & goto:eof
+:cmdpathfound
+
+:: if called as jgr.bat locate the JGR package to find jgr.exe
+if /i not %cmd%==jgr.exe goto:notJGR
+  set st=start
+  set cmdpath=jgr.exe
+  if not defined JGR_LIBS set JGR_LIBS=%R_LIBS%
+  for %%a in ("%R_HOME%\bin\Rscript.exe") do set RSCRIPT=%%~sfa
+  if not defined JGR_LIBS for /f "usebackq delims=" %%a in (
+		`%RSCRIPT% -e "cat(.libPaths(),sep=';')"`
+  ) do set JGR_LIBS=%%~a
+  if not defined JGR_LIBS (
+	echo "Error: JGR package not found in R library" & goto:eof
+  )
+  for %%f in ("JGR") do set "jgrpkg=%%~$JGR_LIBS:f"
+  set JGR_LIB=%jgrpkg:~0,-4%
+  for %%a in ("%JGR_LIB%") do set JGR_LIB_SHORT=%%~sfa
+  for %%a in ("%R_HOME%") do set R_HOME_SHORT=%%~sfa
+  set args=--libpath=%JGR_LIB_SHORT% --rhome=%R_HOME_SHORT%
+
+:notJGR
+
+rem set R_ARCH
+rem set R_ARCH0
+rem set cmdpath
+rem if defined st set st
+rem set args
+
+set cygwin=nodosfilewarning
+if not defined args goto:noargs
+if defined st (start "" "%cmdpath%" %args%) else "%cmdpath%" %args%
+goto:eof
+:noargs
+if defined st (start "" "%cmdpath%") else "%cmdpath%"
+goto:eof
+
+:help#Rscript
+echo Usage: #Rscript %%0 %%*
+echo If the above is the first line in a file 
+echo containing only R code and the file is 
+echo given a .bat extension then it can be 
+echo run as a batch file.
+goto:eof
+
+
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: processing of --arch= where value can be 32, 64, i386, x64, /i386, /x64
+
+:: Call it like this: call :process_arch %*
+:: On return R_ARCH will be set from --arch or R_ARCH or default
+:: and R_ARCH0 will be R_ARCH without the / prefix
+:: It will look for the architecture in these places in this order:
+:: - first arg if its --arch
+:: - environment variable R_ARCH
+:: - check if R_HOME\bin\i386 exists
+:: - if R_HOME\bin\x64 exists
+:: - if none of the above then use R_ARCH=/i386
+:: Note that R_HOME should be defined before calling this routine
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+:process_arch
+	if defined R_ARCH goto:process_arch_cont
+	:: The loop searches for --arch and sets R_ARCH to the next argument
+    :process_arch_loop 
+    set arg=%~1
+    shift 
+    if not defined arg goto :process_arch_cont 
+	if "%arg%"=="--arch" set R_ARCH=%1
+	if defined R_ARCH goto:process_arch_cont
+	goto:process_arch_loop
+    :process_arch_cont
+	if defined process_arg_arch goto:process_arch_defined
+	if exist %R_HOME%\bin\i386 (set R_ARCH=/i386) & goto:process_arch_defined
+	if exist %R_HOME%\bin\x64 (set R_ARCH=/x64) & goto:process_arch_defined
+	(set R_ARCH=/i386)
+	:process_arch_defined
+	if "%R_ARCH%"=="32" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="386" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="i386" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="64" (set R_ARCH=/x64)
+	if "%R_ARCH%"=="x64" (set R_ARCH=/x64)
+	:: if R_ARCH does not begin with a slash add one as a prefix
+	(set first_char=%R_ARCH:~0,1%)
+	if not "%first_char%" == "/" (set R_ARCH=/%R_ARCH%)
+	:: R_ARCH0 is like R_ARCH but without the beginning /
+	(set R_ARCH0=%R_ARCH:~1%)
+	goto:eof
+
+endlocal

Added: grass/trunk/mswindows/external/rbatch/Rgui.bat
===================================================================
--- grass/trunk/mswindows/external/rbatch/Rgui.bat	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/Rgui.bat	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,239 @@
+
+ at echo off
+rem if /i "%1"==path (path %2) && goto:eof
+
+setlocal
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: Placing this file in your path will allow rcmd to be run anywhere
+:: without changing your path environment variable.  See comments
+:: below on how it finds where R is.  Your path can be listed by
+:: the Windows console command:  path
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+rem at one tine this script had only been tested on XP
+rem recent tests have only been on Vista
+rem ver | findstr XP >NUL
+rem if errorlevel 1 echo Warning: This script has only been tested on Windows XP.
+
+set scriptdir_=%~dp0
+set lookin=.;%userprofile%;%scriptdir_%
+if not defined R_BATCHFILES_RC (
+	for %%f in ("rbatchfilesrc.bat") do set "R_BATCHFILES_RC=%%~$lookin:f"
+)
+if defined R_BATCHFILES_RC (
+	if exist "%R_BATCHFILES_RC%" call %R_BATCHFILES_RC%
+)
+
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: use environment variable R_HOME if defined
+:: else current folder if bin\rcmd.exe exists 
+:: else most current R as determined by registry entry
+:: else error
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+if not defined R_HOME if exist bin\r.exe set R_HOME=%CD%
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\R-core\R /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\r-core\r /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+if not defined R_HOME echo "Error: R not found" & goto:eof
+
+call :process_arch %*
+
+:: add R_MIKTEX to PATH if defined.  Otherwise if its not 
+:: in the PATH already then check \Program Files\miktex* or \miktex* 
+:: and if found add that to PATH.
+
+:: if miktex found in PATH skip searching for it
+PATH | findstr /i miktex > nul
+if not errorlevel 1 goto:end_miktex
+
+:: check for presence of %ProgramFiles%\miktex* or \miktex*
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on "%ProgramFiles%"\miktex* 2^>NUL'
+) do set R_MIKTEX=%ProgramFiles%\%%a
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on %SystemDrive%:\miktex* 2^>NUL'
+) do set R_MIKTEX=%SystemDrive%:\miktex\%%a
+
+:end_miktex
+if defined R_MIKTEX PATH %R_MIKTEX%\miktex\bin;%PATH%
+
+if not defined MYSQL_HOME for /f "delims=" %%a in (
+    'dir /b /on "%ProgramFiles%"\MySQL\* 2^>NUL'
+) do set MYSQL_HOME=%ProgramFiles%\MySQL\%%a
+
+if not defined R_TOOLS for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\R-core\Rtools /v InstallPath 2^>NUL ^| findstr InstallPath'
+ ) do set R_TOOLS=%%~b
+if not defined R_TOOLS for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\Rtools /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_TOOLS=%%~b
+
+set PATHQ=%PATH%
+:WHILE
+    if "%PATHQ%"=="" goto WEND
+    for /F "delims=;" %%i in ("%PATHQ%") do if exist "%%~sfi" set PATH2=%PATH2%;%%~sfi
+    for /F "delims=; tokens=1,*" %%i in ("%PATHQ%") do set PATHQ=%%j
+    goto WHILE 
+:WEND
+
+set path2=%path2:~1%
+
+if defined R_TOOLS (
+    set path2=%R_TOOLS%\bin;%R_TOOLS%\perl\bin;%R_TOOLS%\MinGW\bin;%PATH2%
+)
+
+path %path2%
+
+set here=%CD%
+set args=%*
+
+:: get name by which this command was called
+:: this allows same file to be used for Rgui, Rterm, etc. by just renaming it
+for %%i in (%0) do set cmd=%%~ni.exe
+
+if /i %cmd%==rtools.exe (endlocal & set path=%path2%) && goto:eof
+
+cd %R_HOME%\bin
+if /i not %cmd%==rguistart.exe goto:notRguiStart
+  set cmd=rgui.exe
+  set firstArgument=%1
+  if defined firstArgument (
+    dir %1 | findstr "<DIR>" > nul
+    if errorlevel 1 goto:notRguiStart
+    set here=%~1
+    set firstArgument=
+  )
+  set args=
+  shift
+  :startloop
+  set firstArgument=%1
+  if defined firstArgument (
+     set args=%args% "%~1" 
+     shift
+     goto:startloop
+  )
+:notRguiStart
+
+set st=
+if /i %cmd%==rgui.exe set st=start
+
+if /i not %cmd%==#Rscript.exe goto:not#Rscript
+set cmd=Rscript.exe
+if [%1]==[] goto:help#Rscript
+call :rsarg1 %*
+goto:not#Rscript
+:rsarg1
+set args=%*
+set arg1=%~1
+set arg1=%arg1:.bat.bat=.bat%
+set last4=%arg1:~-4%
+if /i not "%last4%"==".bat" set arg1=%arg1%.bat
+for %%a in ("%R_HOME%\bin\Rscript.exe") do set RSCRIPT=%%~sfa
+call set args=%%args:%1="%arg1%"%%
+rem call set args=%%args:%1=%%
+goto:eof
+:not#Rscript
+
+cd %here%
+
+:: Look in architecture specific subdirectory of bin. If not there look in bin.
+set cmdpath=%R_HOME%\bin\%R_ARCH0%\%cmd%
+if exist "%cmdpath%" goto:cmdpathfound
+set cmdpath=%R_HOME%\bin\%cmd%
+if exist "%cmdpath%" goto:cmdpathfound
+echo "Error: %cmd% not found" & goto:eof
+:cmdpathfound
+
+:: if called as jgr.bat locate the JGR package to find jgr.exe
+if /i not %cmd%==jgr.exe goto:notJGR
+  set st=start
+  set cmdpath=jgr.exe
+  if not defined JGR_LIBS set JGR_LIBS=%R_LIBS%
+  for %%a in ("%R_HOME%\bin\Rscript.exe") do set RSCRIPT=%%~sfa
+  if not defined JGR_LIBS for /f "usebackq delims=" %%a in (
+		`%RSCRIPT% -e "cat(.libPaths(),sep=';')"`
+  ) do set JGR_LIBS=%%~a
+  if not defined JGR_LIBS (
+	echo "Error: JGR package not found in R library" & goto:eof
+  )
+  for %%f in ("JGR") do set "jgrpkg=%%~$JGR_LIBS:f"
+  set JGR_LIB=%jgrpkg:~0,-4%
+  for %%a in ("%JGR_LIB%") do set JGR_LIB_SHORT=%%~sfa
+  for %%a in ("%R_HOME%") do set R_HOME_SHORT=%%~sfa
+  set args=--libpath=%JGR_LIB_SHORT% --rhome=%R_HOME_SHORT%
+
+:notJGR
+
+rem set R_ARCH
+rem set R_ARCH0
+rem set cmdpath
+rem if defined st set st
+rem set args
+
+set cygwin=nodosfilewarning
+if not defined args goto:noargs
+if defined st (start "" "%cmdpath%" %args%) else "%cmdpath%" %args%
+goto:eof
+:noargs
+if defined st (start "" "%cmdpath%") else "%cmdpath%"
+goto:eof
+
+:help#Rscript
+echo Usage: #Rscript %%0 %%*
+echo If the above is the first line in a file 
+echo containing only R code and the file is 
+echo given a .bat extension then it can be 
+echo run as a batch file.
+goto:eof
+
+
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: processing of --arch= where value can be 32, 64, i386, x64, /i386, /x64
+
+:: Call it like this: call :process_arch %*
+:: On return R_ARCH will be set from --arch or R_ARCH or default
+:: and R_ARCH0 will be R_ARCH without the / prefix
+:: It will look for the architecture in these places in this order:
+:: - first arg if its --arch
+:: - environment variable R_ARCH
+:: - check if R_HOME\bin\i386 exists
+:: - if R_HOME\bin\x64 exists
+:: - if none of the above then use R_ARCH=/i386
+:: Note that R_HOME should be defined before calling this routine
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+:process_arch
+	if defined R_ARCH goto:process_arch_cont
+	:: The loop searches for --arch and sets R_ARCH to the next argument
+    :process_arch_loop 
+    set arg=%~1
+    shift 
+    if not defined arg goto :process_arch_cont 
+	if "%arg%"=="--arch" set R_ARCH=%1
+	if defined R_ARCH goto:process_arch_cont
+	goto:process_arch_loop
+    :process_arch_cont
+	if defined process_arg_arch goto:process_arch_defined
+	if exist %R_HOME%\bin\i386 (set R_ARCH=/i386) & goto:process_arch_defined
+	if exist %R_HOME%\bin\x64 (set R_ARCH=/x64) & goto:process_arch_defined
+	(set R_ARCH=/i386)
+	:process_arch_defined
+	if "%R_ARCH%"=="32" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="386" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="i386" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="64" (set R_ARCH=/x64)
+	if "%R_ARCH%"=="x64" (set R_ARCH=/x64)
+	:: if R_ARCH does not begin with a slash add one as a prefix
+	(set first_char=%R_ARCH:~0,1%)
+	if not "%first_char%" == "/" (set R_ARCH=/%R_ARCH%)
+	:: R_ARCH0 is like R_ARCH but without the beginning /
+	(set R_ARCH0=%R_ARCH:~1%)
+	goto:eof
+
+endlocal

Added: grass/trunk/mswindows/external/rbatch/RguiStart.bat
===================================================================
--- grass/trunk/mswindows/external/rbatch/RguiStart.bat	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/RguiStart.bat	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,239 @@
+
+ at echo off
+rem if /i "%1"==path (path %2) && goto:eof
+
+setlocal
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: Placing this file in your path will allow rcmd to be run anywhere
+:: without changing your path environment variable.  See comments
+:: below on how it finds where R is.  Your path can be listed by
+:: the Windows console command:  path
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+rem at one tine this script had only been tested on XP
+rem recent tests have only been on Vista
+rem ver | findstr XP >NUL
+rem if errorlevel 1 echo Warning: This script has only been tested on Windows XP.
+
+set scriptdir_=%~dp0
+set lookin=.;%userprofile%;%scriptdir_%
+if not defined R_BATCHFILES_RC (
+	for %%f in ("rbatchfilesrc.bat") do set "R_BATCHFILES_RC=%%~$lookin:f"
+)
+if defined R_BATCHFILES_RC (
+	if exist "%R_BATCHFILES_RC%" call %R_BATCHFILES_RC%
+)
+
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: use environment variable R_HOME if defined
+:: else current folder if bin\rcmd.exe exists 
+:: else most current R as determined by registry entry
+:: else error
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+if not defined R_HOME if exist bin\r.exe set R_HOME=%CD%
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\R-core\R /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\r-core\r /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+if not defined R_HOME echo "Error: R not found" & goto:eof
+
+call :process_arch %*
+
+:: add R_MIKTEX to PATH if defined.  Otherwise if its not 
+:: in the PATH already then check \Program Files\miktex* or \miktex* 
+:: and if found add that to PATH.
+
+:: if miktex found in PATH skip searching for it
+PATH | findstr /i miktex > nul
+if not errorlevel 1 goto:end_miktex
+
+:: check for presence of %ProgramFiles%\miktex* or \miktex*
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on "%ProgramFiles%"\miktex* 2^>NUL'
+) do set R_MIKTEX=%ProgramFiles%\%%a
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on %SystemDrive%:\miktex* 2^>NUL'
+) do set R_MIKTEX=%SystemDrive%:\miktex\%%a
+
+:end_miktex
+if defined R_MIKTEX PATH %R_MIKTEX%\miktex\bin;%PATH%
+
+if not defined MYSQL_HOME for /f "delims=" %%a in (
+    'dir /b /on "%ProgramFiles%"\MySQL\* 2^>NUL'
+) do set MYSQL_HOME=%ProgramFiles%\MySQL\%%a
+
+if not defined R_TOOLS for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\R-core\Rtools /v InstallPath 2^>NUL ^| findstr InstallPath'
+ ) do set R_TOOLS=%%~b
+if not defined R_TOOLS for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\Rtools /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_TOOLS=%%~b
+
+set PATHQ=%PATH%
+:WHILE
+    if "%PATHQ%"=="" goto WEND
+    for /F "delims=;" %%i in ("%PATHQ%") do if exist "%%~sfi" set PATH2=%PATH2%;%%~sfi
+    for /F "delims=; tokens=1,*" %%i in ("%PATHQ%") do set PATHQ=%%j
+    goto WHILE 
+:WEND
+
+set path2=%path2:~1%
+
+if defined R_TOOLS (
+    set path2=%R_TOOLS%\bin;%R_TOOLS%\perl\bin;%R_TOOLS%\MinGW\bin;%PATH2%
+)
+
+path %path2%
+
+set here=%CD%
+set args=%*
+
+:: get name by which this command was called
+:: this allows same file to be used for Rgui, Rterm, etc. by just renaming it
+for %%i in (%0) do set cmd=%%~ni.exe
+
+if /i %cmd%==rtools.exe (endlocal & set path=%path2%) && goto:eof
+
+cd %R_HOME%\bin
+if /i not %cmd%==rguistart.exe goto:notRguiStart
+  set cmd=rgui.exe
+  set firstArgument=%1
+  if defined firstArgument (
+    dir %1 | findstr "<DIR>" > nul
+    if errorlevel 1 goto:notRguiStart
+    set here=%~1
+    set firstArgument=
+  )
+  set args=
+  shift
+  :startloop
+  set firstArgument=%1
+  if defined firstArgument (
+     set args=%args% "%~1" 
+     shift
+     goto:startloop
+  )
+:notRguiStart
+
+set st=
+if /i %cmd%==rgui.exe set st=start
+
+if /i not %cmd%==#Rscript.exe goto:not#Rscript
+set cmd=Rscript.exe
+if [%1]==[] goto:help#Rscript
+call :rsarg1 %*
+goto:not#Rscript
+:rsarg1
+set args=%*
+set arg1=%~1
+set arg1=%arg1:.bat.bat=.bat%
+set last4=%arg1:~-4%
+if /i not "%last4%"==".bat" set arg1=%arg1%.bat
+for %%a in ("%R_HOME%\bin\Rscript.exe") do set RSCRIPT=%%~sfa
+call set args=%%args:%1="%arg1%"%%
+rem call set args=%%args:%1=%%
+goto:eof
+:not#Rscript
+
+cd %here%
+
+:: Look in architecture specific subdirectory of bin. If not there look in bin.
+set cmdpath=%R_HOME%\bin\%R_ARCH0%\%cmd%
+if exist "%cmdpath%" goto:cmdpathfound
+set cmdpath=%R_HOME%\bin\%cmd%
+if exist "%cmdpath%" goto:cmdpathfound
+echo "Error: %cmd% not found" & goto:eof
+:cmdpathfound
+
+:: if called as jgr.bat locate the JGR package to find jgr.exe
+if /i not %cmd%==jgr.exe goto:notJGR
+  set st=start
+  set cmdpath=jgr.exe
+  if not defined JGR_LIBS set JGR_LIBS=%R_LIBS%
+  for %%a in ("%R_HOME%\bin\Rscript.exe") do set RSCRIPT=%%~sfa
+  if not defined JGR_LIBS for /f "usebackq delims=" %%a in (
+		`%RSCRIPT% -e "cat(.libPaths(),sep=';')"`
+  ) do set JGR_LIBS=%%~a
+  if not defined JGR_LIBS (
+	echo "Error: JGR package not found in R library" & goto:eof
+  )
+  for %%f in ("JGR") do set "jgrpkg=%%~$JGR_LIBS:f"
+  set JGR_LIB=%jgrpkg:~0,-4%
+  for %%a in ("%JGR_LIB%") do set JGR_LIB_SHORT=%%~sfa
+  for %%a in ("%R_HOME%") do set R_HOME_SHORT=%%~sfa
+  set args=--libpath=%JGR_LIB_SHORT% --rhome=%R_HOME_SHORT%
+
+:notJGR
+
+rem set R_ARCH
+rem set R_ARCH0
+rem set cmdpath
+rem if defined st set st
+rem set args
+
+set cygwin=nodosfilewarning
+if not defined args goto:noargs
+if defined st (start "" "%cmdpath%" %args%) else "%cmdpath%" %args%
+goto:eof
+:noargs
+if defined st (start "" "%cmdpath%") else "%cmdpath%"
+goto:eof
+
+:help#Rscript
+echo Usage: #Rscript %%0 %%*
+echo If the above is the first line in a file 
+echo containing only R code and the file is 
+echo given a .bat extension then it can be 
+echo run as a batch file.
+goto:eof
+
+
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: processing of --arch= where value can be 32, 64, i386, x64, /i386, /x64
+
+:: Call it like this: call :process_arch %*
+:: On return R_ARCH will be set from --arch or R_ARCH or default
+:: and R_ARCH0 will be R_ARCH without the / prefix
+:: It will look for the architecture in these places in this order:
+:: - first arg if its --arch
+:: - environment variable R_ARCH
+:: - check if R_HOME\bin\i386 exists
+:: - if R_HOME\bin\x64 exists
+:: - if none of the above then use R_ARCH=/i386
+:: Note that R_HOME should be defined before calling this routine
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+:process_arch
+	if defined R_ARCH goto:process_arch_cont
+	:: The loop searches for --arch and sets R_ARCH to the next argument
+    :process_arch_loop 
+    set arg=%~1
+    shift 
+    if not defined arg goto :process_arch_cont 
+	if "%arg%"=="--arch" set R_ARCH=%1
+	if defined R_ARCH goto:process_arch_cont
+	goto:process_arch_loop
+    :process_arch_cont
+	if defined process_arg_arch goto:process_arch_defined
+	if exist %R_HOME%\bin\i386 (set R_ARCH=/i386) & goto:process_arch_defined
+	if exist %R_HOME%\bin\x64 (set R_ARCH=/x64) & goto:process_arch_defined
+	(set R_ARCH=/i386)
+	:process_arch_defined
+	if "%R_ARCH%"=="32" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="386" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="i386" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="64" (set R_ARCH=/x64)
+	if "%R_ARCH%"=="x64" (set R_ARCH=/x64)
+	:: if R_ARCH does not begin with a slash add one as a prefix
+	(set first_char=%R_ARCH:~0,1%)
+	if not "%first_char%" == "/" (set R_ARCH=/%R_ARCH%)
+	:: R_ARCH0 is like R_ARCH but without the beginning /
+	(set R_ARCH0=%R_ARCH:~1%)
+	goto:eof
+
+endlocal

Added: grass/trunk/mswindows/external/rbatch/Rscript.bat
===================================================================
--- grass/trunk/mswindows/external/rbatch/Rscript.bat	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/Rscript.bat	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,239 @@
+
+ at echo off
+rem if /i "%1"==path (path %2) && goto:eof
+
+setlocal
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: Placing this file in your path will allow rcmd to be run anywhere
+:: without changing your path environment variable.  See comments
+:: below on how it finds where R is.  Your path can be listed by
+:: the Windows console command:  path
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+rem at one tine this script had only been tested on XP
+rem recent tests have only been on Vista
+rem ver | findstr XP >NUL
+rem if errorlevel 1 echo Warning: This script has only been tested on Windows XP.
+
+set scriptdir_=%~dp0
+set lookin=.;%userprofile%;%scriptdir_%
+if not defined R_BATCHFILES_RC (
+	for %%f in ("rbatchfilesrc.bat") do set "R_BATCHFILES_RC=%%~$lookin:f"
+)
+if defined R_BATCHFILES_RC (
+	if exist "%R_BATCHFILES_RC%" call %R_BATCHFILES_RC%
+)
+
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: use environment variable R_HOME if defined
+:: else current folder if bin\rcmd.exe exists 
+:: else most current R as determined by registry entry
+:: else error
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+if not defined R_HOME if exist bin\r.exe set R_HOME=%CD%
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\R-core\R /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\r-core\r /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+if not defined R_HOME echo "Error: R not found" & goto:eof
+
+call :process_arch %*
+
+:: add R_MIKTEX to PATH if defined.  Otherwise if its not 
+:: in the PATH already then check \Program Files\miktex* or \miktex* 
+:: and if found add that to PATH.
+
+:: if miktex found in PATH skip searching for it
+PATH | findstr /i miktex > nul
+if not errorlevel 1 goto:end_miktex
+
+:: check for presence of %ProgramFiles%\miktex* or \miktex*
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on "%ProgramFiles%"\miktex* 2^>NUL'
+) do set R_MIKTEX=%ProgramFiles%\%%a
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on %SystemDrive%:\miktex* 2^>NUL'
+) do set R_MIKTEX=%SystemDrive%:\miktex\%%a
+
+:end_miktex
+if defined R_MIKTEX PATH %R_MIKTEX%\miktex\bin;%PATH%
+
+if not defined MYSQL_HOME for /f "delims=" %%a in (
+    'dir /b /on "%ProgramFiles%"\MySQL\* 2^>NUL'
+) do set MYSQL_HOME=%ProgramFiles%\MySQL\%%a
+
+if not defined R_TOOLS for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\R-core\Rtools /v InstallPath 2^>NUL ^| findstr InstallPath'
+ ) do set R_TOOLS=%%~b
+if not defined R_TOOLS for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\Rtools /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_TOOLS=%%~b
+
+set PATHQ=%PATH%
+:WHILE
+    if "%PATHQ%"=="" goto WEND
+    for /F "delims=;" %%i in ("%PATHQ%") do if exist "%%~sfi" set PATH2=%PATH2%;%%~sfi
+    for /F "delims=; tokens=1,*" %%i in ("%PATHQ%") do set PATHQ=%%j
+    goto WHILE 
+:WEND
+
+set path2=%path2:~1%
+
+if defined R_TOOLS (
+    set path2=%R_TOOLS%\bin;%R_TOOLS%\perl\bin;%R_TOOLS%\MinGW\bin;%PATH2%
+)
+
+path %path2%
+
+set here=%CD%
+set args=%*
+
+:: get name by which this command was called
+:: this allows same file to be used for Rgui, Rterm, etc. by just renaming it
+for %%i in (%0) do set cmd=%%~ni.exe
+
+if /i %cmd%==rtools.exe (endlocal & set path=%path2%) && goto:eof
+
+cd %R_HOME%\bin
+if /i not %cmd%==rguistart.exe goto:notRguiStart
+  set cmd=rgui.exe
+  set firstArgument=%1
+  if defined firstArgument (
+    dir %1 | findstr "<DIR>" > nul
+    if errorlevel 1 goto:notRguiStart
+    set here=%~1
+    set firstArgument=
+  )
+  set args=
+  shift
+  :startloop
+  set firstArgument=%1
+  if defined firstArgument (
+     set args=%args% "%~1" 
+     shift
+     goto:startloop
+  )
+:notRguiStart
+
+set st=
+if /i %cmd%==rgui.exe set st=start
+
+if /i not %cmd%==#Rscript.exe goto:not#Rscript
+set cmd=Rscript.exe
+if [%1]==[] goto:help#Rscript
+call :rsarg1 %*
+goto:not#Rscript
+:rsarg1
+set args=%*
+set arg1=%~1
+set arg1=%arg1:.bat.bat=.bat%
+set last4=%arg1:~-4%
+if /i not "%last4%"==".bat" set arg1=%arg1%.bat
+for %%a in ("%R_HOME%\bin\Rscript.exe") do set RSCRIPT=%%~sfa
+call set args=%%args:%1="%arg1%"%%
+rem call set args=%%args:%1=%%
+goto:eof
+:not#Rscript
+
+cd %here%
+
+:: Look in architecture specific subdirectory of bin. If not there look in bin.
+set cmdpath=%R_HOME%\bin\%R_ARCH0%\%cmd%
+if exist "%cmdpath%" goto:cmdpathfound
+set cmdpath=%R_HOME%\bin\%cmd%
+if exist "%cmdpath%" goto:cmdpathfound
+echo "Error: %cmd% not found" & goto:eof
+:cmdpathfound
+
+:: if called as jgr.bat locate the JGR package to find jgr.exe
+if /i not %cmd%==jgr.exe goto:notJGR
+  set st=start
+  set cmdpath=jgr.exe
+  if not defined JGR_LIBS set JGR_LIBS=%R_LIBS%
+  for %%a in ("%R_HOME%\bin\Rscript.exe") do set RSCRIPT=%%~sfa
+  if not defined JGR_LIBS for /f "usebackq delims=" %%a in (
+		`%RSCRIPT% -e "cat(.libPaths(),sep=';')"`
+  ) do set JGR_LIBS=%%~a
+  if not defined JGR_LIBS (
+	echo "Error: JGR package not found in R library" & goto:eof
+  )
+  for %%f in ("JGR") do set "jgrpkg=%%~$JGR_LIBS:f"
+  set JGR_LIB=%jgrpkg:~0,-4%
+  for %%a in ("%JGR_LIB%") do set JGR_LIB_SHORT=%%~sfa
+  for %%a in ("%R_HOME%") do set R_HOME_SHORT=%%~sfa
+  set args=--libpath=%JGR_LIB_SHORT% --rhome=%R_HOME_SHORT%
+
+:notJGR
+
+rem set R_ARCH
+rem set R_ARCH0
+rem set cmdpath
+rem if defined st set st
+rem set args
+
+set cygwin=nodosfilewarning
+if not defined args goto:noargs
+if defined st (start "" "%cmdpath%" %args%) else "%cmdpath%" %args%
+goto:eof
+:noargs
+if defined st (start "" "%cmdpath%") else "%cmdpath%"
+goto:eof
+
+:help#Rscript
+echo Usage: #Rscript %%0 %%*
+echo If the above is the first line in a file 
+echo containing only R code and the file is 
+echo given a .bat extension then it can be 
+echo run as a batch file.
+goto:eof
+
+
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: processing of --arch= where value can be 32, 64, i386, x64, /i386, /x64
+
+:: Call it like this: call :process_arch %*
+:: On return R_ARCH will be set from --arch or R_ARCH or default
+:: and R_ARCH0 will be R_ARCH without the / prefix
+:: It will look for the architecture in these places in this order:
+:: - first arg if its --arch
+:: - environment variable R_ARCH
+:: - check if R_HOME\bin\i386 exists
+:: - if R_HOME\bin\x64 exists
+:: - if none of the above then use R_ARCH=/i386
+:: Note that R_HOME should be defined before calling this routine
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+:process_arch
+	if defined R_ARCH goto:process_arch_cont
+	:: The loop searches for --arch and sets R_ARCH to the next argument
+    :process_arch_loop 
+    set arg=%~1
+    shift 
+    if not defined arg goto :process_arch_cont 
+	if "%arg%"=="--arch" set R_ARCH=%1
+	if defined R_ARCH goto:process_arch_cont
+	goto:process_arch_loop
+    :process_arch_cont
+	if defined process_arg_arch goto:process_arch_defined
+	if exist %R_HOME%\bin\i386 (set R_ARCH=/i386) & goto:process_arch_defined
+	if exist %R_HOME%\bin\x64 (set R_ARCH=/x64) & goto:process_arch_defined
+	(set R_ARCH=/i386)
+	:process_arch_defined
+	if "%R_ARCH%"=="32" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="386" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="i386" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="64" (set R_ARCH=/x64)
+	if "%R_ARCH%"=="x64" (set R_ARCH=/x64)
+	:: if R_ARCH does not begin with a slash add one as a prefix
+	(set first_char=%R_ARCH:~0,1%)
+	if not "%first_char%" == "/" (set R_ARCH=/%R_ARCH%)
+	:: R_ARCH0 is like R_ARCH but without the beginning /
+	(set R_ARCH0=%R_ARCH:~1%)
+	goto:eof
+
+endlocal

Added: grass/trunk/mswindows/external/rbatch/Rtidy.bat
===================================================================
--- grass/trunk/mswindows/external/rbatch/Rtidy.bat	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/Rtidy.bat	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,8 @@
+#Rscript %0.bat %*
+# usage: Rtidy sourcefile.R > sourcefile.Rtidy.R
+# based on 3.1 of R Extensions Manual
+options(keep.source = FALSE)
+source(commandArgs(TRUE))
+dump(ls(all = TRUE), file = stdout())
+q("no")
+

Added: grass/trunk/mswindows/external/rbatch/Rtools.bat
===================================================================
--- grass/trunk/mswindows/external/rbatch/Rtools.bat	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/Rtools.bat	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,239 @@
+
+ at echo off
+rem if /i "%1"==path (path %2) && goto:eof
+
+setlocal
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: Placing this file in your path will allow rcmd to be run anywhere
+:: without changing your path environment variable.  See comments
+:: below on how it finds where R is.  Your path can be listed by
+:: the Windows console command:  path
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+rem at one tine this script had only been tested on XP
+rem recent tests have only been on Vista
+rem ver | findstr XP >NUL
+rem if errorlevel 1 echo Warning: This script has only been tested on Windows XP.
+
+set scriptdir_=%~dp0
+set lookin=.;%userprofile%;%scriptdir_%
+if not defined R_BATCHFILES_RC (
+	for %%f in ("rbatchfilesrc.bat") do set "R_BATCHFILES_RC=%%~$lookin:f"
+)
+if defined R_BATCHFILES_RC (
+	if exist "%R_BATCHFILES_RC%" call %R_BATCHFILES_RC%
+)
+
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: use environment variable R_HOME if defined
+:: else current folder if bin\rcmd.exe exists 
+:: else most current R as determined by registry entry
+:: else error
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+if not defined R_HOME if exist bin\r.exe set R_HOME=%CD%
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\R-core\R /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\r-core\r /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+if not defined R_HOME echo "Error: R not found" & goto:eof
+
+call :process_arch %*
+
+:: add R_MIKTEX to PATH if defined.  Otherwise if its not 
+:: in the PATH already then check \Program Files\miktex* or \miktex* 
+:: and if found add that to PATH.
+
+:: if miktex found in PATH skip searching for it
+PATH | findstr /i miktex > nul
+if not errorlevel 1 goto:end_miktex
+
+:: check for presence of %ProgramFiles%\miktex* or \miktex*
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on "%ProgramFiles%"\miktex* 2^>NUL'
+) do set R_MIKTEX=%ProgramFiles%\%%a
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on %SystemDrive%:\miktex* 2^>NUL'
+) do set R_MIKTEX=%SystemDrive%:\miktex\%%a
+
+:end_miktex
+if defined R_MIKTEX PATH %R_MIKTEX%\miktex\bin;%PATH%
+
+if not defined MYSQL_HOME for /f "delims=" %%a in (
+    'dir /b /on "%ProgramFiles%"\MySQL\* 2^>NUL'
+) do set MYSQL_HOME=%ProgramFiles%\MySQL\%%a
+
+if not defined R_TOOLS for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\R-core\Rtools /v InstallPath 2^>NUL ^| findstr InstallPath'
+ ) do set R_TOOLS=%%~b
+if not defined R_TOOLS for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\Rtools /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_TOOLS=%%~b
+
+set PATHQ=%PATH%
+:WHILE
+    if "%PATHQ%"=="" goto WEND
+    for /F "delims=;" %%i in ("%PATHQ%") do if exist "%%~sfi" set PATH2=%PATH2%;%%~sfi
+    for /F "delims=; tokens=1,*" %%i in ("%PATHQ%") do set PATHQ=%%j
+    goto WHILE 
+:WEND
+
+set path2=%path2:~1%
+
+if defined R_TOOLS (
+    set path2=%R_TOOLS%\bin;%R_TOOLS%\perl\bin;%R_TOOLS%\MinGW\bin;%PATH2%
+)
+
+path %path2%
+
+set here=%CD%
+set args=%*
+
+:: get name by which this command was called
+:: this allows same file to be used for Rgui, Rterm, etc. by just renaming it
+for %%i in (%0) do set cmd=%%~ni.exe
+
+if /i %cmd%==rtools.exe (endlocal & set path=%path2%) && goto:eof
+
+cd %R_HOME%\bin
+if /i not %cmd%==rguistart.exe goto:notRguiStart
+  set cmd=rgui.exe
+  set firstArgument=%1
+  if defined firstArgument (
+    dir %1 | findstr "<DIR>" > nul
+    if errorlevel 1 goto:notRguiStart
+    set here=%~1
+    set firstArgument=
+  )
+  set args=
+  shift
+  :startloop
+  set firstArgument=%1
+  if defined firstArgument (
+     set args=%args% "%~1" 
+     shift
+     goto:startloop
+  )
+:notRguiStart
+
+set st=
+if /i %cmd%==rgui.exe set st=start
+
+if /i not %cmd%==#Rscript.exe goto:not#Rscript
+set cmd=Rscript.exe
+if [%1]==[] goto:help#Rscript
+call :rsarg1 %*
+goto:not#Rscript
+:rsarg1
+set args=%*
+set arg1=%~1
+set arg1=%arg1:.bat.bat=.bat%
+set last4=%arg1:~-4%
+if /i not "%last4%"==".bat" set arg1=%arg1%.bat
+for %%a in ("%R_HOME%\bin\Rscript.exe") do set RSCRIPT=%%~sfa
+call set args=%%args:%1="%arg1%"%%
+rem call set args=%%args:%1=%%
+goto:eof
+:not#Rscript
+
+cd %here%
+
+:: Look in architecture specific subdirectory of bin. If not there look in bin.
+set cmdpath=%R_HOME%\bin\%R_ARCH0%\%cmd%
+if exist "%cmdpath%" goto:cmdpathfound
+set cmdpath=%R_HOME%\bin\%cmd%
+if exist "%cmdpath%" goto:cmdpathfound
+echo "Error: %cmd% not found" & goto:eof
+:cmdpathfound
+
+:: if called as jgr.bat locate the JGR package to find jgr.exe
+if /i not %cmd%==jgr.exe goto:notJGR
+  set st=start
+  set cmdpath=jgr.exe
+  if not defined JGR_LIBS set JGR_LIBS=%R_LIBS%
+  for %%a in ("%R_HOME%\bin\Rscript.exe") do set RSCRIPT=%%~sfa
+  if not defined JGR_LIBS for /f "usebackq delims=" %%a in (
+		`%RSCRIPT% -e "cat(.libPaths(),sep=';')"`
+  ) do set JGR_LIBS=%%~a
+  if not defined JGR_LIBS (
+	echo "Error: JGR package not found in R library" & goto:eof
+  )
+  for %%f in ("JGR") do set "jgrpkg=%%~$JGR_LIBS:f"
+  set JGR_LIB=%jgrpkg:~0,-4%
+  for %%a in ("%JGR_LIB%") do set JGR_LIB_SHORT=%%~sfa
+  for %%a in ("%R_HOME%") do set R_HOME_SHORT=%%~sfa
+  set args=--libpath=%JGR_LIB_SHORT% --rhome=%R_HOME_SHORT%
+
+:notJGR
+
+rem set R_ARCH
+rem set R_ARCH0
+rem set cmdpath
+rem if defined st set st
+rem set args
+
+set cygwin=nodosfilewarning
+if not defined args goto:noargs
+if defined st (start "" "%cmdpath%" %args%) else "%cmdpath%" %args%
+goto:eof
+:noargs
+if defined st (start "" "%cmdpath%") else "%cmdpath%"
+goto:eof
+
+:help#Rscript
+echo Usage: #Rscript %%0 %%*
+echo If the above is the first line in a file 
+echo containing only R code and the file is 
+echo given a .bat extension then it can be 
+echo run as a batch file.
+goto:eof
+
+
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: processing of --arch= where value can be 32, 64, i386, x64, /i386, /x64
+
+:: Call it like this: call :process_arch %*
+:: On return R_ARCH will be set from --arch or R_ARCH or default
+:: and R_ARCH0 will be R_ARCH without the / prefix
+:: It will look for the architecture in these places in this order:
+:: - first arg if its --arch
+:: - environment variable R_ARCH
+:: - check if R_HOME\bin\i386 exists
+:: - if R_HOME\bin\x64 exists
+:: - if none of the above then use R_ARCH=/i386
+:: Note that R_HOME should be defined before calling this routine
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+:process_arch
+	if defined R_ARCH goto:process_arch_cont
+	:: The loop searches for --arch and sets R_ARCH to the next argument
+    :process_arch_loop 
+    set arg=%~1
+    shift 
+    if not defined arg goto :process_arch_cont 
+	if "%arg%"=="--arch" set R_ARCH=%1
+	if defined R_ARCH goto:process_arch_cont
+	goto:process_arch_loop
+    :process_arch_cont
+	if defined process_arg_arch goto:process_arch_defined
+	if exist %R_HOME%\bin\i386 (set R_ARCH=/i386) & goto:process_arch_defined
+	if exist %R_HOME%\bin\x64 (set R_ARCH=/x64) & goto:process_arch_defined
+	(set R_ARCH=/i386)
+	:process_arch_defined
+	if "%R_ARCH%"=="32" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="386" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="i386" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="64" (set R_ARCH=/x64)
+	if "%R_ARCH%"=="x64" (set R_ARCH=/x64)
+	:: if R_ARCH does not begin with a slash add one as a prefix
+	(set first_char=%R_ARCH:~0,1%)
+	if not "%first_char%" == "/" (set R_ARCH=/%R_ARCH%)
+	:: R_ARCH0 is like R_ARCH but without the beginning /
+	(set R_ARCH0=%R_ARCH:~1%)
+	goto:eof
+
+endlocal

Added: grass/trunk/mswindows/external/rbatch/RtoolsVersion.bat
===================================================================
--- grass/trunk/mswindows/external/rbatch/RtoolsVersion.bat	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/RtoolsVersion.bat	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,30 @@
+ at echo off
+
+setlocal
+rem if /i "%1"==path (path %2) && goto:eof
+
+if not defined R_TOOLS for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\R-core\Rtools /v InstallPath 2^>NUL ^| findstr InstallPath'
+ ) do set R_TOOLS=%%~b
+if not defined R_TOOLS for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\Rtools /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_TOOLS=%%~b
+if not defined R_TOOLS (
+	echo "Warning: Rtools not found in registry."
+	if exist "C:\Rtools" set R_TOOLS=C:\Rtools
+)
+if not defined R_TOOLS (
+	echo "Warning: Rtools not found in common locations."
+	goto:eof
+)
+
+echo Rtools at: %R_TOOLS%
+if not exist "%R_TOOLS%\VERSION.txt" (
+	echo Rtools version: 2.12 or 2.13 or earlier.
+	goto:eof
+)
+
+type %R_TOOLS%\VERSION.txt
+
+endlocal
+

Added: grass/trunk/mswindows/external/rbatch/Rversions.bat
===================================================================
--- grass/trunk/mswindows/external/rbatch/Rversions.bat	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/Rversions.bat	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,103 @@
+
+ at echo off
+
+:: Without args this lists the R_HOME directory for each version of R
+:: on the system.  If one of those directories is given as an argument
+:: then that version is set to the current version
+:: Note: Use Rfind.bat and look on R_HOME line to find current version of R.
+
+setlocal
+rem ver | findstr XP >NUL
+rem if errorlevel 1 echo Warning: This script has only been tested on Windows XP.
+
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: use environment variable R_HOME if defined
+:: else current folder if bin\rcmd.exe exists 
+:: else most current R as determined by registry entry
+:: else error
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+if not defined R_HOME if exist bin\rcmd.exe set R_HOME=%CD%
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\r-core\r /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\r-core\r /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+if not defined R_HOME echo "Error: R not found" & goto:eof
+
+:: look for architecture in these places in this order:
+:: - environment variable R_ARCH
+:: - first arg if its --arch
+:: - check if R_HOME\bin\i386 exists
+:: - if R_HOME\bin\x64 exists
+:: - if none of the above then use i386
+
+call :process_arch %*
+rem set R
+
+cd %R_HOME%
+cd ..
+
+if "%1"=="" (
+	for /d %%a in (*) do if exist %%a\bin\R.exe echo %%a
+	goto:eof
+)
+
+:: Look in architecture specific subdirectory of bin. If not there look in bin.
+set cmdpath=%1\bin\%R_ARCH0%\RSetReg.exe
+rem set cmdpath
+if exist "%cmdpath%" goto:cmdpathfound
+set cmdpath=%1\bin\RSetReg.exe
+rem set cmdpath
+if exist "%cmdpath%" goto:cmdpathfound
+echo "Error: RSetReg.exe not found" & goto:eof
+goto:eof
+:cmdpathfound
+"%cmdpath%"
+
+goto:eof
+
+
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: processing of --arch= where value can be 32, 64, i386, x64, /i386, /x64
+
+:: Call it like this: call :process_arch %*
+:: On return R_ARCH will be set from --arch or R_ARCH or default
+:: and R_ARCH0 will be R_ARCH without the / prefix
+:: It will look for the architecture in these places in this order:
+:: - first arg if its --arch
+:: - environment variable R_ARCH
+:: - check if R_HOME\bin\i386 exists
+:: - if R_HOME\bin\x64 exists
+:: - if none of the above then use R_ARCH=/i386
+:: Note that R_HOME should be defined before calling this routine
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+:process_arch
+	if defined R_ARCH goto:process_arch_cont
+	:: The loop searches for --arch and sets R_ARCH to the next argument
+    :process_arch_loop 
+    (set arg=%~1) 
+    shift 
+    if not defined arg goto :process_arch_cont 
+	if "%arg%"=="--arch" (set R_ARCH=%1) & goto:process_arch_cont
+	goto:process_arch_loop
+    :process_arch_cont
+	if defined process_arg_arch goto:process_arch_defined
+	if exist %R_HOME%\bin\i386 (set R_ARCH=/i386) & goto:process_arch_defined
+	if exist %R_HOME%\bin\x64 (set R_ARCH=/x64) & goto:process_arch_defined
+	(set R_ARCH=/i386)
+	:process_arch_defined
+	if "%R_ARCH%"=="32" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="386" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="i386" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="64" (set R_ARCH=/x64)
+	if "%R_ARCH%"=="x64" (set R_ARCH=/x64)
+	:: if R_ARCH does not begin with a slash add one as a prefix
+	(set first_char=%R_ARCH:~0,1%)
+	if not "%first_char%" == "/" (set R_ARCH=/%R_ARCH%)
+	:: R_ARCH0 is like R_ARCH but without the beginning /
+	(set R_ARCH0=%R_ARCH:~1%)
+	goto:eof
+
+endlocal

Added: grass/trunk/mswindows/external/rbatch/Stangle.bat
===================================================================
--- grass/trunk/mswindows/external/rbatch/Stangle.bat	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/Stangle.bat	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,377 @@
+ at echo off
+setlocal
+rem rem ver | findstr XP >NUL
+
+for %%i in (%0) do set cmd0=%%~ni
+set cmd=Sweave
+if /i "%cmd0%"=="Stangle" set cmd=Stangle
+
+if not defined SWEAVE_STYLEPATH_DEFAULT set SWEAVE_STYLEPATH_DEFAULT=TRUE
+
+set scriptdir_=%~dp0
+set lookin=.;%userprofile%;%scriptdir_%
+
+if not defined R_BATCHFILES_RC (
+	for %%f in ("rbatchfilesrc.bat") do set "R_BATCHFILES_RC=%%~$lookin:f"
+)
+if defined R_BATCHFILES_RC (
+	set R_BATCHFILES_RC
+	if exist "%R_BATCHFILES_RC%" call %R_BATCHFILES_RC%
+)
+
+if "%1"=="" goto:help
+if "%1"=="-h" goto:help
+if "%1"=="--help" goto:help
+if "%1"=="/?" goto:help
+
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: use environment variable R_HOME if defined
+:: else check for .\bin\R.exe
+:: else check registry
+:: else check for existence of bin\R.exe in:
+::   %ProgramFiles%\R\R\R-*
+:: where more recently dated R-* directories would be matched over older ones
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+if not defined R_HOME if exist bin\R.exe set R_HOME=%CD%
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\r-core\r /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\r-core\r /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+
+if not defined R_HOME echo "Error: R not found" & goto:eof
+
+	if not defined R_HOME echo "Error: R not found" & goto:eof
+
+if not "%1"==":Rterm" goto:notRterm
+
+	set here=%CD%
+	set args=%2 %3 %4 %5 %6 %7 %8 %9
+
+	set cmd=:Rterm
+
+	goto:Rterm
+)
+:notRterm
+goto:continue
+:help
+echo Usage: %0 abc.Rnw
+echo    or  %0 abc
+if /i "%cmd%"=="stangle" goto:eof
+echo switches:
+echo    -t or --tex or     produce tex file and exit
+echo    -p or --pdf or     produce pdf file and exit
+echo    -n or --nobck.pdf  do not create .bck.pdf; instead display pdf directly
+echo Runs sweave producing a .tex file.  Then it runs pdflatex producing
+echo  a .pdf file and a .bck.pdf file.  Finally the .bck.pdf file is 
+echo  displayed on screen.
+echo.
+echo Examples:
+echo.
+echo 1. Run sweave, pdflatex, create backup pdf with unique name, display it
+echo       sweave mydoc.Rnw
+echo 2. Same
+echo       sweave mydoc
+echo 3. Run sweave to create tex file.  Do not run pdflatex or display.
+echo       sweave mydoc --tex
+echo 4. Run sweave and pdflatex creating pdf file.  Do not create .bck.pdf
+echo    file and do not display file.
+echo       sweave mydoc --pdf
+echo 5. Run sweave and pdflatex. Do not create .bck.pdf. Display .pdf file.
+echo       sweave mydoc --nobck
+goto:eof
+:continue
+
+call :process_arch %*
+
+:: argument processing
+:: - returns 'file' as file argument
+
+    :loop 
+    (set arg=%~1) 
+    shift 
+    if not defined arg goto :cont 
+    (set prefix1=%arg:~0,1%) 
+    if "%prefix1%"=="-" goto:switch
+    set file=%arg%
+    goto:loop
+	:switch
+	set switch0=%arg:-=%
+	set switch0=%switch0:~0,1%
+	rem architecture switch was previously handled so skip over it here
+	if "%switch0%"=="a" goto:loop
+	set switch=%switch0%
+    goto:loop
+    :cont
+
+if errorlevel 1 echo Warning: This script has only been tested on Windows XP.
+if exist "%file%.Rtex" set infile="%file%.Rtex"
+if exist "%file%.Snw" set infile="%file%.Snw"
+if exist "%file%.Rnw" set infile="%file%.Rnw"
+if exist "%file%" set infile="%file%" 
+set infilslsh=%infile:\=/%
+:: call sweave
+echo library('utils'); %cmd%(%infilslsh%) | %cmd0%.bat :Rterm --no-restore --slave
+if /i "%cmd%"=="stangle" goto:eof
+:: echo on
+if errorlevel 1 goto:eof
+if /i "%switch%"=="t" goto:eof
+
+:: echo %cd%
+for %%a in ("%file%") do set base=%%~sdpna
+if not exist "%base%.tex" goto:eof
+for /f "delims=" %%a in ('dir %infile% "%base%.tex" /od/b ^| more +1'
+) do set ext=%%~xa
+
+:: add R_MIKTEX to PATH if defined.  Otherwise if its not 
+:: in the PATH already then check \Program Files\miktex* or \miktex* 
+:: and if found add that to PATH.
+
+:: if miktex found in PATH skip searching for it
+PATH | findstr /i miktex > nul
+if not errorlevel 1 goto:end_miktex
+
+:: check for presence of %ProgramFiles%\miktex* or \miktex*
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on "%ProgramFiles%"\miktex* 2^>NUL'
+) do set R_MIKTEX=%ProgramFiles%\%%a
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on %SystemDrive%:\miktex* 2^>NUL'
+) do set R_MIKTEX=%SystemDrive%:\miktex\%%a
+
+:end_miktex
+if defined R_MIKTEX PATH %R_MIKTEX%\miktex\bin;%PATH%
+
+if "%ext%"==".tex" (pdflatex "%base%.tex") else goto:eof
+if errorlevel 1 goto:eof
+if /i "%switch%"=="p" goto:eof
+
+if not exist "%base%.pdf" goto:eof
+for /f "delims=" %%a in ('dir "%base%.pdf" "%base%.tex" /od/b ^| more +1'
+) do set ext=%%~xa
+if not "%ext%"==".pdf" goto:eof
+set pdffile=%base%.pdf
+if /i "%switch%"=="n" start "" "%pdffile%" && goto:eof
+set tmpfile=%date%-%time%
+set tmpfile=%tmpfile: =-%
+set tmpfile=%tmpfile::=.%
+set tmpfile=%tmpfile:/=.%
+set tmpfile=%base%-%tmpfile%.bck.pdf
+copy "%pdffile%" "%tmpfile%"
+start "" "%tmpfile%"
+echo *** delete *.bck.pdf files when done ***
+goto:eof
+
+
+
+ at echo off
+setlocal
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: Placing this file in your path will allow rcmd to be run anywhere
+:: without changing your path environment variable.  See comments
+:: below on how it finds where R is.  Your path can be listed by
+:: the Windows console command:  path
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: use environment variable R_HOME if defined
+:: else check for .\bin\R.exe
+:: else check registry
+:: else check for existence of bin\R.exe in each of the following:
+::   %ProgramFiles%\R\R\R-*
+:: where more recently created R-* directories would be matched over
+:: older ones.
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+if not defined R_HOME if exist bin\R.exe set R_HOME=%CD%
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\r-core\r /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\r-core\r /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+
+if not defined R_HOME for /f "delims=" %%a in (
+	'dir/b/od "%ProgramFiles%"\R\R-* 2^>NUL'
+) do if exist "%ProgramFiles%\R\%%a\bin\R.exe" (set R_HOME=%ProgramFiles%\R\%%a)
+
+if not defined R_HOME echo "Error: R not found" & goto:eof
+
+
+:: add R_MIKTEX to PATH if defined.  Otherwise if its not 
+:: in the PATH already then check \Program Files\miktex* or \miktex* 
+:: and if found add that to PATH.
+
+:: if miktex found in PATH skip searching for it
+PATH | findstr /i miktex > nul
+if not errorlevel 1 goto:end_miktex
+
+:: check for presence of %ProgramFiles%\miktex* or \miktex*
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on "%ProgramFiles%"\miktex* 2^>NUL'
+) do set R_MIKTEX=%ProgramFiles%\%%a
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on %SystemDrive%:\miktex* 2^>NUL'
+) do set R_MIKTEX=%SystemDrive%:\miktex\%%a
+
+:end_miktex
+if defined R_MIKTEX PATH %R_MIKTEX%\miktex\bin;%PATH%
+
+if not defined R_TOOLS for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\R-core\Rtools /v InstallPath 2^>NUL ^|
+findstr InstallPath'
+ ) do set R_TOOLS=%%~b
+if not defined R_TOOLS for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\Rtools /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_TOOLS=%%~b
+
+
+set PATHQ=%PATH%
+:WHILE
+    if "%PATHQ%"=="" goto WEND
+    for /F "delims=;" %%i in ("%PATHQ%") do if exist "%%~sfi" set PATH2=%PATH2%;%%~sfi
+    for /F "delims=; tokens=1,*" %%i in ("%PATHQ%") do set PATHQ=%%j
+    goto WHILE 
+:WEND
+
+set path2=%path2:~1%
+
+if defined R_TOOLS (
+    PATH %R_TOOLS%\bin;%R_TOOLS%\perl\bin;%R_TOOLS%\MinGW\bin;%PATH2%
+)
+
+set here=%CD%
+set args=%*
+
+:: get name by which this command was called
+:: this allows same file to be used for Rgui, Rterm, etc. by just renaming it
+for %%i in (%0) do set cmd=%%~ni 
+
+goto %cmd%
+goto:eof
+
+:: note that RguiStart sets cmd to rgui.exe and then 
+:: jumps to :Rgui.exe where processing is finished
+:RguiStart
+:RguiStart.exe
+cd %R_HOME%\bin
+if /i not %cmd%==rguistart.exe goto:Rgui
+  set cmd=rgui.exe
+  set firstArgument=%1
+  if defined firstArgument (
+    dir %1 | findstr "<DIR>" > nul
+    if errorlevel 1 goto:notRguiStart
+    set here=%~1
+    set firstArgument=
+  )
+  set args=
+  shift
+  :startloop
+  set firstArgument=%1
+  if defined firstArgument (
+     set args=%args% "%~1" 
+     shift
+     goto:startloop
+  )
+
+:Rcmd2
+:Rcmd2.exe
+:Rcmd
+:Rcmd.exe
+(set cmd=rcmd.exe)&goto:main
+
+:Rterm
+:Rterm.exe
+(set cmd=rterm.exe)&goto:main
+
+:Rgui
+:Rgui.exe
+(set cmd=rgui.exe)&goto:main
+
+:R
+:R.exe
+(set cmd=r)&goto:main
+
+:Rjgr
+:Rjgr.exe
+(set cmd=rjgr)&goto:main
+
+:#Rscript
+:#Rscript.exe
+:Rscript
+:Rscript.exe
+(set cmd=rscript.exe)&goto:main
+
+# main portion of program
+:main
+set st=
+if /i %cmd%==rgui.exe set st=start
+:: if /i %cmd%==#rscript.exe set cmd=rscript.exe
+cd %here%
+
+:: Look in architecture specific subdirectory of bin. If not there look in bin.
+set cmdpath=%R_HOME%\bin\%R_ARCH%\%cmd%
+if exist "%cmdpath%" goto:cmdpathfound
+set cmdpath=%R_HOME%\bin\%cmd%
+if exist "%cmdpath%" goto:cmdpathfound
+echo "Error: %cmd% not found" & goto:eof
+:cmdpathfound
+rem set cmdpath
+
+if defined st (start "" "%cmdpath%" %args%) else "%cmdpath%" %args%
+goto:eof
+
+endlocal
+
+
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: processing of --arch= where value can be 32, 64, i386, x64, /i386, /x64
+
+:: Call it like this: call :process_arch %*
+:: On return R_ARCH will be set from --arch or R_ARCH or default
+:: and R_ARCH0 will be R_ARCH without the / prefix
+:: It will look for the architecture in these places in this order:
+:: - first arg if its --arch
+:: - environment variable R_ARCH
+:: - check if R_HOME\bin\i386 exists
+:: - if R_HOME\bin\x64 exists
+:: - if none of the above then use R_ARCH=/i386
+:: Note that R_HOME should be defined before calling this routine
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+:process_arch
+	rem set R_HOME
+	if defined R_ARCH goto:process_arch_cont
+	:: The loop searches for --arch and sets R_ARCH to the next argument
+    :process_arch_loop 
+    (set arg=%~1) 
+    shift 
+    if not defined arg goto :process_arch_cont 
+	if "%arg%"=="--arch" (set R_ARCH=%1) & goto:process_arch_cont
+	goto:process_arch_loop
+    :process_arch_cont
+	if defined R_ARCH goto:process_arch_defined
+	if exist %R_HOME%\bin\i386 (set R_ARCH=/i386) & goto:process_arch_defined
+	if exist %R_HOME%\bin\x64 (set R_ARCH=/x64) & goto:process_arch_defined
+	(set R_ARCH=/i386)
+	:process_arch_defined
+	if "%R_ARCH%"=="32" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="386" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="i386" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="64" (set R_ARCH=/x64)
+	if "%R_ARCH%"=="x64" (set R_ARCH=/x64)
+	:: if R_ARCH does not begin with a slash add one as a prefix
+	(set first_char=%R_ARCH:~0,1%)
+	if not "%first_char%" == "/" (set R_ARCH=/%R_ARCH%)
+	:: R_ARCH0 is like R_ARCH but without the beginning /
+	(set R_ARCH0=%R_ARCH:~1%)
+	goto:eof
+
+endlocal
+
+
+

Added: grass/trunk/mswindows/external/rbatch/Sweave.bat
===================================================================
--- grass/trunk/mswindows/external/rbatch/Sweave.bat	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/Sweave.bat	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,377 @@
+ at echo off
+setlocal
+rem rem ver | findstr XP >NUL
+
+for %%i in (%0) do set cmd0=%%~ni
+set cmd=Sweave
+if /i "%cmd0%"=="Stangle" set cmd=Stangle
+
+if not defined SWEAVE_STYLEPATH_DEFAULT set SWEAVE_STYLEPATH_DEFAULT=TRUE
+
+set scriptdir_=%~dp0
+set lookin=.;%userprofile%;%scriptdir_%
+
+if not defined R_BATCHFILES_RC (
+	for %%f in ("rbatchfilesrc.bat") do set "R_BATCHFILES_RC=%%~$lookin:f"
+)
+if defined R_BATCHFILES_RC (
+	set R_BATCHFILES_RC
+	if exist "%R_BATCHFILES_RC%" call %R_BATCHFILES_RC%
+)
+
+if "%1"=="" goto:help
+if "%1"=="-h" goto:help
+if "%1"=="--help" goto:help
+if "%1"=="/?" goto:help
+
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: use environment variable R_HOME if defined
+:: else check for .\bin\R.exe
+:: else check registry
+:: else check for existence of bin\R.exe in:
+::   %ProgramFiles%\R\R\R-*
+:: where more recently dated R-* directories would be matched over older ones
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+if not defined R_HOME if exist bin\R.exe set R_HOME=%CD%
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\r-core\r /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\r-core\r /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+
+if not defined R_HOME echo "Error: R not found" & goto:eof
+
+	if not defined R_HOME echo "Error: R not found" & goto:eof
+
+if not "%1"==":Rterm" goto:notRterm
+
+	set here=%CD%
+	set args=%2 %3 %4 %5 %6 %7 %8 %9
+
+	set cmd=:Rterm
+
+	goto:Rterm
+)
+:notRterm
+goto:continue
+:help
+echo Usage: %0 abc.Rnw
+echo    or  %0 abc
+if /i "%cmd%"=="stangle" goto:eof
+echo switches:
+echo    -t or --tex or     produce tex file and exit
+echo    -p or --pdf or     produce pdf file and exit
+echo    -n or --nobck.pdf  do not create .bck.pdf; instead display pdf directly
+echo Runs sweave producing a .tex file.  Then it runs pdflatex producing
+echo  a .pdf file and a .bck.pdf file.  Finally the .bck.pdf file is 
+echo  displayed on screen.
+echo.
+echo Examples:
+echo.
+echo 1. Run sweave, pdflatex, create backup pdf with unique name, display it
+echo       sweave mydoc.Rnw
+echo 2. Same
+echo       sweave mydoc
+echo 3. Run sweave to create tex file.  Do not run pdflatex or display.
+echo       sweave mydoc --tex
+echo 4. Run sweave and pdflatex creating pdf file.  Do not create .bck.pdf
+echo    file and do not display file.
+echo       sweave mydoc --pdf
+echo 5. Run sweave and pdflatex. Do not create .bck.pdf. Display .pdf file.
+echo       sweave mydoc --nobck
+goto:eof
+:continue
+
+call :process_arch %*
+
+:: argument processing
+:: - returns 'file' as file argument
+
+    :loop 
+    (set arg=%~1) 
+    shift 
+    if not defined arg goto :cont 
+    (set prefix1=%arg:~0,1%) 
+    if "%prefix1%"=="-" goto:switch
+    set file=%arg%
+    goto:loop
+	:switch
+	set switch0=%arg:-=%
+	set switch0=%switch0:~0,1%
+	rem architecture switch was previously handled so skip over it here
+	if "%switch0%"=="a" goto:loop
+	set switch=%switch0%
+    goto:loop
+    :cont
+
+if errorlevel 1 echo Warning: This script has only been tested on Windows XP.
+if exist "%file%.Rtex" set infile="%file%.Rtex"
+if exist "%file%.Snw" set infile="%file%.Snw"
+if exist "%file%.Rnw" set infile="%file%.Rnw"
+if exist "%file%" set infile="%file%" 
+set infilslsh=%infile:\=/%
+:: call sweave
+echo library('utils'); %cmd%(%infilslsh%) | %cmd0%.bat :Rterm --no-restore --slave
+if /i "%cmd%"=="stangle" goto:eof
+:: echo on
+if errorlevel 1 goto:eof
+if /i "%switch%"=="t" goto:eof
+
+:: echo %cd%
+for %%a in ("%file%") do set base=%%~sdpna
+if not exist "%base%.tex" goto:eof
+for /f "delims=" %%a in ('dir %infile% "%base%.tex" /od/b ^| more +1'
+) do set ext=%%~xa
+
+:: add R_MIKTEX to PATH if defined.  Otherwise if its not 
+:: in the PATH already then check \Program Files\miktex* or \miktex* 
+:: and if found add that to PATH.
+
+:: if miktex found in PATH skip searching for it
+PATH | findstr /i miktex > nul
+if not errorlevel 1 goto:end_miktex
+
+:: check for presence of %ProgramFiles%\miktex* or \miktex*
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on "%ProgramFiles%"\miktex* 2^>NUL'
+) do set R_MIKTEX=%ProgramFiles%\%%a
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on %SystemDrive%:\miktex* 2^>NUL'
+) do set R_MIKTEX=%SystemDrive%:\miktex\%%a
+
+:end_miktex
+if defined R_MIKTEX PATH %R_MIKTEX%\miktex\bin;%PATH%
+
+if "%ext%"==".tex" (pdflatex "%base%.tex") else goto:eof
+if errorlevel 1 goto:eof
+if /i "%switch%"=="p" goto:eof
+
+if not exist "%base%.pdf" goto:eof
+for /f "delims=" %%a in ('dir "%base%.pdf" "%base%.tex" /od/b ^| more +1'
+) do set ext=%%~xa
+if not "%ext%"==".pdf" goto:eof
+set pdffile=%base%.pdf
+if /i "%switch%"=="n" start "" "%pdffile%" && goto:eof
+set tmpfile=%date%-%time%
+set tmpfile=%tmpfile: =-%
+set tmpfile=%tmpfile::=.%
+set tmpfile=%tmpfile:/=.%
+set tmpfile=%base%-%tmpfile%.bck.pdf
+copy "%pdffile%" "%tmpfile%"
+start "" "%tmpfile%"
+echo *** delete *.bck.pdf files when done ***
+goto:eof
+
+
+
+ at echo off
+setlocal
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: Placing this file in your path will allow rcmd to be run anywhere
+:: without changing your path environment variable.  See comments
+:: below on how it finds where R is.  Your path can be listed by
+:: the Windows console command:  path
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: use environment variable R_HOME if defined
+:: else check for .\bin\R.exe
+:: else check registry
+:: else check for existence of bin\R.exe in each of the following:
+::   %ProgramFiles%\R\R\R-*
+:: where more recently created R-* directories would be matched over
+:: older ones.
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+if not defined R_HOME if exist bin\R.exe set R_HOME=%CD%
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\r-core\r /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\r-core\r /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+
+if not defined R_HOME for /f "delims=" %%a in (
+	'dir/b/od "%ProgramFiles%"\R\R-* 2^>NUL'
+) do if exist "%ProgramFiles%\R\%%a\bin\R.exe" (set R_HOME=%ProgramFiles%\R\%%a)
+
+if not defined R_HOME echo "Error: R not found" & goto:eof
+
+
+:: add R_MIKTEX to PATH if defined.  Otherwise if its not 
+:: in the PATH already then check \Program Files\miktex* or \miktex* 
+:: and if found add that to PATH.
+
+:: if miktex found in PATH skip searching for it
+PATH | findstr /i miktex > nul
+if not errorlevel 1 goto:end_miktex
+
+:: check for presence of %ProgramFiles%\miktex* or \miktex*
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on "%ProgramFiles%"\miktex* 2^>NUL'
+) do set R_MIKTEX=%ProgramFiles%\%%a
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on %SystemDrive%:\miktex* 2^>NUL'
+) do set R_MIKTEX=%SystemDrive%:\miktex\%%a
+
+:end_miktex
+if defined R_MIKTEX PATH %R_MIKTEX%\miktex\bin;%PATH%
+
+if not defined R_TOOLS for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\R-core\Rtools /v InstallPath 2^>NUL ^|
+findstr InstallPath'
+ ) do set R_TOOLS=%%~b
+if not defined R_TOOLS for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\Rtools /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_TOOLS=%%~b
+
+
+set PATHQ=%PATH%
+:WHILE
+    if "%PATHQ%"=="" goto WEND
+    for /F "delims=;" %%i in ("%PATHQ%") do if exist "%%~sfi" set PATH2=%PATH2%;%%~sfi
+    for /F "delims=; tokens=1,*" %%i in ("%PATHQ%") do set PATHQ=%%j
+    goto WHILE 
+:WEND
+
+set path2=%path2:~1%
+
+if defined R_TOOLS (
+    PATH %R_TOOLS%\bin;%R_TOOLS%\perl\bin;%R_TOOLS%\MinGW\bin;%PATH2%
+)
+
+set here=%CD%
+set args=%*
+
+:: get name by which this command was called
+:: this allows same file to be used for Rgui, Rterm, etc. by just renaming it
+for %%i in (%0) do set cmd=%%~ni 
+
+goto %cmd%
+goto:eof
+
+:: note that RguiStart sets cmd to rgui.exe and then 
+:: jumps to :Rgui.exe where processing is finished
+:RguiStart
+:RguiStart.exe
+cd %R_HOME%\bin
+if /i not %cmd%==rguistart.exe goto:Rgui
+  set cmd=rgui.exe
+  set firstArgument=%1
+  if defined firstArgument (
+    dir %1 | findstr "<DIR>" > nul
+    if errorlevel 1 goto:notRguiStart
+    set here=%~1
+    set firstArgument=
+  )
+  set args=
+  shift
+  :startloop
+  set firstArgument=%1
+  if defined firstArgument (
+     set args=%args% "%~1" 
+     shift
+     goto:startloop
+  )
+
+:Rcmd2
+:Rcmd2.exe
+:Rcmd
+:Rcmd.exe
+(set cmd=rcmd.exe)&goto:main
+
+:Rterm
+:Rterm.exe
+(set cmd=rterm.exe)&goto:main
+
+:Rgui
+:Rgui.exe
+(set cmd=rgui.exe)&goto:main
+
+:R
+:R.exe
+(set cmd=r)&goto:main
+
+:Rjgr
+:Rjgr.exe
+(set cmd=rjgr)&goto:main
+
+:#Rscript
+:#Rscript.exe
+:Rscript
+:Rscript.exe
+(set cmd=rscript.exe)&goto:main
+
+# main portion of program
+:main
+set st=
+if /i %cmd%==rgui.exe set st=start
+:: if /i %cmd%==#rscript.exe set cmd=rscript.exe
+cd %here%
+
+:: Look in architecture specific subdirectory of bin. If not there look in bin.
+set cmdpath=%R_HOME%\bin\%R_ARCH%\%cmd%
+if exist "%cmdpath%" goto:cmdpathfound
+set cmdpath=%R_HOME%\bin\%cmd%
+if exist "%cmdpath%" goto:cmdpathfound
+echo "Error: %cmd% not found" & goto:eof
+:cmdpathfound
+rem set cmdpath
+
+if defined st (start "" "%cmdpath%" %args%) else "%cmdpath%" %args%
+goto:eof
+
+endlocal
+
+
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: processing of --arch= where value can be 32, 64, i386, x64, /i386, /x64
+
+:: Call it like this: call :process_arch %*
+:: On return R_ARCH will be set from --arch or R_ARCH or default
+:: and R_ARCH0 will be R_ARCH without the / prefix
+:: It will look for the architecture in these places in this order:
+:: - first arg if its --arch
+:: - environment variable R_ARCH
+:: - check if R_HOME\bin\i386 exists
+:: - if R_HOME\bin\x64 exists
+:: - if none of the above then use R_ARCH=/i386
+:: Note that R_HOME should be defined before calling this routine
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+:process_arch
+	rem set R_HOME
+	if defined R_ARCH goto:process_arch_cont
+	:: The loop searches for --arch and sets R_ARCH to the next argument
+    :process_arch_loop 
+    (set arg=%~1) 
+    shift 
+    if not defined arg goto :process_arch_cont 
+	if "%arg%"=="--arch" (set R_ARCH=%1) & goto:process_arch_cont
+	goto:process_arch_loop
+    :process_arch_cont
+	if defined R_ARCH goto:process_arch_defined
+	if exist %R_HOME%\bin\i386 (set R_ARCH=/i386) & goto:process_arch_defined
+	if exist %R_HOME%\bin\x64 (set R_ARCH=/x64) & goto:process_arch_defined
+	(set R_ARCH=/i386)
+	:process_arch_defined
+	if "%R_ARCH%"=="32" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="386" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="i386" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="64" (set R_ARCH=/x64)
+	if "%R_ARCH%"=="x64" (set R_ARCH=/x64)
+	:: if R_ARCH does not begin with a slash add one as a prefix
+	(set first_char=%R_ARCH:~0,1%)
+	if not "%first_char%" == "/" (set R_ARCH=/%R_ARCH%)
+	:: R_ARCH0 is like R_ARCH but without the beginning /
+	(set R_ARCH0=%R_ARCH:~1%)
+	goto:eof
+
+endlocal
+
+
+

Added: grass/trunk/mswindows/external/rbatch/THANKS
===================================================================
--- grass/trunk/mswindows/external/rbatch/THANKS	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/THANKS	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,35 @@
+
+Thanks to the following for contributing code:
+
+  Nicholas Hirschey <<Nicholas.Hirschey at phd.mccombs.utexas.edu>
+  Dieter Menne <dieter.menne at menne-biomed.de>
+  Erich Neuwirth <erich.neuwirth at univie.ac.at>
+
+Thanks to the following for finding bugs:
+
+  Nicholas Hirschey <<Nicholas.Hirschey at phd.mccombs.utexas.edu>
+  Xiaohua Dai <ecoinformatics at gmail.com>
+
+Thanks to the following people for discussion related to R:
+
+  Henrik Bengtsson <henrikb at braju.com>
+  J. Hosking <jh910 at juno.com>
+  Uwe Ligges <ligges at statistik.uni-dortmund.de>
+  Duncan Murdoch <murdoch at stats.uwo.ca>
+  Tobias Verbeke <tobias.verbeke at telenet.be>
+
+Also thanks to the following for discussion related to Windows batch:
+
+  William Allen
+  billious
+  carlos
+  Clay Calvert
+  Ted Davis
+  Al Dunbar
+  foxidrive
+  Phil Robyn
+  Paul R. Sadowski
+  Timo Salmi
+  Tomek (T3X)
+  Matthias Tacke
+

Added: grass/trunk/mswindows/external/rbatch/WISHLIST
===================================================================
--- grass/trunk/mswindows/external/rbatch/WISHLIST	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/WISHLIST	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,11 @@
+WISHLIST
+
+o Sweave.bat
+  - output file name
+  - commandArgs
+  - brew
+
+o clean up documentation
+
+o test latest version of XP (recent versions were tested only on Vista;
+  versions up to 0.3-2 tested only on XP)

Added: grass/trunk/mswindows/external/rbatch/clip2r.js
===================================================================
--- grass/trunk/mswindows/external/rbatch/clip2r.js	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/clip2r.js	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,27 @@
+// (c) 2009.  Gabor Grothendieck. 
+// This is free software licensed under GPL.
+//
+// Based on TpR.bas by Philippe Grosjean.
+//
+// 1. To find the directory where _vimrc goes enter this in vim   :echo $HOME
+// 2. Place these two lines in your _vimrc file in which case F3 will 
+//    transmit current selection to the clipboard and then paste it into R
+//    e.g. ctrl-A F3 copies entire file to R
+//
+//    map <F3> <C-C><ESC>:!start clip2r.js<CR><CR>
+//    imap <F3> <ESC><C-C><ESC>:!start clip2r.js<CR><CR>
+//
+//    Alternately use these two lines copy entire file when F3 is pressed:
+// 
+//    map <F3> <C-A><C-C><ESC>:!start clip2r.js<CR><CR>
+//    imap <F3> <ESC><C-A><C-C><ESC>:!start clip2r.js<CR><CR>
+//
+// Note: In the wsh.SendKeys command the strings: 
+//       "% x" stands for Alt-space x and has the effect of maximizing Rgui
+//       "%{w}1" stands for Alt-w 1 and activates the R console
+// 		 "^{v}" stands for ctrl-v and pastes clipboard.
+
+var wsh = new ActiveXObject("Wscript.Shell");
+wsh.AppActivate("Rgui");
+wsh.SendKeys("% x%{w}1^{v}");
+

Added: grass/trunk/mswindows/external/rbatch/copydir.bat
===================================================================
--- grass/trunk/mswindows/external/rbatch/copydir.bat	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/copydir.bat	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,16 @@
+ at echo off
+setlocal
+if not "%2"=="" goto:run
+echo Usage: copydir fromdir todir
+echo All files/directories in fromdir that do not also exist in todir are 
+echo recurisvely copied.
+echo e.g. 
+echo      cd \Program Files\R
+echo      copydir R-2.2.0\library R-2.3.0\library
+goto:eof
+:run
+:: Notes on code:
+:: on xcopy command /e copies subdir/files incl empty ones
+:: on xcopy command /i causes target to be created
+for /D  %%a in ("%~1\*") do if not exist %2\%%~na xcopy /e/i "%%a" "%~2\%%~nxa"
+endlocal

Added: grass/trunk/mswindows/external/rbatch/el.js
===================================================================
--- grass/trunk/mswindows/external/rbatch/el.js	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/el.js	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,16 @@
+// elevate.js -- runs target command line elevated
+if (WScript.Arguments.Length >= 1) {
+    Application = WScript.Arguments(0);
+    Arguments = "";
+    for (Index = 1; Index < WScript.Arguments.Length; Index += 1) {
+        if (Index > 1) {
+            Arguments += " ";
+        }
+        Arguments += WScript.Arguments(Index);
+    }
+    new ActiveXObject("Shell.Application").ShellExecute(Application, Arguments, "", "runas");
+} else {
+    WScript.Echo("Usage:");
+    WScript.Echo("elevate Application Arguments");
+}
+

Added: grass/trunk/mswindows/external/rbatch/find-miktex.hta
===================================================================
--- grass/trunk/mswindows/external/rbatch/find-miktex.hta	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/find-miktex.hta	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,29 @@
+<head>
+<STYLE TYPE="text/css">
+.highlight {background:#ff00ff}
+.text {color:#ff00ff}
+.both {color:white;background:black}
+</STYLE> 
+<title>find-miktex</title>
+</head>
+<body onLoad="window.resizeTo(650,250);">
+<h1>Find MiKTeX</h1>
+<script type="text/jscript">
+
+fso = new ActiveXObject("Scripting.FileSystemObject");
+mik = new ActiveXObject("MiKTeX.Session");
+
+i = 0;
+while (true) {
+	try {
+		rt = mik.GetRootDirectory(i);
+		if (fso.FileExists(rt + "\\miktex\\bin\\latex.exe")) {
+			document.write(rt + "\\miktex\\bin<br>");
+		}
+		i++;
+	} catch(e) {break};
+}
+	
+</script>
+</body>
+</html>

Added: grass/trunk/mswindows/external/rbatch/movedir.bat
===================================================================
--- grass/trunk/mswindows/external/rbatch/movedir.bat	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/movedir.bat	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,21 @@
+ at echo off
+setlocal
+:: Usage:
+::   If arg1 and arg2 are the library subdirectories of two R distributions
+::   then all libraries in arg1 that are not already in arg2 are moved to 
+::   arg2.  Note that this is a fast way of upgrading to a new version of
+::   R but won't work if the versions of R have different library formats.
+:: Example:
+::   cd \Program Files\R
+::   movedir R-2.2.0\library R-2.2.0pat\library
+::
+if not "%2"=="" goto:run
+echo Usage: movedir fromdir todir
+echo All files/directories in fromdir that do not also exist in todir are moved.
+echo e.g. 
+echo      cd \Program Files\R
+echo      movedir R-2.2.0\library R-2.3.0\library
+goto:eof
+:run
+for /D  %%a in ("%~1\*") do if not exist %2\%%~na move "%%a" "%~2\%%~nxa"
+endlocal

Added: grass/trunk/mswindows/external/rbatch/rterm.bat
===================================================================
--- grass/trunk/mswindows/external/rbatch/rterm.bat	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/rterm.bat	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,239 @@
+
+ at echo off
+rem if /i "%1"==path (path %2) && goto:eof
+
+setlocal
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: Placing this file in your path will allow rcmd to be run anywhere
+:: without changing your path environment variable.  See comments
+:: below on how it finds where R is.  Your path can be listed by
+:: the Windows console command:  path
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+rem at one tine this script had only been tested on XP
+rem recent tests have only been on Vista
+rem ver | findstr XP >NUL
+rem if errorlevel 1 echo Warning: This script has only been tested on Windows XP.
+
+set scriptdir_=%~dp0
+set lookin=.;%userprofile%;%scriptdir_%
+if not defined R_BATCHFILES_RC (
+	for %%f in ("rbatchfilesrc.bat") do set "R_BATCHFILES_RC=%%~$lookin:f"
+)
+if defined R_BATCHFILES_RC (
+	if exist "%R_BATCHFILES_RC%" call %R_BATCHFILES_RC%
+)
+
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: use environment variable R_HOME if defined
+:: else current folder if bin\rcmd.exe exists 
+:: else most current R as determined by registry entry
+:: else error
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+if not defined R_HOME if exist bin\r.exe set R_HOME=%CD%
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\R-core\R /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+if not defined R_HOME for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\r-core\r /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_HOME=%%~b
+if not defined R_HOME echo "Error: R not found" & goto:eof
+
+call :process_arch %*
+
+:: add R_MIKTEX to PATH if defined.  Otherwise if its not 
+:: in the PATH already then check \Program Files\miktex* or \miktex* 
+:: and if found add that to PATH.
+
+:: if miktex found in PATH skip searching for it
+PATH | findstr /i miktex > nul
+if not errorlevel 1 goto:end_miktex
+
+:: check for presence of %ProgramFiles%\miktex* or \miktex*
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on "%ProgramFiles%"\miktex* 2^>NUL'
+) do set R_MIKTEX=%ProgramFiles%\%%a
+
+if not defined R_MIKTEX for /f "delims=" %%a in (
+    'dir /b /on %SystemDrive%:\miktex* 2^>NUL'
+) do set R_MIKTEX=%SystemDrive%:\miktex\%%a
+
+:end_miktex
+if defined R_MIKTEX PATH %R_MIKTEX%\miktex\bin;%PATH%
+
+if not defined MYSQL_HOME for /f "delims=" %%a in (
+    'dir /b /on "%ProgramFiles%"\MySQL\* 2^>NUL'
+) do set MYSQL_HOME=%ProgramFiles%\MySQL\%%a
+
+if not defined R_TOOLS for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\R-core\Rtools /v InstallPath 2^>NUL ^| findstr InstallPath'
+ ) do set R_TOOLS=%%~b
+if not defined R_TOOLS for /f "tokens=2*" %%a in (
+ 'reg query hklm\software\wow6432Node\Rtools /v InstallPath 2^>NUL ^| findstr InstallPath'
+  ) do set R_TOOLS=%%~b
+
+set PATHQ=%PATH%
+:WHILE
+    if "%PATHQ%"=="" goto WEND
+    for /F "delims=;" %%i in ("%PATHQ%") do if exist "%%~sfi" set PATH2=%PATH2%;%%~sfi
+    for /F "delims=; tokens=1,*" %%i in ("%PATHQ%") do set PATHQ=%%j
+    goto WHILE 
+:WEND
+
+set path2=%path2:~1%
+
+if defined R_TOOLS (
+    set path2=%R_TOOLS%\bin;%R_TOOLS%\perl\bin;%R_TOOLS%\MinGW\bin;%PATH2%
+)
+
+path %path2%
+
+set here=%CD%
+set args=%*
+
+:: get name by which this command was called
+:: this allows same file to be used for Rgui, Rterm, etc. by just renaming it
+for %%i in (%0) do set cmd=%%~ni.exe
+
+if /i %cmd%==rtools.exe (endlocal & set path=%path2%) && goto:eof
+
+cd %R_HOME%\bin
+if /i not %cmd%==rguistart.exe goto:notRguiStart
+  set cmd=rgui.exe
+  set firstArgument=%1
+  if defined firstArgument (
+    dir %1 | findstr "<DIR>" > nul
+    if errorlevel 1 goto:notRguiStart
+    set here=%~1
+    set firstArgument=
+  )
+  set args=
+  shift
+  :startloop
+  set firstArgument=%1
+  if defined firstArgument (
+     set args=%args% "%~1" 
+     shift
+     goto:startloop
+  )
+:notRguiStart
+
+set st=
+if /i %cmd%==rgui.exe set st=start
+
+if /i not %cmd%==#Rscript.exe goto:not#Rscript
+set cmd=Rscript.exe
+if [%1]==[] goto:help#Rscript
+call :rsarg1 %*
+goto:not#Rscript
+:rsarg1
+set args=%*
+set arg1=%~1
+set arg1=%arg1:.bat.bat=.bat%
+set last4=%arg1:~-4%
+if /i not "%last4%"==".bat" set arg1=%arg1%.bat
+for %%a in ("%R_HOME%\bin\Rscript.exe") do set RSCRIPT=%%~sfa
+call set args=%%args:%1="%arg1%"%%
+rem call set args=%%args:%1=%%
+goto:eof
+:not#Rscript
+
+cd %here%
+
+:: Look in architecture specific subdirectory of bin. If not there look in bin.
+set cmdpath=%R_HOME%\bin\%R_ARCH0%\%cmd%
+if exist "%cmdpath%" goto:cmdpathfound
+set cmdpath=%R_HOME%\bin\%cmd%
+if exist "%cmdpath%" goto:cmdpathfound
+echo "Error: %cmd% not found" & goto:eof
+:cmdpathfound
+
+:: if called as jgr.bat locate the JGR package to find jgr.exe
+if /i not %cmd%==jgr.exe goto:notJGR
+  set st=start
+  set cmdpath=jgr.exe
+  if not defined JGR_LIBS set JGR_LIBS=%R_LIBS%
+  for %%a in ("%R_HOME%\bin\Rscript.exe") do set RSCRIPT=%%~sfa
+  if not defined JGR_LIBS for /f "usebackq delims=" %%a in (
+		`%RSCRIPT% -e "cat(.libPaths(),sep=';')"`
+  ) do set JGR_LIBS=%%~a
+  if not defined JGR_LIBS (
+	echo "Error: JGR package not found in R library" & goto:eof
+  )
+  for %%f in ("JGR") do set "jgrpkg=%%~$JGR_LIBS:f"
+  set JGR_LIB=%jgrpkg:~0,-4%
+  for %%a in ("%JGR_LIB%") do set JGR_LIB_SHORT=%%~sfa
+  for %%a in ("%R_HOME%") do set R_HOME_SHORT=%%~sfa
+  set args=--libpath=%JGR_LIB_SHORT% --rhome=%R_HOME_SHORT%
+
+:notJGR
+
+rem set R_ARCH
+rem set R_ARCH0
+rem set cmdpath
+rem if defined st set st
+rem set args
+
+set cygwin=nodosfilewarning
+if not defined args goto:noargs
+if defined st (start "" "%cmdpath%" %args%) else "%cmdpath%" %args%
+goto:eof
+:noargs
+if defined st (start "" "%cmdpath%") else "%cmdpath%"
+goto:eof
+
+:help#Rscript
+echo Usage: #Rscript %%0 %%*
+echo If the above is the first line in a file 
+echo containing only R code and the file is 
+echo given a .bat extension then it can be 
+echo run as a batch file.
+goto:eof
+
+
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: processing of --arch= where value can be 32, 64, i386, x64, /i386, /x64
+
+:: Call it like this: call :process_arch %*
+:: On return R_ARCH will be set from --arch or R_ARCH or default
+:: and R_ARCH0 will be R_ARCH without the / prefix
+:: It will look for the architecture in these places in this order:
+:: - first arg if its --arch
+:: - environment variable R_ARCH
+:: - check if R_HOME\bin\i386 exists
+:: - if R_HOME\bin\x64 exists
+:: - if none of the above then use R_ARCH=/i386
+:: Note that R_HOME should be defined before calling this routine
+::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+:process_arch
+	if defined R_ARCH goto:process_arch_cont
+	:: The loop searches for --arch and sets R_ARCH to the next argument
+    :process_arch_loop 
+    set arg=%~1
+    shift 
+    if not defined arg goto :process_arch_cont 
+	if "%arg%"=="--arch" set R_ARCH=%1
+	if defined R_ARCH goto:process_arch_cont
+	goto:process_arch_loop
+    :process_arch_cont
+	if defined process_arg_arch goto:process_arch_defined
+	if exist %R_HOME%\bin\i386 (set R_ARCH=/i386) & goto:process_arch_defined
+	if exist %R_HOME%\bin\x64 (set R_ARCH=/x64) & goto:process_arch_defined
+	(set R_ARCH=/i386)
+	:process_arch_defined
+	if "%R_ARCH%"=="32" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="386" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="i386" (set R_ARCH=/i386)
+	if "%R_ARCH%"=="64" (set R_ARCH=/x64)
+	if "%R_ARCH%"=="x64" (set R_ARCH=/x64)
+	:: if R_ARCH does not begin with a slash add one as a prefix
+	(set first_char=%R_ARCH:~0,1%)
+	if not "%first_char%" == "/" (set R_ARCH=/%R_ARCH%)
+	:: R_ARCH0 is like R_ARCH but without the beginning /
+	(set R_ARCH0=%R_ARCH:~1%)
+	goto:eof
+
+endlocal

Added: grass/trunk/mswindows/external/rbatch/show-svn-info.hta
===================================================================
--- grass/trunk/mswindows/external/rbatch/show-svn-info.hta	                        (rev 0)
+++ grass/trunk/mswindows/external/rbatch/show-svn-info.hta	2012-08-31 19:34:51 UTC (rev 53033)
@@ -0,0 +1,45 @@
+<head>
+<STYLE TYPE="text/css">
+.highlight {background:#ff00ff}
+.text {color:#ff00ff}
+.both {color:white;background:black}
+</STYLE> 
+<title>show-svn-info</title>
+</head>
+<body onLoad="window.resizeTo(650,450);">
+<h1>Tortoise SubVersion</h1>
+<A href="http://batchfiles.googlecode.com">batchfiles home page</a>
+<A href="http://cran.r-project.org/contrib/extra/batchfiles/">(CRAN)</a><br><br>
+<A href="http://tortoisesvn.net">Tortoise SVN home page</a>
+<A href="http://tortoisesvn.net/help">(Help)</a>
+<A href="http://groups.google.com/group/tortoisesvn">(Forum)</a> 
+<A href="http://groups.google.com/group/tortoisesvn-dev">(Devel Forum)</a><br><br>
+<script type="text/jscript">
+
+// based on code in section 6.4 of Tortoise SVN manual
+
+// testCOM.js - javascript file
+// test script for the SubWCRev COM/Automation-object
+
+filesystem = new ActiveXObject("Scripting.FileSystemObject");
+
+SubWCRev1 = new ActiveXObject("SubWCRev.object");
+SubWCRev2 = new ActiveXObject("SubWCRev.object");
+SubWCRev3 = new ActiveXObject("SubWCRev.object");
+
+SubWCRev1.GetWCInfo(filesystem.GetAbsolutePathName("."), 0, 0);
+SubWCRev2.GetWCInfo(filesystem.GetAbsolutePathName(".."), 1, 1);
+SubWCRev3.GetWCInfo(filesystem.GetAbsolutePathName("SubWCRev.cpp"), 
+                    0, 0);
+
+sInfo1 = "Revision = " + SubWCRev1.Revision + "<br>" +
+      "\nMin Revision = " + SubWCRev1.MinRev + "<br>" +
+      "\nMax Revision = " + SubWCRev1.MaxRev + "<br>" +
+      "\nDate = " + SubWCRev1.Date + "<br>" +
+      '\nURL = <a href="' + SubWCRev1.Url + '">' + SubWCRev1.Url + "</a><br>" +
+      "\nAuthor = " + SubWCRev1.Author + "<br>" +
+      "\nHasMods = " + SubWCRev1.HasModifications;
+document.write(sInfo1);
+</script>
+</body>
+</html>



More information about the grass-commit mailing list