bug 9498 fixed - A long history caused Scilab startup to be very long. 64/4064/4
Allan CORNET [Tue, 17 May 2011 15:02:33 +0000 (17:02 +0200)]
Change-Id: I8abfe598a2fc68a1ab3a3a55a9965ecc7afa897b

21 files changed:
SEP/SEP_064_extends_historysize.odt [new file with mode: 0644]
scilab/CHANGES_5.4.X
scilab/Scilab.sln
scilab/modules/fileio/fileio.vcxproj
scilab/modules/fileio/fileio.vcxproj.filters
scilab/modules/fileio/includes/mgetl.h [moved from scilab/modules/fileio/src/c/mgetl.h with 100% similarity]
scilab/modules/history_manager/help/en_US/historysize.xml
scilab/modules/history_manager/help/en_US/loadhistory.xml
scilab/modules/history_manager/includes/HistoryManager.h
scilab/modules/history_manager/sci_gateway/c/sci_historysize.c
scilab/modules/history_manager/sci_gateway/c/sci_loadhistory.c
scilab/modules/history_manager/src/c/LibScilab_Import.def
scilab/modules/history_manager/src/c/fileio_Import.def
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.cpp
scilab/modules/history_manager/src/cpp/HistoryManager.hxx
scilab/modules/history_manager/tests/nonreg_tests/bug_9498.tst [new file with mode: 0644]
scilab/modules/history_manager/tests/unit_tests/historysize.dia.ref [new file with mode: 0644]
scilab/modules/history_manager/tests/unit_tests/historysize.tst [new file with mode: 0644]

diff --git a/SEP/SEP_064_extends_historysize.odt b/SEP/SEP_064_extends_historysize.odt
new file mode 100644 (file)
index 0000000..edc6acc
Binary files /dev/null and b/SEP/SEP_064_extends_historysize.odt differ
index d4d11f0..e53ac22 100644 (file)
@@ -221,6 +221,8 @@ Bug fixes:
 
 * bug 9479 fixed - Typo fixed (intput => input).
 
+* bug 9498 fixed - A long history caused Scilab startup to be very long.
+
 * bug 9510 fixed - export_to_hdf5 did not return %f when trying to export
                    unmanaged type (function, macro, ...)
 
index 34f9bb1..32e7158 100644 (file)
@@ -414,6 +414,9 @@ EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nocompletion", "modules\completion\src\nocompletion\nocompletion.vcxproj", "{D1586C83-3F16-467B-85C6-6A12A08CCB8D}"
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "history_manager", "modules\history_manager\src\c\history_manager.vcxproj", "{1B98DC87-44F5-48AE-B5D0-29DD8AD86F5E}"
+       ProjectSection(ProjectDependencies) = postProject
+               {43C5BAB1-1DCA-4743-A183-77E0D42FE7D0} = {43C5BAB1-1DCA-4743-A183-77E0D42FE7D0}
+       EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "history_manager-Ant", "modules\history_manager\src\java\history_manager-JAVA.vcxproj", "{63965A84-E354-4CBC-BFAC-FDFC8224573F}"
 EndProject
index 35bc41f..56d8260 100644 (file)
@@ -348,6 +348,7 @@ lib /DEF:"$(ProjectDir)io_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /O
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="includes\addfile.h" />
+    <ClInclude Include="includes\mgetl.h" />
     <ClInclude Include="src\c\basename.h" />
     <ClInclude Include="includes\cluni0.h" />
     <ClInclude Include="src\c\copyfile.h" />
@@ -380,7 +381,6 @@ lib /DEF:"$(ProjectDir)io_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /O
     <ClInclude Include="src\c\merror.h" />
     <ClInclude Include="includes\mget.h" />
     <ClInclude Include="src\c\mgeti.h" />
-    <ClInclude Include="src\c\mgetl.h" />
     <ClInclude Include="src\c\mgetstr.h" />
     <ClInclude Include="includes\mopen.h" />
     <ClInclude Include="src\c\movefile.h" />
index d90112e..c6c40a4 100644 (file)
     <ClInclude Include="src\c\mgeti.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="src\c\mgetl.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="src\c\mgetstr.h">
       <Filter>Header Files</Filter>
     </ClInclude>
     <ClInclude Include="includes\URIFileToFilename.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="includes\mgetl.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="src\c\fileio.rc">
index b3559cc..a42a7fd 100644 (file)
@@ -2,6 +2,7 @@
 <!--
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2006-2008 - INRIA - 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
  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  -->
-<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" version="5.0-subset Scilab" xml:lang="en" xml:id="historysize">
+<refentry version="5.0-subset Scilab" xml:id="historysize" xml:lang="en"
+          xmlns="http://docbook.org/ns/docbook"
+          xmlns:xlink="http://www.w3.org/1999/xlink"
+          xmlns:svg="http://www.w3.org/2000/svg"
+          xmlns:ns3="http://www.w3.org/1999/xhtml"
+          xmlns:mml="http://www.w3.org/1998/Math/MathML"
+          xmlns:db="http://docbook.org/ns/docbook">
   <info>
-    <pubdate>$LastChangedDate: 2006-08-17 18:06:16 +0200 (jeu., 17 août 2006) $</pubdate>
+    <pubdate>$LastChangedDate: 2006-08-17 18:06:16 +0200 (jeu., 17 août 2006)
+    $</pubdate>
   </info>
+
   <refnamediv>
     <refname>historysize</refname>
+
     <refpurpose>get number of lines in history</refpurpose>
   </refnamediv>
+
   <refsynopsisdiv>
     <title>Calling Sequence</title>
