* Bug #12333 fixed - Cleaned command history is restored after reopening Scilab. 18/10618/9
Simon Marchetto [Tue, 5 Mar 2013 11:13:49 +0000 (12:13 +0100)]
fix:
- on all platforms history file name is now SCIHOME/history
- retrieve everywhere history file path from preferences

+ remove wrong comments about history filename

Change-Id: I9c9ec856f88230ca293004900bc3c79979282e0c

25 files changed:
scilab/.gitignore
scilab/CHANGES_5.4.X
scilab/modules/core/includes/scilabDefaults.h
scilab/modules/history_browser/tests/nonreg_tests/bug_7437.tst
scilab/modules/history_manager/Makefile.am
scilab/modules/history_manager/Makefile.in
scilab/modules/history_manager/etc/XConfiguration-history.xml
scilab/modules/history_manager/help/en_US/gethistoryfile.xml
scilab/modules/history_manager/help/en_US/loadhistory.xml
scilab/modules/history_manager/help/en_US/savehistory.xml
scilab/modules/history_manager/help/en_US/sethistoryfile.xml
scilab/modules/history_manager/help/fr_FR/loadhistory.xml
scilab/modules/history_manager/help/fr_FR/savehistory.xml
scilab/modules/history_manager/help/ja_JP/loadhistory.xml
scilab/modules/history_manager/help/ja_JP/savehistory.xml
scilab/modules/history_manager/help/ja_JP/sethistoryfile.xml
scilab/modules/history_manager/includes/HistoryManager.h
scilab/modules/history_manager/src/c/history_manager.vcxproj
scilab/modules/history_manager/src/cpp/HistoryFile.cpp
scilab/modules/history_manager/src/cpp/HistoryFile.hxx
scilab/modules/history_manager/src/cpp/HistoryManager.hxx
scilab/modules/history_manager/src/java/org/scilab/modules/history_manager/HistoryManagement.java
scilab/modules/history_manager/src/jni/HistoryManagement.i
scilab/modules/history_manager/tests/nonreg_tests/bug_12333.dia.ref [new file with mode: 0644]
scilab/modules/history_manager/tests/nonreg_tests/bug_12333.tst [new file with mode: 0644]

index ad0f9e9..5504421 100644 (file)
@@ -90,7 +90,7 @@ modules/*/sci_gateway/fortran/*.c
 
 #
 # VS 2010 files
-# 
+#
 *.opensdf
 *.sdf
 *.old
@@ -120,7 +120,7 @@ Path.incl
 config.log
 config.status
 libtool
-history.scilab
+history
 lib
 tcllib
 _tmp_project.h
index 6d4a465..1cfdb4e 100644 (file)
@@ -186,6 +186,13 @@ Compilation
 
 * Enforce a minimal version of JLaTeXMath (1.0.1).
 
+
+Other changes
+=============
+
+* Console command history is now stored on all platforms in SCIHOME/history file.
+
+
 Bug fixes
 ==========
 
@@ -443,6 +450,8 @@ Bug fixes
 
 * Bug #12317 fixed - eventhandler functions no more report keyboard events
 
+* Bug #12333 fixed - Cleaned command history is restored after reopening Scilab.
+
 * Bug #12346 fixed - lsslist() help pages were mislocated. Moved now to CACSD.
 
 * Bug #12348 fixed - surf() disable lines(n) if there is no input variable.
index cdb70fe..1d9d4e0 100644 (file)
@@ -2,11 +2,11 @@
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2007 - INRIA - Sylvestre LEDRU
  * Copyright (C) ENPC
- * 
+ *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
  * you should have received as part of this distribution.  The terms
- * are also available at    
+ * are also available at
  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
 #define __SCILABDEFAULT_H__
 
 /* Where is stored the history by default */
-#ifdef _MSC_VER
-#define DEFAULT_HISTORY_FILE "history.scilab"
-#else
-#define DEFAULT_HISTORY_FILE ".history.scilab"
-#endif
+#define DEFAULT_HISTORY_FILE "history"
 
 #ifdef _MSC_VER
 #define ModelicacName "modelicac.exe"
@@ -30,7 +26,7 @@
 #endif
 
 /* Where the module list file is */
-#define basenamemodulesfile "etc/modules.xml" 
+#define basenamemodulesfile "etc/modules.xml"
 
 /* Where the classpath list file is */
 #define XMLCLASSPATH "%s/etc/classpath.xml"
@@ -45,7 +41,7 @@
 #define FORMATGATEWAYFILENAME "%s/modules/%s/sci_gateway/%s_gateway.xml"
 
 /* Where is the version file of a module */
-#define FORMATVERSIONFILENAME  "%s/modules/%s/version.xml" 
+#define FORMATVERSIONFILENAME  "%s/modules/%s/version.xml"
 
 
 /* Where is the Scilab startup script */
@@ -57,9 +53,9 @@
 /* default Scilab global StackSize  */
 #if defined(_MSC_VER) && defined(_WIN64)
 /* On Windows x64 initial global stacksize must be bigger :( */
-       #define DEFAULTGSTACKSIZE DEFAULTSTACKSIZE
+#define DEFAULTGSTACKSIZE DEFAULTSTACKSIZE
 #else
-       #define DEFAULTGSTACKSIZE 1000
+#define DEFAULTGSTACKSIZE 1000
 #endif
 
 
index ea84c39..7ef57fa 100644 (file)
@@ -17,8 +17,8 @@
 //
 
 // start scilab once time
