bug 4626
Allan CORNET [Thu, 2 Jul 2009 07:14:10 +0000 (09:14 +0200)]
scilab/CHANGES_5.2.X
scilab/modules/completion/src/c/completion.c
scilab/modules/completion/tests/nonreg_tests/bug_4626.dia.ref [new file with mode: 0644]
scilab/modules/completion/tests/nonreg_tests/bug_4626.tst [new file with mode: 0644]

index 83f0aa1..73d43e4 100644 (file)
@@ -272,3 +272,6 @@ Bug fixes:
 * bug 4606 fixed - example of 'link' in help does not work
 
 * bug 4611 fixed - what function doesn't returns a complete list of functions.
+
+* bug 4626 fixed - when using the CLI version, completion make Scilab crash
+
index 7b5d370..90e4406 100644 (file)
@@ -1,14 +1,14 @@
 /*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007 - 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 - 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
+*
+*/
 #include <string.h>
 #include <stdlib.h>
 #include "completion.h"
@@ -35,30 +35,30 @@ char **completion(char *somechars, int *sizeArrayReturned)
 
        char **dictionary = NULL;
        int sizedictionary = 0;
-       
+
        int sizecompletionfunctions = 0;
        char **completionfunctions = completionOnFunctions(somechars, &sizecompletionfunctions);
-       
+
        int sizecompletioncommandwords = 0;
        char **completioncommandwords = completionOnCommandWords(somechars, &sizecompletioncommandwords);
-       
+
        int sizecompletionmacros = 0;
        char **completionmacros =  completionOnMacros(somechars, &sizecompletionmacros);
-       
+
        int sizecompletionvariables = 0;
        char **completionvariables = completionOnVariables(somechars, &sizecompletionvariables);
 
        int sizecompletionhandlegraphicsproperties = 0;
        char **completionhandlegraphicsproperties = completionOnHandleGraphicsProperties(somechars, &sizecompletionhandlegraphicsproperties);
-       
+
        int sizecompletionfiles = 0;
        char **completionfiles = completionOnFiles(somechars, &sizecompletionfiles);
-       
+
        *sizeArrayReturned = 0;
-       
+
        sizedictionary = sizecompletionfunctions + sizecompletioncommandwords + sizecompletionmacros
-                                       + sizecompletionvariables + sizecompletionhandlegraphicsproperties + sizecompletionfiles;
-       
+               + sizecompletionvariables + sizecompletionhandlegraphicsproperties + sizecompletionfiles;
+
 
        if ( (completionfiles) && (sizedictionary == sizecompletionfiles) )
        {
@@ -181,7 +181,7 @@ char **completionOnVariablesWithoutMacros(char *somechars, int *sizeArrayReturne
 
        char **dictionaryVariables = NULL;
        int sizedictionaryVariables = 0;
-       
+
 
        dictionaryVariables = completionOnVariables(somechars,&sizedictionaryVariables);
 
@@ -192,7 +192,7 @@ char **completionOnVariablesWithoutMacros(char *somechars, int *sizeArrayReturne
 
                dictionaryMacros = getmacrosdictionary(&sizedictionaryMacros);
                dictionaryMacros = SortDictionary(dictionaryMacros,sizedictionaryMacros);       
-       
+
                /* Search if we have more than one definition */
                for ( i = 0; i < sizedictionaryVariables; i++)
                {
@@ -320,29 +320,35 @@ char **completionOnHandleGraphicsProperties(char *somechars, int *sizeArrayRetur
 
        sizedictionary = sizeHandleGraphicsGetPropertiesDictionary + sizeHandleGraphicsSetPropertiesDictionary;
 
-       dictionary = (char**)MALLOC(sizeof(char*)*sizedictionary);
-
-       if (dictionary)
+       if (sizedictionary > 0)
        {
-               int i = 0;
+               dictionary = (char**)MALLOC(sizeof(char*)*sizedictionary);
 
-               appendDictionary(&dictionary,&i,&HandleGraphicsGetPropertiesDictionary,&sizeHandleGraphicsGetPropertiesDictionary);
-               appendDictionary(&dictionary,&i,&HandleGraphicsSetPropertiesDictionary,&sizeHandleGraphicsSetPropertiesDictionary);
-               sizedictionary = i;
-       }
+               if (dictionary)
+               {
+                       int i = 0;
 
-       if (dictionary)
-       {
-               dictionary = SortDictionary(dictionary,sizedictionary); 
-               dictionary = RemoveDuplicateDictionary(dictionary,&sizedictionary);     
-               ListWords = completionOnDictionary(dictionary,sizedictionary,somechars,sizeArrayReturned);
-               freePointerDictionary(dictionary,sizedictionary);
+                       appendDictionary(&dictionary,&i,&HandleGraphicsGetPropertiesDictionary,&sizeHandleGraphicsGetPropertiesDictionary);
+                       appendDictionary(&dictionary,&i,&HandleGraphicsSetPropertiesDictionary,&sizeHandleGraphicsSetPropertiesDictionary);
+                       sizedictionary = i;
+               }
+
+               if (dictionary)
+               {
+                       dictionary = SortDictionary(dictionary,sizedictionary); 
+                       dictionary = RemoveDuplicateDictionary(dictionary,&sizedictionary);     
+                       ListWords = completionOnDictionary(dictionary,sizedictionary,somechars,sizeArrayReturned);
+                       freePointerDictionary(dictionary,sizedictionary);
+               }
+               else
+               {
+                       *sizeArrayReturned = 0;
+               }
        }
        else
        {
                *sizeArrayReturned = 0;
        }
-
        return ListWords;
 }
 /*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/completion/tests/nonreg_tests/bug_4626.dia.ref b/scilab/modules/completion/tests/nonreg_tests/bug_4626.dia.ref
new file mode 100644 (file)
index 0000000..52841f6
--- /dev/null
@@ -0,0 +1,17 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - Allan CORNET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 4626 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4626
+//
+// <-- Short Description -->
+// 
+// when using the CLI version (NO GRAPHICS), the autocompletion feature make Scilab crash
+// <-- JVM NOT MANDATORY -->
+r = completion('a','graphic_properties');
+if ~isdef('r') then bugmes();quit;end
diff --git a/scilab/modules/completion/tests/nonreg_tests/bug_4626.tst b/scilab/modules/completion/tests/nonreg_tests/bug_4626.tst
new file mode 100644 (file)
index 0000000..fa46f7e
--- /dev/null
@@ -0,0 +1,20 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - Allan CORNET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 4626 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4626
+//
+// <-- Short Description -->
+// 
+// when using the CLI version (NO GRAPHICS), the autocompletion feature make Scilab crash
+
+
+// <-- JVM NOT MANDATORY -->
+r = completion('a','graphic_properties');
+if ~isdef('r') then pause,end