-    <synopsis>nb=historysize()</synopsis>
+
+    <synopsis>nb = historysize()</synopsis>
+
+    <synopsis>nbMax = historysize("max")</synopsis>
+
+    <synopsis>nbMax = historysize(newMax)</synopsis>
   </refsynopsisdiv>
+
   <refsection>
     <title>Arguments</title>
+
     <variablelist>
       <varlistentry>
         <term>nb</term>
+
         <listitem>
-          <para>number of lines in history.</para>
+          <para>number of lines in current history.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>nbMax</term>
+
+        <listitem>
+          <para>number of lines maximum in history file.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>newMax</term>
+
+        <listitem>
+          <para>set number of lines maximum in history file.</para>
+
+          <para>by default this value is 20000 lines max.</para>
         </listitem>
       </varlistentry>
     </variablelist>
   </refsection>
+
   <refsection>
     <title>Description</title>
+
     <para>get number of lines in history.</para>
+
+    <para>This function can also used to set maximun number of lines in
+    history file.</para>
   </refsection>
+
   <refsection>
     <title>Examples</title>
-    <programlisting role="example"><![CDATA[ 
-historysize()
- ]]></programlisting>
-  </refsection>
-  <refsection>
-    <title>Authors</title>
-    <simplelist type="vert">
-      <member>A.C</member>
-    </simplelist>
+
+    <programlisting role="example">historysize()
+historysize("max")</programlisting>
   </refsection>
 </refentry>
index 920ee88..9f4d8eb 100644 (file)
@@ -2,6 +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 
  *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  -->
-<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" version="5.0-subset Scilab" xml:lang="en" xml:id="loadhistory">
+<refentry version="5.0-subset Scilab" xml:id="loadhistory" xml:lang="en"
+          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">
   <info>
     <pubdate>$LastChangedDate$</pubdate>
   </info>
+
   <refnamediv>
     <refname>loadhistory</refname>
+
     <refpurpose>load a history file</refpurpose>
   </refnamediv>
+
   <refsynopsisdiv>
     <title>Calling Sequence</title>
+
     <synopsis>loadhistory()
 loadhistory(f)</synopsis>
   </refsynopsisdiv>
+
   <refsection>
     <title>Arguments</title>
+
     <variablelist>
       <varlistentry>
         <term>f</term>
+
         <listitem>
           <para>file pathname</para>
         </listitem>
       </varlistentry>
     </variablelist>
   </refsection>
+
   <refsection>
     <title>Description</title>
-    <para>load a history file</para>
+
+    <para>load a history file.</para>
+
     <para>by default, history filename is SCIHOME+'/.history.scilab'</para>
+
+    <para>by default, loadhistory read last 20000 lines of history file(to
+    reduce time loading).</para>
+
+    <para>see <link linkend="historysize">historysize(value)</link> to modify
+    this value.</para>
   </refsection>
+
   <refsection>
     <title>Examples</title>
-    <programlisting role="example"><![CDATA[ 
-loadhistory(SCI+'/session.scilab') 
- ]]></programlisting>
+
+    <programlisting role="example"> loadhistory(SCI+'/session.scilab')  </programlisting>
   </refsection>
+
   <refsection role="see also">
-<title>See Also</title>
+    <title>See Also</title>
+
     <simplelist type="inline">