-// edit SCIHOME/history.scilab
-editor SCIHOME/history.scilab
+// edit SCIHOME/history
+editor SCIHOME/history
 // remove first "// -- Begin Session"
 // and restart scilab
 
index 264f3c9..23bd172 100644 (file)
@@ -55,6 +55,7 @@ libscihistory_manager_la_CPPFLAGS =  $(JAVA_JNI_INCLUDE) \
 -I$(top_srcdir)/modules/fileio/includes/ \
 -I$(top_srcdir)/modules/history_browser/includes/ \
 -I$(top_srcdir)/modules/history_manager/includes/ \
+-I$(top_srcdir)/modules/preferences/includes/ \
 -I$(top_srcdir)/modules/localization/includes/ \
 -I$(top_srcdir)/modules/output_stream/includes/ \
 $(AM_CPPFLAGS)
index c37b65f..a1dd42f 100644 (file)
@@ -507,6 +507,7 @@ libscihistory_manager_la_CPPFLAGS = $(JAVA_JNI_INCLUDE) \
 -I$(top_srcdir)/modules/fileio/includes/ \
 -I$(top_srcdir)/modules/history_browser/includes/ \
 -I$(top_srcdir)/modules/history_manager/includes/ \
+-I$(top_srcdir)/modules/preferences/includes/ \
 -I$(top_srcdir)/modules/localization/includes/ \
 -I$(top_srcdir)/modules/output_stream/includes/ \
 $(AM_CPPFLAGS)
index c7af85d..307d22e 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <command-history title="_(Command history)">
   <body>
-    <history-settings history-file="SCIHOME/.history.scilab" history-lines="20000" enable="true"/>
+    <history-settings history-file="SCIHOME/history" history-lines="20000" enable="true"/>
     <history-save kind="quit" after="1"/>
   </body>
 </command-history>
index 0590e2b..9029be1 100644 (file)
     </refsection>
     <refsection>
         <title>Examples</title>
