Bug 12284 fixed: Completion in console could to a crash (or deadlock) 21/10421/2
Calixte DENIZET [Thu, 7 Feb 2013 11:16:54 +0000 (12:16 +0100)]
Change-Id: I01ff5da39f5a25b1a82ca5629867f2bf61fb6c49

scilab/CHANGES_5.4.X
scilab/modules/completion/src/c/completion.c
scilab/modules/console/src/java/org/scilab/modules/console/SciInputParsingManager.java

index 704d8df..17773e9 100644 (file)
@@ -350,6 +350,9 @@ Bug fixes
 
 * Bug #12272 fixed - Fix a presentation of Cyrillic letters on sample images of russian help page for grand function.
 
+* Bug #12284 fixed - Completion in console could to a crash (or deadlock).
+
+
                     Changes between version 5.3.3 and 5.4.0
                     =======================================
 
index c87cc3c..3ebd62d 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"
@@ -31,359 +31,362 @@ char **completionOnDictionary(char **dictionary,int sizedictionary,char *somecha
 /*--------------------------------------------------------------------------*/
 char **completion(char *somechars, int *sizeArrayReturned)
 {
-       char **ListWords = NULL;
+    char **ListWords = NULL;
 
-       char **dictionary = NULL;
-       int sizedictionary = 0;
+    char **dictionary = NULL;
+    int sizedictionary = 0;
 
-       int sizecompletionfunctions = 0;
-       char **completionfunctions = completionOnFunctions(somechars, &sizecompletionfunctions);
+    int sizecompletionfunctions = 0;
+    char **completionfunctions = completionOnFunctions(somechars, &sizecompletionfunctions);
 
-       int sizecompletioncommandwords = 0;
-       char **completioncommandwords = completionOnCommandWords(somechars, &sizecompletioncommandwords);
+    int sizecompletioncommandwords = 0;
+    char **completioncommandwords = completionOnCommandWords(somechars, &sizecompletioncommandwords);
 
-       int sizecompletionmacros = 0;
-       char **completionmacros =  completionOnMacros(somechars, &sizecompletionmacros);
+    int sizecompletionmacros = 0;
+    char **completionmacros =  completionOnMacros(somechars, &sizecompletionmacros);
 
-       int sizecompletionvariables = 0;
-       char **completionvariables = completionOnVariables(somechars, &sizecompletionvariables);
+    int sizecompletionvariables = 0;
+    char **completionvariables = completionOnVariables(somechars, &sizecompletionvariables);
 
-       int sizecompletionhandlegraphicsproperties = 0;
-       char **completionhandlegraphicsproperties = completionOnHandleGraphicsProperties(somechars, &sizecompletionhandlegraphicsproperties);
+    int sizecompletionhandlegraphicsproperties = 0;
+    char **completionhandlegraphicsproperties = completionOnHandleGraphicsProperties(somechars, &sizecompletionhandlegraphicsproperties);
 
-       int sizecompletionfiles = 0;
-       char **completionfiles = completionOnFiles(somechars, &sizecompletionfiles);
+    int sizecompletionfiles = 0;
+    char **completionfiles = completionOnFiles(somechars, &sizecompletionfiles);
 
-       *sizeArrayReturned = 0;
+    *sizeArrayReturned = 0;
 
-       sizedictionary = sizecompletionfunctions + sizecompletioncommandwords + sizecompletionmacros
-               + sizecompletionvariables + sizecompletionhandlegraphicsproperties + sizecompletionfiles;
+    sizedictionary = sizecompletionfunctions + sizecompletioncommandwords + sizecompletionmacros
+        + sizecompletionvariables + sizecompletionhandlegraphicsproperties + sizecompletionfiles;
 
 
-       if ( (completionfiles) && (sizedictionary == sizecompletionfiles) )
-       {
-               ListWords = completionfiles;
-               *sizeArrayReturned = sizecompletionfiles;
-       }
-       else
-       {
-               if (sizedictionary > 0) dictionary = (char**)MALLOC(sizeof(char*)*sizedictionary);
+    if ( (completionfiles) && (sizedictionary == sizecompletionfiles) )
+    {
+        ListWords = completionfiles;
+        *sizeArrayReturned = sizecompletionfiles;
+    }
+    else
+    {
+        if (sizedictionary > 0) dictionary = (char**)MALLOC(sizeof(char*)*sizedictionary);
 
-               if (dictionary)
-               {
-                       int i = 0;
-                       appendDictionary(&dictionary,&i,&completionfunctions,&sizecompletionfunctions);
-                       appendDictionary(&dictionary,&i,&completioncommandwords,&sizecompletioncommandwords);
-                       appendDictionary(&dictionary,&i,&completionmacros,&sizecompletionmacros);
-                       appendDictionary(&dictionary,&i,&completionvariables,&sizecompletionvariables);
-                       appendDictionary(&dictionary,&i,&completionhandlegraphicsproperties,&sizecompletionhandlegraphicsproperties);
-                       appendDictionary(&dictionary,&i,&completionfiles,&sizecompletionfiles);
+        if (dictionary)
+        {
+            int i = 0;
+            appendDictionary(&dictionary,&i,&completionfunctions,&sizecompletionfunctions);
+            appendDictionary(&dictionary,&i,&completioncommandwords,&sizecompletioncommandwords);
+            appendDictionary(&dictionary,&i,&completionmacros,&sizecompletionmacros);
+            appendDictionary(&dictionary,&i,&completionvariables,&sizecompletionvariables);
+            appendDictionary(&dictionary,&i,&completionhandlegraphicsproperties,&sizecompletionhandlegraphicsproperties);
+            appendDictionary(&dictionary,&i,&completionfiles,&sizecompletionfiles);
 
-                       dictionary = SortDictionary(dictionary,i);      
-                       dictionary = RemoveDuplicateDictionary(dictionary,&i);  
+            dictionary = SortDictionary(dictionary,i);
+            dictionary = RemoveDuplicateDictionary(dictionary,&i);
 
-                       sizedictionary = i;
-               }
-               ListWords = completionOnDictionary(dictionary,sizedictionary,somechars,sizeArrayReturned);
-               freePointerDictionary(dictionary,sizedictionary);
-       }
+            sizedictionary = i;
+        }
+        ListWords = completionOnDictionary(dictionary,sizedictionary,somechars,sizeArrayReturned);
+        freePointerDictionary(dictionary,sizedictionary);
+    }
 
-       return ListWords;
+    return ListWords;
 }
 /*--------------------------------------------------------------------------*/
 char **completionOnFunctions(char *somechars, int *sizeArrayReturned)
 {
-       char **ListWords = NULL;
-       char **dictionary = NULL;
-       int sizedictionary = 0;
-
-       dictionary = GetFunctionsList(&sizedictionary);
-
-       if (dictionary)
-       {
-               dictionary = SortDictionary(dictionary,sizedictionary); 
-               ListWords = completionOnDictionary(dictionary,sizedictionary,somechars,sizeArrayReturned);
-               freePointerDictionary(dictionary,sizedictionary);
-       }
-       else
-       {
-               *sizeArrayReturned = 0;
-       }
-       return ListWords;
+    char **ListWords = NULL;
+    char **dictionary = NULL;
+    int sizedictionary = 0;
+
+    dictionary = GetFunctionsList(&sizedictionary);
+
+    if (dictionary)
+    {
+        dictionary = SortDictionary(dictionary,sizedictionary);
+        ListWords = completionOnDictionary(dictionary,sizedictionary,somechars,sizeArrayReturned);
+        freePointerDictionary(dictionary,sizedictionary);
+    }
+    else
+    {
+        *sizeArrayReturned = 0;
+    }
+    return ListWords;
 }
 /*--------------------------------------------------------------------------*/
 char **completionOnCommandWords(char *somechars, int *sizeArrayReturned)
 {
-       char **ListWords = NULL;
-       char **dictionary = NULL;
-       int sizedictionary = 0;
-
-       dictionary = getcommandkeywords(&sizedictionary);
-
-       if (dictionary)
-       {
-               dictionary = SortDictionary(dictionary,sizedictionary); 
-               dictionary = RemoveDuplicateDictionary(dictionary,&sizedictionary);     
-               ListWords = completionOnDictionary(dictionary,sizedictionary,somechars,sizeArrayReturned);
-               freePointerDictionary(dictionary,sizedictionary);       
-       }
-       else
-       {
-               *sizeArrayReturned = 0;
-       }
-       return ListWords;
+    char **ListWords = NULL;
+    char **dictionary = NULL;
+    int sizedictionary = 0;
+
+    dictionary = getcommandkeywords(&sizedictionary);
+
+    if (dictionary)
+    {
+        dictionary = SortDictionary(dictionary,sizedictionary);
+        dictionary = RemoveDuplicateDictionary(dictionary,&sizedictionary);
+        ListWords = completionOnDictionary(dictionary,sizedictionary,somechars,sizeArrayReturned);
+        freePointerDictionary(dictionary,sizedictionary);
+    }
+    else
+    {
+        *sizeArrayReturned = 0;
+    }
+    return ListWords;
 }
 /*--------------------------------------------------------------------------*/
 char **completionOnMacros(char *somechars, int *sizeArrayReturned)
 {
-       char **ListWords = NULL;
-       char **dictionary = NULL;
-       int sizedictionary = 0;
-
-       dictionary = getmacrosdictionary(&sizedictionary);
-
-       if (dictionary)
-       {
-               dictionary = SortDictionary(dictionary,sizedictionary); 
-               dictionary = RemoveDuplicateDictionary(dictionary,&sizedictionary);     
-               ListWords = completionOnDictionary(dictionary,sizedictionary,somechars,sizeArrayReturned);
-               freePointerDictionary(dictionary,sizedictionary);
-       }
-       else
-       {
-               *sizeArrayReturned = 0;
-       }
-       return ListWords;
+    char **ListWords = NULL;
+    char **dictionary = NULL;
+    int sizedictionary = 0;
+
+    dictionary = getmacrosdictionary(&sizedictionary);
+
+    if (dictionary)
+    {
+        dictionary = SortDictionary(dictionary,sizedictionary);
+        dictionary = RemoveDuplicateDictionary(dictionary,&sizedictionary);
+        ListWords = completionOnDictionary(dictionary,sizedictionary,somechars,sizeArrayReturned);
+        freePointerDictionary(dictionary,sizedictionary);
+    }
+    else
+    {
+        *sizeArrayReturned = 0;
+    }
+    return ListWords;
 }
 /*--------------------------------------------------------------------------*/
 char **completionOnVariables(char *somechars, int *sizeArrayReturned)
 {
-       char **ListWords = NULL;
-       char **dictionary = NULL;
-       int sizedictionary = 0;
+    char **ListWords = NULL;
+    char **dictionary = NULL;
+    int sizedictionary = 0;
 
-       dictionary = getVariablesName(&sizedictionary,TRUE);
+    dictionary = getVariablesName(&sizedictionary,TRUE);
 
-       ListWords = completionOnDictionary(dictionary,sizedictionary,somechars,sizeArrayReturned);
-       freePointerDictionary(dictionary,sizedictionary);
+    ListWords = completionOnDictionary(dictionary,sizedictionary,somechars,sizeArrayReturned);
+    freePointerDictionary(dictionary,sizedictionary);
 
-       return ListWords;
+    return ListWords;
 }
 /*--------------------------------------------------------------------------*/
 char **completionOnVariablesWithoutMacros(char *somechars, int *sizeArrayReturned)
 {
-       int i = 0;
-       int j = 0;
-       int nbWordsAlreadyInMacros = 0;
-
-       char **ListWords = NULL;
-       int sizeListWords = 0;
-
-       char **dictionaryVariables = NULL;
-       int sizedictionaryVariables = 0;
-
-       dictionaryVariables = completionOnVariables(somechars,&sizedictionaryVariables);
-
-       if (sizedictionaryVariables)
-       {
-               char **dictionaryMacros = NULL;
-               int sizedictionaryMacros = 0;
-
-               dictionaryMacros = getmacrosdictionary(&sizedictionaryMacros);
-               dictionaryMacros = SortDictionary(dictionaryMacros, sizedictionaryMacros);      
-
-               /* Search if we have more than one definition */
-               for ( i = 0; i < sizedictionaryVariables; i++)
-               {
-                       for ( j = 0; j < sizedictionaryMacros; j++)
-                       {
-                               if ( strcmp(dictionaryVariables[i], dictionaryMacros[j]) == 0 )
-                               {
-                                       nbWordsAlreadyInMacros++;
-                               }
-                       }
-               }
-
-               if (nbWordsAlreadyInMacros)
-               {
-                       sizeListWords = sizedictionaryVariables - nbWordsAlreadyInMacros;
-                       if (sizeListWords > 0)
-                       {
-                               char **ListWordsTmp = (char**)MALLOC(sizeof(char*) * sizedictionaryVariables);
-                               if (ListWordsTmp)
-                               {
-                                       int k = 0;
-
-                                       /* do a copy of dictionary of Variables */
-                                       for ( i = 0; i < sizedictionaryVariables; i++)
-                                       {
-                                               ListWordsTmp[i] = strdup(dictionaryVariables[i]);
-                                       }
-
-                                       for ( i = 0; i < sizedictionaryVariables; i++)
-                                       {
-                                               for ( j = 0; j < sizedictionaryMacros; j++)
-                                               {
-                                                       if ( strcmp(dictionaryVariables[i],dictionaryMacros[j]) == 0 )
-                                                       {
-                                                               FREE(ListWordsTmp[i]);
-                                                               ListWordsTmp[i] = NULL;
-                                                       }
-                                               }
-                                       }
-
-                                       ListWords = (char**)MALLOC(sizeof(char*)*(sizeListWords+1));
-                                       if (ListWords)
-                                       {
-                                               for ( i = 0; i < sizedictionaryVariables; i++)
-                                               {
-                                                       if (ListWordsTmp[i])
-                                                       {
-                                                               ListWords[k] = strdup(ListWordsTmp[i]);
-                                                               if (k <= sizeListWords) k++;
-                                                       }
-                                               }
-                                               /* Add a NULL element at the end (to get number of items from JNI) */
-                                               ListWords[sizeListWords] = NULL;
-
-                                               *sizeArrayReturned = sizeListWords;
-                                       }
-                                       else
-                                       {
-                                               ListWords = NULL;
-                                               *sizeArrayReturned = 0;
-                                       }
-                               }
-                               else
-                               {
-                                       ListWords = NULL;
-                                       *sizeArrayReturned = 0;
-                               }
-                       }
-                       else
-                       {
-                               ListWords = NULL;
-                               *sizeArrayReturned = 0;
-                       }
-               }
-               else
-               {
-                       ListWords = dictionaryVariables;
-                       *sizeArrayReturned = sizedictionaryVariables;
-               }
-
-               freePointerDictionary(dictionaryMacros, sizedictionaryMacros);
-       }
-       else
-       {
-               ListWords = NULL;
-               *sizeArrayReturned = 0;
-       }
-
-       return ListWords;
+    int i = 0;
+    int j = 0;
+    int nbWordsAlreadyInMacros = 0;
+
+    char **ListWords = NULL;
+    int sizeListWords = 0;
+
+    char **dictionaryVariables = NULL;
+    int sizedictionaryVariables = 0;
+
+    dictionaryVariables = completionOnVariables(somechars,&sizedictionaryVariables);
+
+    if (sizedictionaryVariables)
+    {
+        char **dictionaryMacros = NULL;
+        int sizedictionaryMacros = 0;
+
+        dictionaryMacros = getmacrosdictionary(&sizedictionaryMacros);
+        dictionaryMacros = SortDictionary(dictionaryMacros, sizedictionaryMacros);
+
+        /* Search if we have more than one definition */
+        for ( i = 0; i < sizedictionaryVariables; i++)
+        {
+            for ( j = 0; j < sizedictionaryMacros; j++)
+            {
+                if ( strcmp(dictionaryVariables[i], dictionaryMacros[j]) == 0 )
+                {
+                    nbWordsAlreadyInMacros++;
+                }
+            }
+        }
+
+        if (nbWordsAlreadyInMacros)
+        {
+            sizeListWords = sizedictionaryVariables - nbWordsAlreadyInMacros;
+            if (sizeListWords > 0)
+            {
+                char **ListWordsTmp = (char**)MALLOC(sizeof(char*) * sizedictionaryVariables);
+                if (ListWordsTmp)
+                {
+                    int k = 0;
+
+                    /* do a copy of dictionary of Variables */
+                    for ( i = 0; i < sizedictionaryVariables; i++)
+                    {
+                        ListWordsTmp[i] = strdup(dictionaryVariables[i]);
+                    }
+
+                    for ( i = 0; i < sizedictionaryVariables; i++)
+                    {
+                        for ( j = 0; j < sizedictionaryMacros; j++)
+                        {
+                            if ( strcmp(dictionaryVariables[i],dictionaryMacros[j]) == 0 )
+                            {
+                                FREE(ListWordsTmp[i]);
+                                ListWordsTmp[i] = NULL;
+                            }
+                        }
+                    }
+
+                    ListWords = (char**)MALLOC(sizeof(char*)*(sizeListWords+1));
+                    if (ListWords)
+                    {
+                        for ( i = 0; i < sizedictionaryVariables; i++)
+                        {
+                            if (ListWordsTmp[i])
+                            {
+                                ListWords[k] = strdup(ListWordsTmp[i]);
+                                if (k <= sizeListWords) k++;
+                            }
+                        }
+                        /* Add a NULL element at the end (to get number of items from JNI) */
+                        ListWords[sizeListWords] = NULL;
+
+                        *sizeArrayReturned = sizeListWords;
+                    }
+                    else
+                    {
+                        ListWords = NULL;
+                        *sizeArrayReturned = 0;
+                    }
+                }
+                else
+                {
+                    ListWords = NULL;
+                    *sizeArrayReturned = 0;
+                }
+            }
+            else
+            {
+                ListWords = NULL;
+                *sizeArrayReturned = 0;
+            }
+        }
+        else
+        {
+            ListWords = dictionaryVariables;
+            *sizeArrayReturned = sizedictionaryVariables;
+        }
+
+        freePointerDictionary(dictionaryMacros, sizedictionaryMacros);
+    }
+    else
+    {
+        ListWords = NULL;
+        *sizeArrayReturned = 0;
+    }
+
+    return ListWords;
 }
 /*--------------------------------------------------------------------------*/
 char **completionOnFiles(char *somechars, int *sizeArrayReturned)
 {
-       char **ListWords = NULL;
-       char **dictionary = NULL;
-       int sizedictionary = 0;
-
-       dictionary = getfilesdictionary(somechars,&sizedictionary,FALSE);
-
-       if (dictionary)
-       {
-               ListWords = dictionary;
-               *sizeArrayReturned = sizedictionary;
-       }
-       else
-       {
-               *sizeArrayReturned = 0;
-       }
-       return ListWords;
+    char **ListWords = NULL;
+    char **dictionary = NULL;
+    int sizedictionary = 0;
+
+    dictionary = getfilesdictionary(somechars,&sizedictionary,FALSE);
+
+    if (dictionary)
+    {
+        ListWords = dictionary;
+        *sizeArrayReturned = sizedictionary;
+    }
+    else
+    {
+        *sizeArrayReturned = 0;
+    }
+    return ListWords;
 }
 /*--------------------------------------------------------------------------*/
 char **completionOnFields(char *lineBeforeCaret, char *pattern, int *sizeArrayReturned)
 {
-       char **ListWords = NULL;
-       char **dictionary = NULL;
-       int sizedictionary = 0;
-
-       dictionary = getfieldsdictionary(lineBeforeCaret, pattern, &sizedictionary);
-
-       if (dictionary)
-       {
-               ListWords = dictionary;
-               *sizeArrayReturned = sizedictionary;
-       }
-       else
-       {
-               *sizeArrayReturned = 0;
-       }
-       return ListWords;
+    char **ListWords = NULL;
+    char **dictionary = NULL;
+    int sizedictionary = 0;
+
+    if (lineBeforeCaret && pattern)
+    {
+        dictionary = getfieldsdictionary(lineBeforeCaret, pattern, &sizedictionary);
+    }
+
+    if (dictionary)
+    {
+        ListWords = dictionary;
+        *sizeArrayReturned = sizedictionary;
+    }
+    else
+    {
+        *sizeArrayReturned = 0;
+    }
+    return ListWords;
 }
 /*--------------------------------------------------------------------------*/
 char **completionOnHandleGraphicsProperties(char *somechars, int *sizeArrayReturned)
 {
-       char **ListWords = NULL;
-       char **dictionary = NULL;
-       int sizedictionary = 0;
-
-       int sizeHandleGraphicsGetPropertiesDictionary = 0;
-       char **HandleGraphicsGetPropertiesDictionary = getDictionaryGetProperties(&sizeHandleGraphicsGetPropertiesDictionary);
-
-       int sizeHandleGraphicsSetPropertiesDictionary = 0;
-       char **HandleGraphicsSetPropertiesDictionary = getDictionarySetProperties(&sizeHandleGraphicsSetPropertiesDictionary);
-
-       *sizeArrayReturned = 0;
-
-       sizedictionary = sizeHandleGraphicsGetPropertiesDictionary + sizeHandleGraphicsSetPropertiesDictionary;
-
-       if (sizedictionary > 0)
-       {
-               dictionary = (char**)MALLOC(sizeof(char*)*sizedictionary);
-
-               if (dictionary)
-               {
-                       int i = 0;
-
-                       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;
+    char **ListWords = NULL;
+    char **dictionary = NULL;
+    int sizedictionary = 0;
+
+    int sizeHandleGraphicsGetPropertiesDictionary = 0;
+    char **HandleGraphicsGetPropertiesDictionary = getDictionaryGetProperties(&sizeHandleGraphicsGetPropertiesDictionary);
+
+    int sizeHandleGraphicsSetPropertiesDictionary = 0;
+    char **HandleGraphicsSetPropertiesDictionary = getDictionarySetProperties(&sizeHandleGraphicsSetPropertiesDictionary);
+
+    *sizeArrayReturned = 0;
+
+    sizedictionary = sizeHandleGraphicsGetPropertiesDictionary + sizeHandleGraphicsSetPropertiesDictionary;
+
+    if (sizedictionary > 0)
+    {
+        dictionary = (char**)MALLOC(sizeof(char*)*sizedictionary);
+
+        if (dictionary)
+        {
+            int i = 0;
+
+            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;
 }
 /*--------------------------------------------------------------------------*/
 char **completionOnDictionary(char **dictionary,int sizedictionary,char *somechars,int *sizearrayreturned)
 {
-       char **ListWords = NULL;
-
-       if (dictionary)
-       {
-               ListWords = completion_generic(dictionary,sizedictionary,somechars,sizearrayreturned);
-               if (ListWords == NULL) *sizearrayreturned = 0;
-       }
-       else
-       {
-               *sizearrayreturned = 0;
-       }
-       return ListWords;
+    char **ListWords = NULL;
+
+    if (dictionary)
+    {
+        ListWords = completion_generic(dictionary,sizedictionary,somechars,sizearrayreturned);
+        if (ListWords == NULL) *sizearrayreturned = 0;
+    }
+    else
+    {
+        *sizearrayreturned = 0;
+    }
+    return ListWords;
 }
 /*--------------------------------------------------------------------------*/
index 79f605f..0c2e94d 100644 (file)
@@ -29,173 +29,173 @@ import org.scilab.modules.completion.Completion;
  */
 public class SciInputParsingManager implements InputParsingManager {
 
-       private InputCommandView inputCommandView;
-       private PromptView promptView;
-       private Point windowCompletionPosition;
-
-       /**
-        * Default constructor
-        */
-       public SciInputParsingManager() {
-               windowCompletionPosition = new Point(0, 0);
-       }
-
-       /**
-        * Append a string to the console input
-        * @param content the string to append
-        * @see com.artenum.rosetta.interfaces.core.InputParsingManager#append(java.lang.String)
-        */
-       public void append(String content) {
-               inputCommandView.append(content);
-       }
-
-       /**
-        * Get the position of the caret in the console input
-        * @return the position as an int value
-        * @see com.artenum.rosetta.interfaces.core.InputParsingManager#getCaretPosition()
-        */
-       public int getCaretPosition() {
-               return inputCommandView.getCaretPosition();
-       }
-
-       /**
-        * Read the text entered (by the user) in the console
-        * @return the text entered
-        * @see com.artenum.rosetta.interfaces.core.InputParsingManager#getCommandLine()
-        */
-       public String getCommandLine() {
-               return inputCommandView.getText();
-       }
-
-       /**
-        * Get the level to use for completion (which keywork we sould use for completion ?)
-        * @return the level
-        * @see com.artenum.rosetta.interfaces.core.InputParsingManager#getCompletionLevel()
-        */
-       public int getCompletionLevel() {
-               // Always zero for first implementation in Scilab
-               return 0;
-       }
-
-       /**
-        * Get the number of lines in the console input
-        * @return the number of lines
-        * @see com.artenum.rosetta.interfaces.core.InputParsingManager#getNumberOfLines()
-        */
-       public int getNumberOfLines() {
-               int result = inputCommandView.getText().split(StringConstants.NEW_LINE).length;
-               if (inputCommandView.getText().lastIndexOf(StringConstants.NEW_LINE) != -1) {
-                       result++;
-               }
-               return result;
-       }
-
-       /**
-        * Get the string to use for completion (see completion level)
-        * @param level the level used for completion
-        * @return the string to use as a keyword for completion
-        * @see com.artenum.rosetta.interfaces.core.InputParsingManager#getPartLevel(int)
-        */
-       public String getPartLevel(int level) {
-               String returnLine = null;
-               String wholeLine = getCommandLine();
-               int caretPos = getCaretPosition();
-
-               String lineToParse = wholeLine.substring(0, caretPos);
-               if (lineToParse.length() > 0) {
-                       returnLine = Completion.getPartLevel(lineToParse);
-               }
-               return returnLine;
-       }
-
-       /**
-        * Get the string to use for completion (see completion level)
-        * @param level the level used for completion
-        * @return the string to use as a keyword for completion
-        * @see com.artenum.rosetta.interfaces.core.InputParsingManager#getPartLevel(int)
-        */
-       public String getFilePartLevel(int level) {
-               String returnLine = null;
-               String wholeLine = getCommandLine();
-               int caretPos = getCaretPosition();
-               
-               String lineToParse = wholeLine.substring(0, caretPos);
-               if (lineToParse.length() > 0) {
-                       returnLine = Completion.getFilePartLevel(lineToParse);
-               }
-               return returnLine;
-       }
-
-       /**
-        * Get the position where the completion window has to be displayed
-        * @return the position
-        * @see com.artenum.rosetta.interfaces.core.InputParsingManager#getWindowCompletionLocation()
-        */
-       public Point getWindowCompletionLocation() {
-               windowCompletionPosition.setLocation(inputCommandView.getCaretLocation());
-               windowCompletionPosition.translate(-((JPanel) promptView).getWidth(), 0);
-               return windowCompletionPosition;
-       }
-
-       /**
-        * Is a block currently edited in the console input ?
-        * @return true if a block is currently edited (false else)
-        * @see com.artenum.rosetta.interfaces.core.InputParsingManager#isBlockEditing()
-        */
-       public boolean isBlockEditing() {
-               // FIXME : No block editing by default
-               return false;
-       }
-
-       /**
-        * Reset the input of the console (delete all entries)
-        * @see com.artenum.rosetta.interfaces.core.InputParsingManager#reset()
-        */
-       public void reset() {
-               inputCommandView.reset();
-       }
-
-       /**
-        * Set the input command view associated to this parsing manager
-        * @param inputCommandView the command view object to associate
-        * @see com.artenum.rosetta.interfaces.core.InputParsingManager#setInputCommandView(com.artenum.rosetta.interfaces.ui.InputCommandView)
-        */
-       public void setInputCommandView(InputCommandView inputCommandView) {
-               this.inputCommandView = inputCommandView;
-       }
-
-       /**
-        * Append the text selected in the completioon window to the console input
-        * @param completionResult the string to append
-        * @see com.artenum.rosetta.interfaces.core.InputParsingManager#writeCompletionPart(java.lang.String)
-        */
-       public void writeCompletionPart(String completionResult) {
-               // Add to the input view the end of the selected item
-               inputCommandView.append(completionResult.substring(getPartLevel(getCompletionLevel()).length()));
-       }
-
-       /**
-        * Delete the character just before the caret position
-        * @see com.artenum.rosetta.interfaces.core.InputParsingManager#backspace()
-        */
-       public void backspace() {
-               inputCommandView.backspace();
-       }
-
-       /**
-        * Get the prompt view associated to the parsing manager
-        * @return the promptView to associate
-        */
-       public PromptView getPromptView() {
-               return promptView;
-       }
-
-       /**
-        * Set the prompt view associated to the parsing manager
-        * @param promptView the promptView to set
-        */
-       public void setPromptView(PromptView promptView) {
-               this.promptView = promptView;
-       }
+    private InputCommandView inputCommandView;
+    private PromptView promptView;
+    private Point windowCompletionPosition;
+
+    /**
+     * Default constructor
+     */
+    public SciInputParsingManager() {
+        windowCompletionPosition = new Point(0, 0);
+    }
+
+    /**
+     * Append a string to the console input
+     * @param content the string to append
+     * @see com.artenum.rosetta.interfaces.core.InputParsingManager#append(java.lang.String)
+     */
+    public void append(String content) {
+        inputCommandView.append(content);
+    }
+
+    /**
+     * Get the position of the caret in the console input
+     * @return the position as an int value
+     * @see com.artenum.rosetta.interfaces.core.InputParsingManager#getCaretPosition()
+     */
+    public int getCaretPosition() {
+        return inputCommandView.getCaretPosition();
+    }
+
+    /**
+     * Read the text entered (by the user) in the console
+     * @return the text entered
+     * @see com.artenum.rosetta.interfaces.core.InputParsingManager#getCommandLine()
+     */
+    public String getCommandLine() {
+        return inputCommandView.getText();
+    }
+
+    /**
+     * Get the level to use for completion (which keywork we sould use for completion ?)
+     * @return the level
+     * @see com.artenum.rosetta.interfaces.core.InputParsingManager#getCompletionLevel()
+     */
+    public int getCompletionLevel() {
+        // Always zero for first implementation in Scilab
+        return 0;
+    }
+
+    /**
+     * Get the number of lines in the console input
+     * @return the number of lines
+     * @see com.artenum.rosetta.interfaces.core.InputParsingManager#getNumberOfLines()
+     */
+    public int getNumberOfLines() {
+        int result = inputCommandView.getText().split(StringConstants.NEW_LINE).length;
+        if (inputCommandView.getText().lastIndexOf(StringConstants.NEW_LINE) != -1) {
+            result++;
+        }
+        return result;
+    }
+
+    /**
+     * Get the string to use for completion (see completion level)
+     * @param level the level used for completion
+     * @return the string to use as a keyword for completion
+     * @see com.artenum.rosetta.interfaces.core.InputParsingManager#getPartLevel(int)
+     */
+    public String getPartLevel(int level) {
+        String returnLine = "";
+        String wholeLine = getCommandLine();
+        int caretPos = getCaretPosition();
+
+        String lineToParse = wholeLine.substring(0, caretPos);
+        if (lineToParse.length() > 0) {
+            returnLine = Completion.getPartLevel(lineToParse);
+        }
+        return returnLine;
+    }
+
+    /**
+     * Get the string to use for completion (see completion level)
+     * @param level the level used for completion
+     * @return the string to use as a keyword for completion
+     * @see com.artenum.rosetta.interfaces.core.InputParsingManager#getPartLevel(int)
+     */
+    public String getFilePartLevel(int level) {
+        String returnLine = null;
+        String wholeLine = getCommandLine();
+        int caretPos = getCaretPosition();
+
+        String lineToParse = wholeLine.substring(0, caretPos);
+        if (lineToParse.length() > 0) {
+            returnLine = Completion.getFilePartLevel(lineToParse);
+        }
+        return returnLine;
+    }
+
+    /**
+     * Get the position where the completion window has to be displayed
+     * @return the position
+     * @see com.artenum.rosetta.interfaces.core.InputParsingManager#getWindowCompletionLocation()
+     */
+    public Point getWindowCompletionLocation() {
+        windowCompletionPosition.setLocation(inputCommandView.getCaretLocation());
+        windowCompletionPosition.translate(-((JPanel) promptView).getWidth(), 0);
+        return windowCompletionPosition;
+    }
+
+    /**
+     * Is a block currently edited in the console input ?
+     * @return true if a block is currently edited (false else)
+     * @see com.artenum.rosetta.interfaces.core.InputParsingManager#isBlockEditing()
+     */
+    public boolean isBlockEditing() {
+        // FIXME : No block editing by default
+        return false;
+    }
+
+    /**
+     * Reset the input of the console (delete all entries)
+     * @see com.artenum.rosetta.interfaces.core.InputParsingManager#reset()
+     */
+    public void reset() {
+        inputCommandView.reset();
+    }
+
+    /**
+     * Set the input command view associated to this parsing manager
+     * @param inputCommandView the command view object to associate
+     * @see com.artenum.rosetta.interfaces.core.InputParsingManager#setInputCommandView(com.artenum.rosetta.interfaces.ui.InputCommandView)
+     */
+    public void setInputCommandView(InputCommandView inputCommandView) {
+        this.inputCommandView = inputCommandView;
+    }
+
+    /**
+     * Append the text selected in the completioon window to the console input
+     * @param completionResult the string to append
+     * @see com.artenum.rosetta.interfaces.core.InputParsingManager#writeCompletionPart(java.lang.String)
+     */
+    public void writeCompletionPart(String completionResult) {
+        // Add to the input view the end of the selected item
+        inputCommandView.append(completionResult.substring(getPartLevel(getCompletionLevel()).length()));
+    }
+
+    /**
+     * Delete the character just before the caret position
+     * @see com.artenum.rosetta.interfaces.core.InputParsingManager#backspace()
+     */
+    public void backspace() {
+        inputCommandView.backspace();
+    }
+
+    /**
+     * Get the prompt view associated to the parsing manager
+     * @return the promptView to associate
+     */
+    public PromptView getPromptView() {
+        return promptView;
+    }
+
+    /**
+     * Set the prompt view associated to the parsing manager
+     * @param promptView the promptView to set
+     */
+    public void setPromptView(PromptView promptView) {
+        this.promptView = promptView;
+    }
 
 }