-      <member>
-        <link linkend="savehistory">savehistory</link>
-      </member>
-      <member>
-        <link linkend="resethistory">resethistory</link>
-      </member>
-      <member>
-        <link linkend="gethistory">gethistory</link>
-      </member>
-    </simplelist>
-  </refsection>
-  <refsection>
-    <title>Authors</title>
-    <simplelist type="vert">
-      <member>A.C</member>
+      <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 47881ee..9c544ca 100644 (file)
@@ -1,14 +1,15 @@
 /*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007-2008 - INRIA - 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
- * you should have received as part of this distribution.  The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2007-2008 - INRIA - Allan CORNET
+* Copyright (C) 2010 - 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
+* you should have received as part of this distribution.  The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
 
 /*------------------------------------------------------------------------*/
 #ifndef __HISTORYMANAGER_C_H__
 #ifdef __cplusplus
 extern "C" {
 #endif
-/*------------------------------------------------------------------------*/
-       /**
-       * get history manager state
-       * @return TRUE or FALSE
-       */
-       HISTORY_MANAGER_IMPEXP BOOL historyIsEnabled(void);
-
-       /**
-        * append lines to History manager
-        * @param array of string
-        * @param size of the array of string
-        * @return TRUE or FALSE
-        */
-       HISTORY_MANAGER_IMPEXP BOOL appendLinesToScilabHistory(char **lines_, int numberoflines);
-       // Note it is lines_ because line is a keyword for term stuff
-
-       /**
-       * add a line to History manager
-       * @param a line to add
-       * line isn't added if it is the same as previous (FALSE)
-       * @return TRUE or FALSE
-       */
-       HISTORY_MANAGER_IMPEXP BOOL appendLineToScilabHistory(char *line);
-
-       /**
-       * Display history
-       */
-       HISTORY_MANAGER_IMPEXP void displayScilabHistory(void);
-
-       /**
-       * 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);
-
-       /**
-       * 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);
-
-       /**
-       * set filename of history
-       * @param filename of history
-       * @return TRUE or FALSE
-       */
-       HISTORY_MANAGER_IMPEXP BOOL setFilenameScilabHistory(char *filename);
-
-       /**
-       * get filename of history
-       * @return a filename
-       */
-       HISTORY_MANAGER_IMPEXP char *getFilenameScilabHistory(void);
-
-       /**
-       * set default filename of history
-       * @return TRUE or FALSE
-       */
-       HISTORY_MANAGER_IMPEXP BOOL setDefaultFilenameScilabHistory(void);
-
-       /**
-       * reset history manager
-       */
-       HISTORY_MANAGER_IMPEXP void resetScilabHistory(void);
-
-       /**
-       * Get all lines in history
-       * @return a array of string
-       */
-       HISTORY_MANAGER_IMPEXP char **getAllLinesOfScilabHistory(void);
-
-       /**
-       * Get numbers of lines in history
-       * size of array returned by getAllLinesOfScilabHistory
-       * @return int
-       */
-       HISTORY_MANAGER_IMPEXP int getSizeAllLinesOfScilabHistory(void);
-
-       /**
-       * set new token to search in history
-       * @param token (a string)
-       * @return TRUE or FALSE
-       */
-       HISTORY_MANAGER_IMPEXP BOOL setSearchedTokenInScilabHistory(char *token);
-
-       /**
-       * reset search in history
-       * @return TRUE or FALSE
-       */
-       HISTORY_MANAGER_IMPEXP BOOL resetSearchedTokenInScilabHistory(void);
-
-       /**
-       * get token searched in history
-       * @return token (a string)
-       */
-       HISTORY_MANAGER_IMPEXP char *getSearchedTokenInScilabHistory(void);
-
-       /**
-       * Get the previous line in Scilab history
-       * @return a line or NULL
-       * after a appendLine iterator go to end
-       */
-       HISTORY_MANAGER_IMPEXP char *getPreviousLineInScilabHistory(void);
-
-       /**
-       * Get the next line in Scilab history
-       * @return a line or NULL
-       * after a appendLine iterator go to end
-       */
-       HISTORY_MANAGER_IMPEXP char *getNextLineInScilabHistory(void);
-
-       /**
-       * Get numbers of lines in history
-       * @return number of lines
-       */
-       HISTORY_MANAGER_IMPEXP int getNumberOfLinesInScilabHistory(void);
-
-       /**
-       * set consecutive duplicate lines are added
-       * @param doit (TRUE or FALSE)
-       */
-       HISTORY_MANAGER_IMPEXP void setSaveConsecutiveDuplicateLinesInScilabHistory(BOOL doit);
-
-       /**
-       * indicate if consecutive duplicate lines are added
-       * @return TRUE or FALSE
-       */
-       HISTORY_MANAGER_IMPEXP BOOL getSaveConsecutiveDuplicateLinesInScilabHistory(void);
-
-       /**
-       * Set after how many lines history is saved
-       * @param number between 0 and Max
-       * default value is 0 (disabled)
-       */
-       HISTORY_MANAGER_IMPEXP void setAfterHowManyLinesScilabHistoryIsSaved(int num);
-
-       /**
-       * Get after how many lines history is saved
-       * @return number between 0 and Max
-       * default value is 0 (disabled)
-       */
-       HISTORY_MANAGER_IMPEXP int getAfterHowManyLinesScilabHistoryIsSaved(void);
-
-       /**
-       * Get the Nth Line in history
-       * @param N
-       * @return the Nth Line
-       */
-       HISTORY_MANAGER_IMPEXP char *getNthLineInScilabHistory(int N);
-
-       /**
-       * delete the Nth Line in history
-       * @param N
-       * @return TRUE or FALSE
-       */
-       HISTORY_MANAGER_IMPEXP BOOL deleteNthLineScilabHistory(int N);
-
-       /**
-       * get number of lines of history
-       * @return a number >= 0
-       */
-       HISTORY_MANAGER_IMPEXP int getSizeScilabHistory(void);
-
-
-/*------------------------------------------------------------------------*/
+    /*------------------------------------------------------------------------*/
+    /**
+    * get history manager state
+    * @return TRUE or FALSE
+    */
+    HISTORY_MANAGER_IMPEXP BOOL historyIsEnabled(void);
+
+    /**
+    * append lines to History manager
+    * @param array of string
+    * @param size of the array of string
+    * @return TRUE or FALSE
+    */
+    HISTORY_MANAGER_IMPEXP BOOL appendLinesToScilabHistory(char **lines_, int numberoflines);
+    // Note it is lines_ because line is a keyword for term stuff
+
+    /**
+    * add a line to History manager
+    * @param a line to add
+    * line isn't added if it is the same as previous (FALSE)
+    * @return TRUE or FALSE
+    */
+    HISTORY_MANAGER_IMPEXP BOOL appendLineToScilabHistory(char *line);
+
+    /**
+    * Display history
+    */
+    HISTORY_MANAGER_IMPEXP void displayScilabHistory(void);
+
+    /**
+    * 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);
+
+    /**
+    * 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);
+
+    /**
+    * set filename of history
+    * @param filename of history
+    * @return TRUE or FALSE
+    */
+    HISTORY_MANAGER_IMPEXP BOOL setFilenameScilabHistory(char *filename);
+
+    /**
+    * get filename of history
+    * @return a filename
+    */
+    HISTORY_MANAGER_IMPEXP char *getFilenameScilabHistory(void);
+
+    /**
+    * set default filename of history
+    * @return TRUE or FALSE
+    */
+    HISTORY_MANAGER_IMPEXP BOOL setDefaultFilenameScilabHistory(void);
+
+    /**
+    * get info about history file was or not truncated (too big)
+    * @return TRUE (truncated) or FALSE
+    */
+    HISTORY_MANAGER_IMPEXP BOOL isScilabHistoryTruncated(void);
+
+    /**
+    * reset history manager
+    */
+    HISTORY_MANAGER_IMPEXP void resetScilabHistory(void);
+
+    /**
+    * Get all lines in history
+    * @return a array of string
+    */
+    HISTORY_MANAGER_IMPEXP char **getAllLinesOfScilabHistory(void);
+
+    /**
+    * Get numbers of lines in history
+    * size of array returned by getAllLinesOfScilabHistory
+    * @return int
+    */
+    HISTORY_MANAGER_IMPEXP int getSizeAllLinesOfScilabHistory(void);
+
+    /**
+    * set new token to search in history
+    * @param token (a string)
+    * @return TRUE or FALSE
+    */
+    HISTORY_MANAGER_IMPEXP BOOL setSearchedTokenInScilabHistory(char *token);
+
+    /**
+    * reset search in history
+    * @return TRUE or FALSE
+    */
+    HISTORY_MANAGER_IMPEXP BOOL resetSearchedTokenInScilabHistory(void);
+
+    /**
+    * get token searched in history
+    * @return token (a string)
+    */
+    HISTORY_MANAGER_IMPEXP char *getSearchedTokenInScilabHistory(void);
+
+    /**
+    * Get the previous line in Scilab history
+    * @return a line or NULL
+    * after a appendLine iterator go to end
+    */
+    HISTORY_MANAGER_IMPEXP char *getPreviousLineInScilabHistory(void);
+
+    /**
+    * Get the next line in Scilab history
+    * @return a line or NULL
+    * after a appendLine iterator go to end
+    */
+    HISTORY_MANAGER_IMPEXP char *getNextLineInScilabHistory(void);
+
+    /**
+    * Get numbers of lines in history
+    * @return number of lines
+    */
+    HISTORY_MANAGER_IMPEXP int getNumberOfLinesInScilabHistory(void);
+
+    /**
+    * set consecutive duplicate lines are added
+    * @param doit (TRUE or FALSE)
+    */
+    HISTORY_MANAGER_IMPEXP void setSaveConsecutiveDuplicateLinesInScilabHistory(BOOL doit);
+
+    /**
+    * indicate if consecutive duplicate lines are added
+    * @return TRUE or FALSE
+    */
+    HISTORY_MANAGER_IMPEXP BOOL getSaveConsecutiveDuplicateLinesInScilabHistory(void);
+
+    /**
+    * Set after how many lines history is saved
+    * @param number between 0 and Max
+    * default value is 0 (disabled)
+    */
+    HISTORY_MANAGER_IMPEXP void setAfterHowManyLinesScilabHistoryIsSaved(int num);
+
+    /**
+    * Get after how many lines history is saved
+    * @return number between 0 and Max
+    * default value is 0 (disabled)
+    */
+    HISTORY_MANAGER_IMPEXP int getAfterHowManyLinesScilabHistoryIsSaved(void);
+
+    /**
+    * Get the Nth Line in history
+    * @param N
+    * @return the Nth Line
+    */
+    HISTORY_MANAGER_IMPEXP char *getNthLineInScilabHistory(int N);
+
+    /**
+    * delete the Nth Line in history
+    * @param N
+    * @return TRUE or FALSE
+    */
+    HISTORY_MANAGER_IMPEXP BOOL deleteNthLineScilabHistory(int N);
+
+    /**
+    * get number of lines of history
+    * @return a number >= 0
+    */
+    HISTORY_MANAGER_IMPEXP int getSizeScilabHistory(void);
+
+    /**
+    */
+    BOOL setSizeMaxScilabHistory(int nbLinesMax);
+
+    /**
+    */
+    int getSizeMaxScilabHistory(void);
+
+
+    /*------------------------------------------------------------------------*/
 #ifdef __cplusplus
 }
 #endif