-        <programlisting role="example"><![CDATA[ 
+        <programlisting role="example"><![CDATA[
 gethistoryfile()
  ]]></programlisting>
     </refsection>
+    <refsection>
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.4.1</revnumber>
+                <revremark>
+                    Default history file is SCIHOME/history (instead of SCIHOME/.history.scilab).
+                </revremark>
+            </revision>
+        </revhistory>
+    </refsection>
 </refentry>
index 129f660..66e6545 100644 (file)
@@ -2,7 +2,7 @@
 <!--
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2007-2008 - INRIA - Allan CORNET
- * Copyright (C) 2011 - DIGITEO - Allan CORNET 
+ * Copyright (C) 2011 - DIGITEO - Allan CORNET
  *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
@@ -36,7 +36,7 @@
     <refsection>
         <title>Description</title>
         <para>load a history file.</para>
-        <para>by default, history filename is SCIHOME+'/.history.scilab'</para>
+        <para>by default, history filename is SCIHOME/history</para>
         <para>by default, loadhistory read last 20000 lines of history file(to
             reduce time loading).
         </para>
             </member>
         </simplelist>
     </refsection>
+    <refsection>
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.4.1</revnumber>
+                <revremark>
+                    Default history file is SCIHOME/history (instead of SCIHOME/.history.scilab).
+                </revremark>
+            </revision>
+        </revhistory>
+    </refsection>
 </refentry>
index 8b82d7c..a2f7bf7 100644 (file)
     <refsection>
         <title>Description</title>
         <para>save the current history in a file.</para>
-        <para>by default, history filename is SCIHOME+'/.history.scilab'</para>
+        <para>by default, history filename is SCIHOME/history</para>
     </refsection>
     <refsection>
         <title>Examples</title>
-        <programlisting role="example"><![CDATA[ 
-savehistory(SCI+'/session.scilab') 
+        <programlisting role="example"><![CDATA[
+savehistory(SCI+'/session.scilab')
  ]]></programlisting>
     </refsection>
     <refsection role="see also">
@@ -57,4 +57,15 @@ savehistory(SCI+'/session.scilab')
             </member>
         </simplelist>
     </refsection>
+    <refsection>
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.4.1</revnumber>
+                <revremark>
+                    Default history file is SCIHOME/history (instead of SCIHOME/.history.scilab).
+                </revremark>
+            </revision>
+        </revhistory>
+    </refsection>
 </refentry>
index a5ed9c6..4980b4c 100644 (file)
         <title>Description</title>
         <para>set filename for scilab history.</para>
         <para>sethistoryfile() without parameters will use the default filename
-            (SCIHOME/history.scilab)
+            (SCIHOME/history)
         </para>
     </refsection>
     <refsection>
         <title>Examples</title>
-        <programlisting role="example"><![CDATA[ 
+        <programlisting role="example"><![CDATA[
 gethistoryfile()
 sethistoryfile(gethistoryfile())
  ]]></programlisting>
     </refsection>
+    <refsection>
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.4.1</revnumber>
+                <revremark>
+                    Default history file is SCIHOME/history (instead of SCIHOME/.history.scilab).
+                </revremark>
+            </revision>
+        </revhistory>
+    </refsection>
 </refentry>
index 076b220..9f8b46f 100644 (file)
     <refsection>
         <title>Description</title>
         <para>charge un fichier contenant l'historique</para>
-        <para>Par défaut, le nom du fichier contenant l'historique est SCIHOME+'/.history.scilab'</para>
+        <para>Par défaut, le nom du fichier contenant l'historique est SCIHOME/history</para>
     </refsection>
     <refsection>
         <title>Exemples</title>
-        <programlisting role="example"><![CDATA[ 
-loadhistory(SCI+'/session.scilab') 
+        <programlisting role="example"><![CDATA[
+loadhistory(SCI+'/session.scilab')
 ]]></programlisting>
     </refsection>
     <refsection role="see also">
@@ -57,4 +57,15 @@ loadhistory(SCI+'/session.scilab')
             </member>
         </simplelist>
     </refsection>
+    <refsection>
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.4.1</revnumber>
+                <revremark>
+                    Le fichier par défaut pour stocker l'historique est SCIHOME/history (au lieu de SCIHOME/.history.scilab).
+                </revremark>
+            </revision>
+        </revhistory>
+    </refsection>
 </refentry>
index 434dc5c..204f4f4 100644 (file)
     <refsection>
         <title>Description</title>
         <para>sauvegarde l'historique de scilab dans un fichier.</para>
-        <para>Par défaut, l'historique est sauvegardé dans SCIHOME+'/.history.scilab'</para>
+        <para>Par défaut, l'historique est sauvegardé dans SCIHOME/history</para>
     </refsection>
     <refsection>
         <title>Exemples</title>
-        <programlisting role="example"><![CDATA[ 
-savehistory(SCI+'/session.scilab') 
+        <programlisting role="example"><![CDATA[
+savehistory(SCI+'/session.scilab')
 ]]></programlisting>
     </refsection>
     <refsection role="see also">
@@ -57,4 +57,15 @@ savehistory(SCI+'/session.scilab')
             </member>
         </simplelist>
     </refsection>
+    <refsection>
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.4.1</revnumber>
+                <revremark>
+                    Le fichier par défaut pour stocker l'historique est SCIHOME/history (au lieu de SCIHOME/.history.scilab).
+                </revremark>
+            </revision>
+        </revhistory>
+    </refsection>
 </refentry>
index 9569ce7..e81e4fb 100644 (file)
@@ -3,7 +3,7 @@
 <!--
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2007-2008 - INRIA - Allan CORNET
- * Copyright (C) 2011 - DIGITEO - Allan CORNET 
+ * Copyright (C) 2011 - DIGITEO - Allan CORNET
  *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
  -->
 
 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns4="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="loadhistory" xml:lang="ja">
-    
+
     <refnamediv>
-        
+
         <refname>loadhistory</refname>
-        
+
         <refpurpose>履歴ファイルを読み込む</refpurpose>
-        
+
     </refnamediv>
-    
+
     <refsynopsisdiv>
-        
+
         <title>呼び出し手順</title>
-        
+
         <synopsis>loadhistory()
-            
+
             loadhistory(f)
-            
+
         </synopsis>
-        
+
     </refsynopsisdiv>
-    
+
     <refsection>
-        
+
         <title>引数</title>
-        
+
         <variablelist>
-            
+
             <varlistentry>
-                
+
                 <term>f</term>
-                
+
                 <listitem>
-                    
+
                     <para>ファイルのパス名</para>
-                    
+
                 </listitem>
-                
+
             </varlistentry>
-            
+
         </variablelist>
-        
+
     </refsection>
-    
+
     <refsection>
-        
+
         <title>説明</title>
-        
+
         <para>履歴ファイルを読み込みます.</para>
-        
-        <para>デフォルトで,履歴ファイル名は SCIHOME+'/.history.scilab' です.</para>
-        
+
+        <para>デフォルトで,履歴ファイル名は SCIHOME/history です.</para>
+
         <para>デフォルトで, loadhistory は(読込時間を減らすために)
-            
+
             履歴ファイルの末尾 20000行を読み込みます.
-            
+
         </para>
-        
+
         <para>
-            
+
             この値を修正するには,
-            
-            <link linkend="historysize">historysize(value)</link> 
-            
+
+            <link linkend="historysize">historysize(value)</link>
+
             を参照してください.
-            
+
         </para>
-        
+
     </refsection>
-    
+
     <refsection>
-        
+
         <title>例</title>
-        
+
         <programlisting role="example"> loadhistory(SCI+'/session.scilab')  </programlisting>
-        
+
     </refsection>
-    
+
     <refsection role="see also">
-        
+
         <title>参照</title>
-        
+
         <simplelist type="inline">
-            
+
             <member>
-                
+
                 <link linkend="savehistory">savehistory</link>
-                
+
             </member>
-            
+
             <member>
-                
+
                 <link linkend="resethistory">resethistory</link>
-                
+
             </member>
-            
+
             <member>
-                
+
                 <link linkend="historysize">historysize</link>
-                
+
             </member>
-            
+
             <member>
-                
+
                 <link linkend="gethistory">gethistory</link>
-                
+
             </member>
-            
+
         </simplelist>
-        
+
     </refsection>
-    
+
 </refentry>
 
index a4f5df1..34e52d4 100644 (file)
  -->
 
 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="ja" xml:id="savehistory">
-    
+
     <refnamediv>
-        
+
         <refname>savehistory</refname>
-        
+
         <refpurpose>履歴をファイルに保存</refpurpose>
-        
+
     </refnamediv>
-    
+
     <refsynopsisdiv>
-        
+
         <title>呼び出し手順</title>
-        
+
         <synopsis>savehistory()
-            
+
             savehistory(f)
-            
+
         </synopsis>
-        
+
     </refsynopsisdiv>
-    
+
     <refsection>
-        
+
         <title>引数</title>
-        
+
         <variablelist>
-            
+
             <varlistentry>
-                
+
                 <term>f</term>
-                
+
                 <listitem>
-                    
+
                     <para>ファイルのパス名</para>
-                    
+
                 </listitem>
-                
+
             </varlistentry>
-            
+
         </variablelist>
-        
+
     </refsection>
-    
+
     <refsection>
-        
+
         <title>説明</title>
-        
+
         <para>履歴をファイルに保存します.</para>
-        
-        <para>デフォルトの履歴ファイルは SCIHOME+'/.history.scilab' です.</para>
-        
+
+        <para>デフォルトの履歴ファイルは SCIHOME/history です.</para>
+
     </refsection>
-    
+
     <refsection>
-        
+
         <title>例</title>
-        
-        <programlisting role="example"><![CDATA[ 
-savehistory(SCI+'/session.scilab') 
+
+        <programlisting role="example"><![CDATA[
+savehistory(SCI+'/session.scilab')
  ]]></programlisting>
-        
+
     </refsection>
-    
+
     <refsection role="see also">
-        
+
         <title>参照</title>
-        
+
         <simplelist type="inline">
-            
+
             <member>
-                
+
                 <link linkend="loadhistory">loadhistory</link>
-                
+
             </member>
-            
+
             <member>
-                
+
                 <link linkend="resethistory">resethistory</link>
-                
+
             </member>
-            
+
             <member>
-                
+
                 <link linkend="gethistory">gethistory</link>
-                
+
             </member>
-            
+
         </simplelist>
-        
+
     </refsection>
-    
+
 </refentry>
 
index fb8fa3c..2ffd1bd 100644 (file)
  -->
 
 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="ja" xml:id="sethistoryfile">
-    
+
     <refnamediv>
-        
+
         <refname>sethistoryfile</refname>
-        
+
         <refpurpose>Scilab履歴のファイル名を設定</refpurpose>
-        
+
     </refnamediv>
-    
+
     <refsynopsisdiv>
-        
+
         <title>呼び出し手順</title>
-        
+
         <synopsis>sethistoryfile(filename)
-            
+
             sethistoryfile()
-            
+
         </synopsis>
-        
+
     </refsynopsisdiv>
-    
+
     <refsection>
-        
+
         <title>引数</title>
-        
+
         <variablelist>
-            
+
             <varlistentry>
-                
+
                 <term>filename</term>
-                
+
                 <listitem>
-                    
+
                     <para>履歴のファイル名</para>
-                    
+
                 </listitem>
-                
+
             </varlistentry>
-            
+
         </variablelist>
-        
+
     </refsection>
-    
+
     <refsection>
-        
+
         <title>説明</title>
-        
+
         <para>Scilab履歴のファイル名を設定します.</para>
-        
+
         <para>パラメータ無しのsethistoryfile() は
-            
+
             デフォルトのファイル名
-            
-            (SCIHOME/history.scilab)を使用します.
-            
+
+            (SCIHOME/history)を使用します.
+
         </para>
-        
+
     </refsection>
-    
+
     <refsection>
-        
+
         <title>例</title>
-        
-        <programlisting role="example"><![CDATA[ 
+
+        <programlisting role="example"><![CDATA[
 gethistoryfile()
 sethistoryfile(gethistoryfile())
  ]]></programlisting>
-        
+
     </refsection>
-    
+
 </refentry>
 
index 1f29dd6..c5079af 100644 (file)
@@ -52,7 +52,6 @@ extern "C" {
     /**
     * save history in a file
     * @param a filename if NULL saves in default filename
-    * default filename --> SCIHOME/history.scilab
     * @return TRUE or FALSE
     */
     HISTORY_MANAGER_IMPEXP BOOL writeScilabHistoryToFile(char *filename);
@@ -60,7 +59,6 @@ extern "C" {
     /**
     * load history from a file
     * @param a filename if NULL load from default filename
-    * default filename --> SCIHOME/history.scilab
     * @return TRUE or FALSE
     */
     HISTORY_MANAGER_IMPEXP BOOL loadScilabHistoryFromFile(char *filename);
index ff3f8a3..31b579e 100644 (file)
@@ -80,7 +80,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>.;../../includes;../../../localization/includes;../../../jvm/includes;../../../../libs/intl;../../../core/includes;../../../windows_tools/includes;../../../output_stream/includes;../../../history_browser/includes;../../../fileio/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../api_scilab/includes;../jni;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../../includes;../../../localization/includes;../../../jvm/includes;../../../../libs/intl;../../../core/includes;../../../windows_tools/includes;../../../output_stream/includes;../../../history_browser/includes;../../../fileio/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../api_scilab/includes;../jni;../../../preferences/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;HISTORY_MANAGER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <WarningLevel>Level3</WarningLevel>
@@ -111,7 +111,7 @@ lib /DEF:"$(ProjectDir)history_browser_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$
     </Midl>
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>.;../../includes;../../../localization/includes;../../../jvm/includes;../../../../libs/intl;../../../core/includes;../../../windows_tools/includes;../../../output_stream/includes;../../../history_browser/includes;../../../fileio/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../api_scilab/includes;../jni;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../../includes;../../../localization/includes;../../../jvm/includes;../../../../libs/intl;../../../core/includes;../../../windows_tools/includes;../../../output_stream/includes;../../../history_browser/includes;../../../fileio/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../api_scilab/includes;../jni;../../../preferences/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;HISTORY_MANAGER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <WarningLevel>Level3</WarningLevel>
@@ -140,7 +140,7 @@ lib /DEF:"$(ProjectDir)history_browser_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$
     <ClCompile>
       <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
       <WholeProgramOptimization>false</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>.;../../includes;../../../localization/includes;../../../jvm/includes;../../../../libs/intl;../../../core/includes;../../../windows_tools/includes;../../../output_stream/includes;../../../history_browser/includes;../../../fileio/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../api_scilab/includes;../jni;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../../includes;../../../localization/includes;../../../jvm/includes;../../../../libs/intl;../../../core/includes;../../../windows_tools/includes;../../../output_stream/includes;../../../history_browser/includes;../../../fileio/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../api_scilab/includes;../jni;../../../preferences/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;HISTORY_MANAGER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -176,7 +176,7 @@ lib /DEF:"$(ProjectDir)history_browser_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$
     <ClCompile>
       <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
       <WholeProgramOptimization>false</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>.;../../includes;../../../localization/includes;../../../jvm/includes;../../../../libs/intl;../../../core/includes;../../../windows_tools/includes;../../../output_stream/includes;../../../history_browser/includes;../../../fileio/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../api_scilab/includes;../jni;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../../includes;../../../localization/includes;../../../jvm/includes;../../../../libs/intl;../../../core/includes;../../../windows_tools/includes;../../../output_stream/includes;../../../history_browser/includes;../../../fileio/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../api_scilab/includes;../jni;../../../preferences/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;HISTORY_MANAGER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -267,6 +267,9 @@ lib /DEF:"$(ProjectDir)history_browser_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$
       <Project>{a5911cd7-f8e8-440c-a23e-4843a0636f3a}</Project>
       <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
     </ProjectReference>
+    <ProjectReference Include="..\..\..\preferences\src\c\preferences.vcxproj">
+      <Project>{7b893e9f-d032-44de-9b71-197a29c4989b}</Project>
+    </ProjectReference>
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
index f491c0e..84fbb62 100644 (file)
@@ -32,6 +32,8 @@ extern "C"
 #include "mgetl.h"
 #include "mclose.h"
 #include "freeArrayOfString.h"
+#include "getScilabPreference.h"
+#include "expandPathVariable.h"
 };
 /*------------------------------------------------------------------------*/
 #define DEFAULT_HISTORY_FILE_MAX_LINES 20000
@@ -49,7 +51,10 @@ HistoryFile::~HistoryFile()
 /*------------------------------------------------------------------------*/
 std::string HistoryFile::getFilename(void)
 {
-    if (this->my_history_filename.empty()) this->setDefaultFilename();
+    if (this->my_history_filename.empty())
+    {
+        this->setDefaultFilename();
+    }
     return this->my_history_filename;
 }
 /*------------------------------------------------------------------------*/
@@ -68,63 +73,62 @@ void HistoryFile::setFilename(std::string filename)
 /*------------------------------------------------------------------------*/
 BOOL HistoryFile::setDefaultFilename(void)
 {
-    BOOL bOK = FALSE;
-    char *SCIHOME = getSCIHOME();
-    std::string defaultfilename;
-    std::string defautlhistoryfile;
-
-    defautlhistoryfile.assign(DEFAULT_HISTORY_FILE);
-
-    if (SCIHOME)
+    const ScilabPreferences* prefs = getScilabPreferences();
+    if (prefs != NULL)
     {
-        std::string sep;
-        std::string scihome;
-
-        sep.assign(DIR_SEPARATOR);
-        scihome.assign(SCIHOME);
-
-        defaultfilename = scihome + sep + defautlhistoryfile;
-
-        FREE(SCIHOME);
-        SCIHOME = NULL;
-        bOK = TRUE;
+        const char* prefHistoryFile = prefs->historyFile;
+        this->setFilename(expandPathVariable((char*)prefHistoryFile));
+        return TRUE;
     }
     else
     {
-        defaultfilename = defautlhistoryfile;
-        bOK = FALSE;
-        /* this isn't the standard path for history file */
-        /* but we set a filename */
+        std::string filename(DEFAULT_HISTORY_FILE);
+        char *SCIHOME = getSCIHOME();
+        if (SCIHOME)
+        {
+            std::string scihome(SCIHOME);
+            std::string sep(DIR_SEPARATOR);
+            this->setFilename(scihome + sep + filename);
+            return TRUE;
+        }
+        else
+        {
+            this->setFilename(filename);
+            return FALSE;
+        }
     }
-
-    this->setFilename(defaultfilename);
-
-    return bOK;
 }
+
 /*------------------------------------------------------------------------*/
 BOOL HistoryFile::writeToFile(std::string filename)
 {
     BOOL bOK = FALSE;
 
-    if (this->Commands.empty()) return bOK;
+    if (this->Commands.empty())
+    {
+        return bOK;
+    }
     else
     {
         FILE *pFile = NULL;
 
-        if (filename.empty())  return bOK;
+        if (filename.empty())
+        {
+            return bOK;
+        }
 
         wcfopen(pFile , (char*)filename.c_str(), "wt");
 
         if (pFile)
         {
             list<CommandLine>::iterator it_commands;
-            for(it_commands=this->Commands.begin(); it_commands != this->Commands.end(); ++it_commands)
+            for (it_commands = this->Commands.begin(); it_commands != this->Commands.end(); ++it_commands)
             {
                 std::string line = (*it_commands).get();
                 if (!line.empty())
                 {
-                    fputs(line.c_str(),pFile);
-                    fputs("\n",pFile);
+                    fputs(line.c_str(), pFile);
+                    fputs("\n", pFile);
                 }
             }
             fclose(pFile);
@@ -137,7 +141,10 @@ BOOL HistoryFile::writeToFile(std::string filename)
 BOOL HistoryFile::writeToFile(void)
 {
     BOOL bOK = FALSE;
-    if (!this->my_history_filename.empty()) bOK = this->writeToFile(my_history_filename);
+    if (!this->my_history_filename.empty())
+    {
+        bOK = this->writeToFile(my_history_filename);
+    }
     return bOK;
 }
 /*------------------------------------------------------------------------*/
@@ -193,7 +200,10 @@ errorLoadHistoryCode HistoryFile::loadFromFile(std::string filename)
 errorLoadHistoryCode HistoryFile::loadFromFile(void)
 {
     errorLoadHistoryCode returnedError = ERROR_HISTORY_NOT_LOADED;
-    if (!this->my_history_filename.empty()) returnedError = this->loadFromFile(my_history_filename);
+    if (!this->my_history_filename.empty())
+    {
+        returnedError = this->loadFromFile(my_history_filename);
+    }
     return returnedError;
 }
 /*------------------------------------------------------------------------*/
@@ -208,9 +218,12 @@ BOOL HistoryFile::setHistory(list<CommandLine> commands)
     BOOL bOK = FALSE;
     list<CommandLine>::iterator it_commands;
 
-    if (!this->Commands.empty()) this->Commands.clear();
+    if (!this->Commands.empty())
+    {
+        this->Commands.clear();
+    }
 
-    for(it_commands=commands.begin(); it_commands != commands.end(); ++it_commands)
+    for (it_commands = commands.begin(); it_commands != commands.end(); ++it_commands)
     {
         std::string line = (*it_commands).get();
         if (!line.empty())
@@ -225,7 +238,7 @@ BOOL HistoryFile::setHistory(list<CommandLine> commands)
 BOOL HistoryFile::reset(void)
 {
     BOOL bOK = FALSE;
-    BOOL check1 = FALSE,check2 = FALSE;
+    BOOL check1 = FALSE, check2 = FALSE;
 
     if (!this->Commands.empty())
     {
@@ -239,7 +252,10 @@ BOOL HistoryFile::reset(void)
         check2 = TRUE;
     }
 
-    if (check1 && check2) bOK = TRUE;
+    if (check1 && check2)
+    {
+        bOK = TRUE;
+    }
 
     return bOK;
 }
index 862d5b0..b47d0fe 100644 (file)
@@ -15,7 +15,7 @@
 #include <list>
 #include "CommandLine.hxx"
 /*------------------------------------------------------------------------*/
-typedef enum 
+typedef enum
 {
     NO_ERROR_HISTORY_LOADED,
     ERROR_HISTORY_NOT_LOADED,
@@ -51,7 +51,6 @@ public:
 
     /**
     * set default filename used by history
-    * SCIHOME/history.scilab
     * @return TRUE or FALSE
     */
     BOOL setDefaultFilename(void);
index 61a57e8..bee7043 100644 (file)
@@ -84,7 +84,6 @@ public:
     /**
     * save history in a file
     * @param a filename if NULL saves in default filename
-    * default filename --> SCIHOME/history.scilab
     * @return TRUE or FALSE
     */
     BOOL writeToFile(char *filename);
@@ -92,7 +91,6 @@ public:
     /**
     * load history from a file
     * @param a filename if NULL load from default filename
-    * default filename --> SCIHOME/<scilab version>history.scilab
     * @return TRUE or FALSE
     */
     BOOL loadFromFile(char *filename);
index 6d42888..054424d 100644 (file)
@@ -9,11 +9,11 @@
 package org.scilab.modules.history_manager;
 
 
- /** 
-   * All Scilab history management used in Java console 
+ /**
+   * All Scilab history management used in Java console
    * @author Vincent COUVERT
    * @author Allan CORNET
-   * @copyright INRIA 
+   * @copyright INRIA
    */
 public class HistoryManagement {
 
@@ -23,7 +23,7 @@ public class HistoryManagement {
   protected HistoryManagement() {
     throw new UnsupportedOperationException();
   }
-  
+
     /**
     * add a line to History manager
     * @param line a line to add
@@ -34,7 +34,7 @@ public static boolean appendLineToScilabHistory(String line) {
     return HistoryManagementJNI.appendLineToScilabHistory(line);
   }
 
-  
+
     /**
     * append lines to History manager
     * @param lines array of string
@@ -45,7 +45,7 @@ public static boolean appendLinesToScilabHistory(String[] lines, int numberoflin
     return HistoryManagementJNI.appendLinesToScilabHistory(lines, numberoflines);
   }
 
-  
+
     /**
     * Display history
     */
@@ -53,29 +53,27 @@ public static void displayScilabHistory() {
     HistoryManagementJNI.displayScilabHistory();
   }
 
-  
+
     /**
     * save history in a file
     * @param filename if NULL saves in default filename
-    * default filename --> SCIHOME/history.scilab
     * @return true or false
     */
 public static boolean writeScilabHistoryToFile(String filename) {
     return HistoryManagementJNI.writeScilabHistoryToFile(filename);
   }
 
-  
+
     /**
     * load history from a file
     * @param filename if NULL load from default filename
-    * default filename --> SCIHOME/history.scilab
     * @return true or false
     */
 public static boolean loadScilabHistoryFromFile(String filename) {
     return HistoryManagementJNI.loadScilabHistoryFromFile(filename);
   }
 
-  
+
     /**
     * set filename of history
     * @param filename of history
@@ -85,7 +83,7 @@ public static boolean setFilenameScilabHistory(String filename) {
     return HistoryManagementJNI.setFilenameScilabHistory(filename);
   }
 
-  
+
     /**
     * get filename of history
     * @return a filename
@@ -94,7 +92,7 @@ public static String getFilenameScilabHistory() {
     return HistoryManagementJNI.getFilenameScilabHistory();
   }
 
-  
+
     /**
     * set default filename of history
     * @return true or false
@@ -103,7 +101,7 @@ public static boolean setDefaultFilenameScilabHistory() {
     return HistoryManagementJNI.setDefaultFilenameScilabHistory();
   }
 
-  
+
     /**
     * reset history manager
     */
@@ -111,7 +109,7 @@ public static void resetScilabHistory() {
     HistoryManagementJNI.resetScilabHistory();
   }
 
-  
+
     /**
     * Get all lines in history
     * @return an array of strings
@@ -120,17 +118,17 @@ public static String[] getAllLinesOfScilabHistory() {
     return HistoryManagementJNI.getAllLinesOfScilabHistory();
   }
 
-  
+
     /**
     * Get numbers of lines in history
     * size of array returned by getAllLinesOfScilabHistory
-    * @return int 
+    * @return int
     */
 public static int getSizeAllLinesOfScilabHistory() {
     return HistoryManagementJNI.getSizeAllLinesOfScilabHistory();
   }
 
-  
+
     /**
     * set new token to search in history
     * @param token (a string)
@@ -140,7 +138,7 @@ public static boolean setSearchedTokenInScilabHistory(String token) {
     return HistoryManagementJNI.setSearchedTokenInScilabHistory(token);
   }
 
-  
+
     /**
     * reset search in history
     * @return true or false
@@ -149,7 +147,7 @@ public static boolean resetSearchedTokenInScilabHistory() {
     return HistoryManagementJNI.resetSearchedTokenInScilabHistory();
   }
 
-  
+
     /**
     * get token searched in history
     * @return token (a string)
@@ -158,7 +156,7 @@ public static String getSearchedTokenInScilabHistory() {
     return HistoryManagementJNI.getSearchedTokenInScilabHistory();
   }
 
-  
+
     /**
     * Get the previous line in Scilab history
     * @return a line or NULL
@@ -168,7 +166,7 @@ public static String getPreviousLineInScilabHistory() {
     return HistoryManagementJNI.getPreviousLineInScilabHistory();
   }
 
-  
+
     /**
     * Get the next line in Scilab history
     * @return a line or NULL
@@ -178,7 +176,7 @@ public static String getNextLineInScilabHistory() {
     return HistoryManagementJNI.getNextLineInScilabHistory();
   }
 
-  
+
     /**
     * Get numbers of lines in history
     * @return number of lines
@@ -187,7 +185,7 @@ public static int getNumberOfLinesInScilabHistory() {
     return HistoryManagementJNI.getNumberOfLinesInScilabHistory();
   }
 
-  
+
     /**
     * set consecutive duplicate lines are added
     * @param doit (true or false)
@@ -196,7 +194,7 @@ public static void setSaveConsecutiveDuplicateLinesInScilabHistory(boolean doit)
     HistoryManagementJNI.setSaveConsecutiveDuplicateLinesInScilabHistory(doit);
   }
 
-  
+
     /**
     * indicate if consecutive duplicate lines are added
     * @return true or false
@@ -205,7 +203,7 @@ public static boolean getSaveConsecutiveDuplicateLinesInScilabHistory() {
     return HistoryManagementJNI.getSaveConsecutiveDuplicateLinesInScilabHistory();
   }
 
-  
+
     /**
     * Set after how many lines history is saved
     * @param num number between 0 and Max
@@ -215,7 +213,7 @@ public static void setAfterHowManyLinesScilabHistoryIsSaved(int num) {
     HistoryManagementJNI.setAfterHowManyLinesScilabHistoryIsSaved(num);
   }
 
-  
+
     /**
     * Get after how many lines history is saved
     * @return number between 0 and Max
@@ -225,7 +223,7 @@ public static int getAfterHowManyLinesScilabHistoryIsSaved() {
     return HistoryManagementJNI.getAfterHowManyLinesScilabHistoryIsSaved();
   }
 
-  
+
     /**
     * Get the Nth Line in history
     * @param N the number of the line to get
@@ -235,7 +233,7 @@ public static String getNthLineInScilabHistory(int N) {
     return HistoryManagementJNI.getNthLineInScilabHistory(N);
   }
 
-  
+
     /**
     * delete the Nth Line in history
     * @param N the number of the line to delete
@@ -245,7 +243,7 @@ public static boolean deleteNthLineScilabHistory(int N) {
     return HistoryManagementJNI.deleteNthLineScilabHistory(N);
   }
 
-  
+
     /**
     * get number of lines of history
     * @return a number >= 0
@@ -254,7 +252,7 @@ public static int getSizeScilabHistory() {
     return HistoryManagementJNI.getSizeScilabHistory();
   }
 
-  
+
     /**
     * get history manager state
     * @return true or false
@@ -263,7 +261,7 @@ public static boolean historyIsEnabled() {
     return HistoryManagementJNI.historyIsEnabled();
   }
 
-  
+
     /**
     * set the number of max lines
     * @return true or false
@@ -272,7 +270,7 @@ public static boolean setSizeMaxScilabHistory(int nbLinesMax) {
     return HistoryManagementJNI.setSizeMaxScilabHistory(nbLinesMax);
   }
 
-  
+
     /**
     * terminate the history manager
     * @return true or false
@@ -281,7 +279,7 @@ public static boolean InitializeHistoryManager() {
     return HistoryManagementJNI.InitializeHistoryManager();
   }
 
-  
+
     /**
     * terminate the history manager
     * @return true or false
index cbb8170..470cfad 100644 (file)
@@ -3,7 +3,7 @@
 /* HistoryManagement.i */
 /* To run this file execute the command below from current directory */
 /**
- * Windows: swig -java -package org.scilab.modules.history_manager -outdir ../java/org/scilab/modules/history_manager/ HistoryManagement.i 
+ * Windows: swig -java -package org.scilab.modules.history_manager -outdir ../java/org/scilab/modules/history_manager/ HistoryManagement.i
  * Other: Use the option --enable-build-swig to the configure
 */
 
 %pragma(java) jniclassclassmodifiers=%{
 /* It is generated code. Disable checkstyle */
 //CHECKSTYLE:OFF
- /** 
-   * All Scilab history management used in Java console 
+ /**
+   * All Scilab history management used in Java console
    * @author Vincent COUVERT
    * @author Allan CORNET
-   * @copyright INRIA 
+   * @copyright INRIA
    */
 class%}
 
@@ -37,7 +37,7 @@ class%}
  protected HistoryManagementJNI() {
         throw new UnsupportedOperationException();
  }";
+
  /* static load of library */
 %pragma(java) jniclasscode=%{
   static {
@@ -57,11 +57,11 @@ class%}
 
 /* JavaDoc for HistoryManagement class */
 %pragma(java) moduleclassmodifiers="
- /** 
-   * All Scilab history management used in Java console 
+ /**
+   * All Scilab history management used in Java console
    * @author Vincent COUVERT
    * @author Allan CORNET
-   * @copyright INRIA 
+   * @copyright INRIA
    */
 public class";
 
@@ -106,7 +106,6 @@ public";
     /**
     * save history in a file
     * @param filename if NULL saves in default filename
-    * default filename --> SCIHOME/history.scilab
     * @return true or false
     */
 public";
@@ -116,7 +115,6 @@ public";
     /**
     * load history from a file
     * @param filename if NULL load from default filename
-    * default filename --> SCIHOME/history.scilab
     * @return true or false
     */
 public";
@@ -159,16 +157,16 @@ public";
     * Get all lines in history
     * @return an array of strings
     */
-public";    
+public";
     char **getAllLinesOfScilabHistory(void);
-    
+
 %javamethodmodifiers getSizeAllLinesOfScilabHistory(void) "
     /**
     * Get numbers of lines in history
     * size of array returned by getAllLinesOfScilabHistory
-    * @return int 
+    * @return int
     */
-public";    
+public";
     int getSizeAllLinesOfScilabHistory(void);
 
 
@@ -282,7 +280,7 @@ public";
     */
 public";
     int getSizeScilabHistory(void);
-    
+
 %javamethodmodifiers historyIsEnabled(void) "
     /**
     * get history manager state
diff --git a/scilab/modules/history_manager/tests/nonreg_tests/bug_12333.dia.ref b/scilab/modules/history_manager/tests/nonreg_tests/bug_12333.dia.ref
new file mode 100644 (file)
index 0000000..7218d60
--- /dev/null
@@ -0,0 +1,28 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Simon MARCHETTO
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 12333 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=12333
+//
+// <-- Short Description -->
+// Cleaned command history is restored after reopening Scilab
+// add some history to be sure it is not empty, and save it
+addhistory("lineA");
+addhistory("lineB");
+addhistory("lineC");
+addhistory("lineD");
+addhistory("lineE");
+savehistory();
+// reset history, and save it
+resethistory();
+savehistory();
+// reload history => it should have less than 5 lines
+loadhistory(SCIHOME + '/history');
+h = gethistory();
+assert_checktrue(size(h,'r') < 5);
diff --git a/scilab/modules/history_manager/tests/nonreg_tests/bug_12333.tst b/scilab/modules/history_manager/tests/nonreg_tests/bug_12333.tst
new file mode 100644 (file)
index 0000000..6ad335d
--- /dev/null
@@ -0,0 +1,31 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Simon MARCHETTO
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 12333 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=12333
+//
+// <-- Short Description -->
+// Cleaned command history is restored after reopening Scilab
+
+// add some history to be sure it is not empty, and save it
+addhistory("lineA");
+addhistory("lineB");
+addhistory("lineC");
+addhistory("lineD");
+addhistory("lineE");
+savehistory();
+
+// reset history, and save it
+resethistory();
+savehistory();
+
+// reload history => it should have less than 5 lines
+loadhistory(SCIHOME + '/history');
+h = gethistory();
+assert_checktrue(size(h,'r') < 5);