index 0529e19..4dd7bd6 100644 (file)
 /*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007-2008 - INRIA - 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
- * you should have received as part of this distribution.  The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2007-2008 - INRIA - 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
+* you should have received as part of this distribution.  The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
 
 /*------------------------------------------------------------------------*/
-/* desc : interface for historysize primitive                             */
-/*------------------------------------------------------------------------*/
 #include "gw_history_manager.h"
-#include "stack-c.h"
 #include "HistoryManager.h"
-#include "MALLOC.h"
+#include "stack-c.h"
+#include "api_scilab.h"
+#include "localization.h"
+#include "Scierror.h"
 /*--------------------------------------------------------------------------*/
 int sci_historysize(char *fname,unsigned long fname_len)
 {
-       int *paramoutINT=NULL;
-       int n = 1;
-       Rhs = Max(Rhs,0);
-       CheckRhs(0,0);
-       CheckLhs(0,1);
+    int iReturnedValue = 0;
+
+    Rhs = Max(Rhs,0);
+    CheckRhs(0, 1);
+    CheckLhs(0, 1);
+    if (Rhs == 1)
+    {
+        int iValue = 0;
+        int *piAddressVarOne = NULL;
+        SciErr sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne);
+        if(sciErr.iErr)
+        {
+            printError(&sciErr, 0);
+            return 0;
+        }
 
-       paramoutINT=(int*)MALLOC(sizeof(int));
+        if (isStringType(pvApiCtx, piAddressVarOne))
+        {
+            if (isScalar(pvApiCtx, piAddressVarOne))
+            {
+                char *paramValue = NULL;
+                if (getAllocatedSingleString(pvApiCtx, piAddressVarOne, &paramValue) == 0)
+                {
+                    if (strcmp(paramValue, "max") == 0)
+                    {
+                        iReturnedValue = getSizeMaxScilabHistory();
+                        freeAllocatedSingleString(paramValue);
+                        paramValue = NULL;
+                    }
+                    else
+                    {
+                        Scierror(999, _("%s: Wrong value for input argument #%d: \"%s\" expected.\n"),fname,1, "max");
+                        freeAllocatedSingleString(paramValue);
+                        paramValue = NULL;
+                        return 0;
+                    }
+                }
+                else
+                {
+                    Scierror(999,_("%s: Memory allocation error.\n"), fname);
+                }
+            }
+            else
+            {
+                Scierror(999, _("%s: Wrong size for input argument #%d.\n"), fname, 1);
+                return 0;
+            }
+        }
+        else if (isDoubleType(pvApiCtx, piAddressVarOne))
+        {
+            if (isScalar(pvApiCtx, piAddressVarOne))
+            {
+                double dValue = 0.;
+                if (getScalarDouble(pvApiCtx, piAddressVarOne, &dValue) == 0)
+                {
+                    iValue = (int)(dValue);
+                }
 
-       *paramoutINT = getSizeScilabHistory();
+                if (!setSizeMaxScilabHistory(iValue))
+                {
+                    Scierror(999, _("%s: Wrong value for input argument #%d.\n"), fname, 1);
+                    return 0;
+                }
+                iReturnedValue = iValue;
+            }
+            else
+            {
+                Scierror(999, _("%s: Wrong size for input argument #%d.\n"), fname, 1);
+                return 0;
+            }
+        }
+        else
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d.\n"), fname, 1);
+            return 0;
+        }
+    }
+    else
+    {
+        iReturnedValue = getSizeScilabHistory();
+    }
 
-       CreateVarFromPtr(Rhs+1,MATRIX_OF_INTEGER_DATATYPE, &n, &n, &paramoutINT);
-       LhsVar(1) = Rhs+1;
-       C2F(putlhsvar)();
+    createScalarDouble(pvApiCtx, Rhs + 1, (double)iReturnedValue);
+    LhsVar(1) = Rhs + 1;
 
-       if (paramoutINT) {FREE(paramoutINT);paramoutINT = NULL;}
-       return 0 ;
+    PutLhsVar();
+    return 0;
 }
 /*--------------------------------------------------------------------------*/
index 1d7fb5e..3ee950a 100644 (file)
@@ -1,59 +1,67 @@
 /*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2006-2008 - INRIA - 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
- * you should have received as part of this distribution.  The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2006-2008 - INRIA - 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
+* you should have received as part of this distribution.  The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
 
 /*--------------------------------------------------------------------------*/
-/* INRIA 2006 */
-/* Allan CORNET */
-/*--------------------------------------------------------------------------*/
 #include "gw_history_manager.h"
 #include "stack-c.h"
 #include "HistoryManager.h"
 #include "MALLOC.h"
 #include "expandPathVariable.h"
+#include "warningmode.h"
+#include "localization.h"
+#include "sciprint.h"
 /*--------------------------------------------------------------------------*/
 int sci_loadhistory(char *fname,unsigned long fname_len)
 {
-       CheckRhs(0,1) ;
-       CheckLhs(0,1) ;
+    CheckRhs(0,1) ;
+    CheckLhs(0,1) ;
+
+    if (Rhs == 0)
+    {
+        char *filename = getFilenameScilabHistory();
+        if (filename)
+        {
+            loadScilabHistoryFromFile(filename);
+            FREE(filename);
+            filename=NULL;
+        }
+    }
+    else
+    {
+        char *line = NULL;
+        int l1 = 0, m1 = 0, n1 = 0;
+        char *Path = NULL;
 
-       if (Rhs == 0)
-       {
-               char *filename = getFilenameScilabHistory();
-               if (filename)
-               {
-                       loadScilabHistoryFromFile(filename);
-                       FREE(filename);
-                       filename=NULL;
-               }
-       }
-       else
-       {
-               char *line = NULL;
-               int l1 = 0, m1 = 0, n1 = 0;
-               char *Path = NULL;
+        GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
+        Path = cstk(l1);
+        line = expandPathVariable(Path);
+        if (line)
+        {
+            loadScilabHistoryFromFile(line);
+            FREE(line);
+            line = NULL;
+        }
+    }
 
-               GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
-               Path = cstk(l1);
-               line = expandPathVariable(Path);
-               if (line)
-               {
-                       loadScilabHistoryFromFile(line);
-                       FREE(line);
-                       line = NULL;
-               }
-       }
+    /* silent truncation 
+    if (isScilabHistoryTruncated() && getWarningMode())
+    {
+        sciprint(_("WARNING: history has been truncated (too big).\n"));
+    }
+    */
 
-       LhsVar(1) = 0;
-       C2F(putlhsvar)();
-       return 0;
+    LhsVar(1) = 0;
+    C2F(putlhsvar)();
+    return 0;
 }
 /*--------------------------------------------------------------------------*/
index 0b58109..78b2a70 100644 (file)
@@ -312,6 +312,9 @@ lib /DEF:"$(ProjectDir)history_browser_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$
       <Project>{3170e4c2-1173-4264-a222-7ee8ccb3ddf7}</Project>
       <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
     </ProjectReference>
+    <ProjectReference Include="..\..\..\api_scilab\api_scilab.vcxproj">
+      <Project>{43c5bab1-1dca-4743-a183-77e0d42fe7d0}</Project>
+    </ProjectReference>
     <ProjectReference Include="..\..\..\output_stream\src\c\output_stream.vcxproj">
       <Project>{a5911cd7-f8e8-440c-a23e-4843a0636f3a}</Project>
       <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
index a29e08e..f491c0e 100644 (file)
@@ -1,15 +1,15 @@
 /*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007-2008 - INRIA - Allan CORNET
- * Copyright (C) 2010 - 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
- * you should have received as part of this distribution.  The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2007-2008 - INRIA - Allan CORNET
+* Copyright (C) 2010-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
+* you should have received as part of this distribution.  The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
 /*------------------------------------------------------------------------*/
 #include "HistoryFile.hxx"
 #include "MALLOC.h"
@@ -28,10 +28,17 @@ extern "C"
 #include "getCommentDateSession.h"
 #include "scilabDefaults.h"
 #include "charEncoding.h"
+#include "mopen.h"
+#include "mgetl.h"
+#include "mclose.h"
+#include "freeArrayOfString.h"
 };
 /*------------------------------------------------------------------------*/
+#define DEFAULT_HISTORY_FILE_MAX_LINES 20000
+/*------------------------------------------------------------------------*/
 HistoryFile::HistoryFile()
 {
+    MaxLinesToRead = DEFAULT_HISTORY_FILE_MAX_LINES;
     my_history_filename.erase();
 }
 /*------------------------------------------------------------------------*/
@@ -134,36 +141,60 @@ BOOL HistoryFile::writeToFile(void)
     return bOK;
 }
 /*------------------------------------------------------------------------*/
-BOOL HistoryFile::loadFromFile(std::string filename)
+errorLoadHistoryCode HistoryFile::loadFromFile(std::string filename)
 {
-#define SECURITY_BUFFER 1000
-    BOOL bOK = FALSE;
-    char  line[PATH_MAX+1];
-    FILE * pFile = NULL;
+    errorLoadHistoryCode returnedError = ERROR_HISTORY_NOT_LOADED;
+    int fd = 0;
+    int f_swap = 0;
+    double res = 0.0;
+    int errMOPEN = MOPEN_INVALID_STATUS;
+    double dErrClose = 0.;
 
-    if (filename.empty()) return bOK;
 
-    wcfopen(pFile , (char*)filename.c_str(), "rt");
-
-    if (pFile)
+    C2F(mopen)(&fd, (char*)filename.c_str(), "rt", &f_swap, &res, &errMOPEN);
+    if (errMOPEN == MOPEN_NO_ERROR)
     {
-        while(fgets (line,sizeof(line),pFile) != NULL)
+        int errMGETL = MGETL_ERROR;
+        int nblines = 0;
+        char **lines = mgetl(fd, -1, &nblines, &errMGETL);
+
+        C2F(mclose)(&fd, &dErrClose);
+        if (errMGETL == MGETL_NO_ERROR)
         {
-            line[strlen(line)-1]='\0'; /* remove carriage return */
-            CommandLine Line(line);
-            this->Commands.push_back(Line);
+            if (lines)
+            {
+                int iStart = 0;
+                int iEnd = 0;
+                if (nblines > getDefaultMaxNbLines())
+                {
+                    iStart = nblines - getDefaultMaxNbLines();
+                    returnedError = HISTORY_TRUNCATED;
+                }
+                else
+                {
+                    iStart = 0;
+                    returnedError = NO_ERROR_HISTORY_LOADED;
+                }
+                iEnd = nblines;
+
+                for (int i = iStart; i < iEnd; i++)
+                {
+                    CommandLine Line(lines[i]);
+                    this->Commands.push_back(Line);
+                }
+                freeArrayOfString(lines, nblines);
+                lines = NULL;
+            }
         }
-        fclose(pFile);
-        bOK = TRUE;
     }
-    return bOK;
+    return returnedError;
 }
 /*------------------------------------------------------------------------*/
-BOOL HistoryFile::loadFromFile(void)
+errorLoadHistoryCode HistoryFile::loadFromFile(void)
 {
-    BOOL bOK = FALSE;
-    if (!this->my_history_filename.empty()) bOK = this->loadFromFile(my_history_filename);
-    return bOK;
+    errorLoadHistoryCode returnedError = ERROR_HISTORY_NOT_LOADED;
+    if (!this->my_history_filename.empty()) returnedError = this->loadFromFile(my_history_filename);
+    return returnedError;
 }
 /*------------------------------------------------------------------------*/
 list<CommandLine> HistoryFile::getHistory(void)
@@ -213,3 +244,19 @@ BOOL HistoryFile::reset(void)
     return bOK;
 }
 /*------------------------------------------------------------------------*/
+int HistoryFile::getDefaultMaxNbLines(void)
+{
+    return MaxLinesToRead;
+}
+/*------------------------------------------------------------------------*/
+BOOL HistoryFile::setDefaultMaxNbLines(int nbLinesMax)
+{
+    BOOL bOK = FALSE;
+    if (nbLinesMax > 0)
+    {
+        MaxLinesToRead = nbLinesMax;
+        bOK = TRUE;
+    }
+    return bOK;
+}
+/*------------------------------------------------------------------------*/
index 97816d1..862d5b0 100644 (file)
 /*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007-2008 - INRIA - 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
- * you should have received as part of this distribution.  The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2007-2008 - INRIA - 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
+* you should have received as part of this distribution.  The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
 
 /*------------------------------------------------------------------------*/
 #include <list>
 #include "CommandLine.hxx"
+/*------------------------------------------------------------------------*/
+typedef enum 
+{
+    NO_ERROR_HISTORY_LOADED,
+    ERROR_HISTORY_NOT_LOADED,
+    HISTORY_TRUNCATED
+} errorLoadHistoryCode;
+/*------------------------------------------------------------------------*/
 using namespace std;
 /*------------------------------------------------------------------------*/
 class HistoryFile
 {
 public:
-       /**
-       * Constructor
-       */
-       HistoryFile();
+    /**
+    * Constructor
+    */
+    HistoryFile();
+
+    /**
+    * Destructor
+    */
+    ~HistoryFile();
+
+    /**
+    * get filename used by history
+    * @return a string (filenam)
+    */
+    std::string getFilename(void);
 
-       /**
-       * Destructor
-       */
-       ~HistoryFile();
+    /**
+    * set filename used by history
+    * @param a string (filename)
+    */
+    void setFilename(std::string filename);
 
-       /**
-       * get filename used by history
-       * @return a string (filenam)
-       */
-       std::string getFilename(void);
+    /**
+    * set default filename used by history
+    * SCIHOME/history.scilab
+    * @return TRUE or FALSE
+    */
+    BOOL setDefaultFilename(void);
 
-       /**
-       * set filename used by history
-       * @param a string (filename)
-       */
-       void setFilename(std::string filename);
+    /**
+    * write history to a file
+    * @param a string the filename
+    * @return TRUE or FALSE
+    */
+    BOOL writeToFile(std::string filename);
 
-       /**
-       * set default filename used by history
-       * SCIHOME/history.scilab
-       * @return TRUE or FALSE
-       */
-       BOOL setDefaultFilename(void);
+    /**
+    * write history to a file
+    * use default filename
+    * @return TRUE or FALSE
+    */
+    BOOL writeToFile(void);
 
-       /**
-       * write history to a file
-       * @param a string the filename
-       * @return TRUE or FALSE
-       */
-       BOOL writeToFile(std::string filename);
+    /**
+    * load history from a file
+    * @param a string the filename
+    * @return TRUE or FALSE
+    */
+    errorLoadHistoryCode loadFromFile(std::string filename);
 
-       /**
-       * write history to a file
-       * use default filename
-       * @return TRUE or FALSE
-       */
-       BOOL writeToFile(void);
+    /**
+    * load history from a file
+    * use default filename
+    * @return TRUE or FALSE
+    */
+    errorLoadHistoryCode loadFromFile(void);
 
-       /**
-       * load history from a file
-       * @param a string the filename
-       * @return TRUE or FALSE
-       */
-       BOOL loadFromFile(std::string filename);
+    /**
+    * get loaded history
+    * @return a list of CommandLine
+    */
+    list<CommandLine> getHistory(void);
 
-       /**
-       * load history from a file
-       * use default filename
-       * @return TRUE or FALSE
-       */
-       BOOL loadFromFile(void);
+    /**
+    * set History to save
+    * @param a list of CommandLine
+    * @return TRUE or FALSE
+    */
+    BOOL setHistory(list<CommandLine> commands);
 
-       /**
-       * get loaded history
-       * @return a list of CommandLine
-       */
-       list<CommandLine> getHistory(void);
+    /**
+    * reset HistoryFile Object
+    * @return TRUE or FALSE
+    */
+    BOOL reset(void);
 
-       /**
-       * set History to save
-       * @param a list of CommandLine
-       * @return TRUE or FALSE
-       */
-       BOOL setHistory(list<CommandLine> commands);
+    /**
+    *
+    */
+    int getDefaultMaxNbLines(void);
 
-       /**
-       * reset HistoryFile Object
-       * @return TRUE or FALSE
-       */
-       BOOL reset(void);
+    /**
+    *
+    */
+    BOOL setDefaultMaxNbLines(int nbLinesMax);
 
 protected:
 private:
-       std::string my_history_filename;
-       list<CommandLine> Commands;
+    std::string my_history_filename;
+    list<CommandLine> Commands;
+    int MaxLinesToRead;
 };
 /*------------------------------------------------------------------------*/
index eadbbf3..9a14b23 100644 (file)
@@ -1,15 +1,16 @@
 /*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007-2008 - INRIA - Allan CORNET
- * Copyright (C) 2010 - DIGITEO - Vincent COUVERT
- *
- * 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
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2007-2008 - INRIA - Allan CORNET
+* Copyright (C) 2010 - DIGITEO - Vincent COUVERT
+* 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
+* you should have received as part of this distribution.  The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
 
 /*------------------------------------------------------------------------*/
 #include "HistoryManager.hxx"
@@ -190,6 +191,16 @@ BOOL loadScilabHistoryFromFile(char *filename)
     return bOK;
 }
 /*------------------------------------------------------------------------*/
+BOOL isScilabHistoryTruncated(void)
+{
+    BOOL bOK = FALSE;
+    if (ScilabHistory)
+    {
+        bOK = ScilabHistory->isTruncated();
+    }
+    return bOK;
+}
+/*------------------------------------------------------------------------*/
 BOOL setFilenameScilabHistory(char *filename)
 {
     if (filename)
@@ -327,8 +338,23 @@ int getSizeScilabHistory(void)
     return val;
 }
 /*------------------------------------------------------------------------*/
+BOOL setSizeMaxScilabHistory(int nbLinesMax)
+{
+    BOOL bOK = FALSE;
+    if (ScilabHistory) bOK = ScilabHistory->setNumberOfLinesMax(nbLinesMax);
+    return bOK;
+}
+/*------------------------------------------------------------------------*/
+int getSizeMaxScilabHistory(void)
+{
+    int val = 0;
+    if (ScilabHistory) val = ScilabHistory->getNumberOfLinesMax();
+    return val;
+}
+/*------------------------------------------------------------------------*/
 HistoryManager::HistoryManager()
 {
+    bTruncated = FALSE;
     CommandsList.clear();
     saveconsecutiveduplicatelines = FALSE;
     afterhowmanylineshistoryissaved = 0;
@@ -476,7 +502,10 @@ BOOL HistoryManager::loadFromFile(char *filename)
         std::string name;
         name.assign(filename);
 
-        my_file.loadFromFile(name);
+        if (my_file.loadFromFile(name) == HISTORY_TRUNCATED)
+        {
+            bTruncated = TRUE;
+        }
 
         CommandsList.clear();
         CommandsList = my_file.getHistory();
@@ -740,7 +769,7 @@ BOOL HistoryManager::isBeginningSessionLine(char *line)
     {
         if (strlen(line) > strlen(SESSION_PRAGMA_BEGIN) + strlen(SESSION_PRAGMA_END))
         {
-            #define STR_LEN_MAX 64
+#define STR_LEN_MAX 64
             char str_start[STR_LEN_MAX];
             char str_end[STR_LEN_MAX];
             strncpy(str_start, line, (int)strlen(SESSION_PRAGMA_BEGIN));
@@ -768,3 +797,18 @@ void HistoryManager::fixHistorySession(void)
     }
 }
 /*--------------------------------------------------------------------------*/
+BOOL HistoryManager::isTruncated(void)
+{
+    return bTruncated;
+}
+/*--------------------------------------------------------------------------*/
+BOOL HistoryManager::setNumberOfLinesMax(int nbLinesMax)
+{
+    return my_file.setDefaultMaxNbLines(nbLinesMax);
+}
+/*--------------------------------------------------------------------------*/
+int HistoryManager::getNumberOfLinesMax(void)
+{
+    return my_file.getDefaultMaxNbLines();
+}
+/*--------------------------------------------------------------------------*/
\ No newline at end of file
index 0bf79d2..ab6183f 100644 (file)
@@ -1,14 +1,15 @@
 /*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007-2008 - INRIA - 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
- * you should have received as part of this distribution.  The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2007-2008 - INRIA - 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
+* you should have received as part of this distribution.  The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
 
 /*------------------------------------------------------------------------*/
 #ifndef __HISTORYMANAGER_CPP_H__
@@ -196,6 +197,22 @@ public:
     */
     char *getNextLine(void);
 
+    /**
+    * get info about history file was truncated
+    * @return TRUE or FALSE
+    */
+    BOOL isTruncated(void);
+
+    /**
+    *
+    */
+    BOOL setNumberOfLinesMax(int nbLinesMax);
+
+    /**
+    *
+    */
+    int getNumberOfLinesMax(void);
+
 protected:
 
 private:
@@ -219,6 +236,7 @@ private:
     */
     void fixHistorySession(void);
 
+    BOOL bTruncated;
 
 };
 /*------------------------------------------------------------------------*/
diff --git a/scilab/modules/history_manager/tests/nonreg_tests/bug_9498.tst b/scilab/modules/history_manager/tests/nonreg_tests/bug_9498.tst
new file mode 100644 (file)
index 0000000..2ca6935
--- /dev/null
@@ -0,0 +1,21 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Allan CORNET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- JVM NOT MANDATORY -->
+// <-- INTERACTIVE TEST -->
+
+// <-- Non-regression test for bug 9498 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=9498
+//
+// <-- Short Description -->
+// By default history file was not limited
+
+// creates a very big history file
+// start scilab, only last 20000 (default) lines are loaded in scilab
+// and a message disabled about this
diff --git a/scilab/modules/history_manager/tests/unit_tests/historysize.dia.ref b/scilab/modules/history_manager/tests/unit_tests/historysize.dia.ref
new file mode 100644 (file)
index 0000000..029a0a4
--- /dev/null
@@ -0,0 +1,25 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Allan CORNET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+savehistory(TMPDIR + "/historysize_backup"); // backup
+resethistory();
+assert_checkequal(historysize(), 0);
+fmterr = msprintf(gettext("%s: Wrong value for input argument #%d: ""%s"" expected.\n"),"historysize", 1, "max");
+assert_checkerror ("historysize(""toto"")", fmterr , 999 );
+assert_checkequal(historysize(100), 100);
+assert_checkequal(historysize("max"), 100);
+fmterr = msprintf(gettext("%s: Wrong value for input argument #%d.\n"),"historysize", 1);
+assert_checkerror ("historysize(-1)", fmterr , 999 );
+strs = string(1:1000);
+resethistory();
+addhistory(strs);
+savehistory(TMPDIR + "/historysize_tmp");
+resethistory();
+warning("off");
+loadhistory(TMPDIR + "/historysize_tmp");
+assert_checkequal(historysize(), 100 + 1);
+resethistory();
+loadhistory(TMPDIR + "/historysize_backup"); // restore
diff --git a/scilab/modules/history_manager/tests/unit_tests/historysize.tst b/scilab/modules/history_manager/tests/unit_tests/historysize.tst
new file mode 100644 (file)
index 0000000..3cefee8
--- /dev/null
@@ -0,0 +1,33 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Allan CORNET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+savehistory(TMPDIR + "/historysize_backup"); // backup
+
+resethistory();
+assert_checkequal(historysize(), 0);
+
+fmterr = msprintf(gettext("%s: Wrong value for input argument #%d: ""%s"" expected.\n"),"historysize", 1, "max");
+assert_checkerror ("historysize(""toto"")", fmterr , 999 );
+
+assert_checkequal(historysize(100), 100);
+assert_checkequal(historysize("max"), 100);
+
+fmterr = msprintf(gettext("%s: Wrong value for input argument #%d.\n"),"historysize", 1);
+assert_checkerror ("historysize(-1)", fmterr , 999 );
+
+strs = string(1:1000);
+resethistory();
+addhistory(strs);
+savehistory(TMPDIR + "/historysize_tmp");
+
+resethistory();
+warning("off");
+loadhistory(TMPDIR + "/historysize_tmp");
+assert_checkequal(historysize(), 100 + 1);
+
+resethistory();
+loadhistory(TMPDIR + "/historysize_backup"); // restore