add getlanguagestable() &
Allan Cornet [Tue, 13 Feb 2007 18:25:39 +0000 (18:25 +0000)]
getlanguage('LANGUAGE_DEFAULT') returns en_US

scilab/modules/localization/Makefile.am
scilab/modules/localization/includes/gw_localization.h
scilab/modules/localization/sci_gateway/gw_localization.c
scilab/modules/localization/sci_gateway/localization
scilab/modules/localization/sci_gateway/sci_getlanguage.c
scilab/modules/localization/sci_gateway/sci_getlanguagestable.c [new file with mode: 0644]
scilab/modules/localization/src/localization.vcproj

index 221ad02..497e2c9 100644 (file)
@@ -10,7 +10,8 @@ src/setgetlanguage.c
 GATEWAY_C_SOURCES = sci_gateway/gw_localization.c \
 sci_gateway/sci_setlanguage.c \
 sci_gateway/sci_getlanguage.c \
-sci_gateway/sci_getlanguagealias.c
+sci_gateway/sci_getlanguagealias.c \
+sci_gateway/sci_getlanguagestable.c
 
 libscilocalization_la_CFLAGS=  -Iincludes/ -Isrc/ -I$(top_srcdir)/libs/MALLOC/includes/ -I$(top_srcdir)/libs/hashtable/ $(XML_FLAGS)
 
@@ -23,14 +24,9 @@ libscilocalization_la_SOURCES = $(LOCALIZATION_C_SOURCES) $(GATEWAY_C_SOURCES)
 libscilocalization_la_LIBADD =         $(top_builddir)/libs/MALLOC/libscimalloc.la \
 $(top_builddir)/libs/hashtable/libscihashtable.la
 
-
-
-
-
 #### Target ######
 target=$(datadir)/localization
 
-
 #### localization : Conf files ####
 libscilocalization_la_rootdir = $(target)
 libscilocalization_la_root_DATA = changelog.txt licence.txt readme.txt VERSION
index 647387b..2d256b9 100644 (file)
@@ -20,6 +20,7 @@ typedef int (*localization_interf) __PARAMS((char *fname,unsigned long fname_len
 int C2F(sci_setlanguage) _PARAMS((char *fname,unsigned long fname_len));
 int C2F(sci_getlanguage) _PARAMS((char *fname,unsigned long fname_len));
 int C2F(sci_getlanguagealias) _PARAMS((char *fname,unsigned long fname_len));
+int C2F(sci_getlanguagestable) _PARAMS((char *fname,unsigned long fname_len));
 
 int C2F(gw_localization)(void);
 
index e693d87..ef040b9 100644 (file)
@@ -13,7 +13,8 @@ static LocalizationTable Tab[]=
 {
        {C2F(sci_setlanguage),"setlanguage"},
        {C2F(sci_getlanguage),"getlanguage"},
-       {C2F(sci_getlanguagealias),"getlanguagealias"}
+       {C2F(sci_getlanguagealias),"getlanguagealias"},
+       {C2F(sci_getlanguagestable),"getlanguagestable"}
 };
 /*-----------------------------------------------------------------------------------*/
 int C2F(gw_localization)()
index 02b6a2b..bd69678 100644 (file)
@@ -9,4 +9,5 @@
 50 1 setlanguage
 50 2 getlanguage
 50 3 getlanguagealias
+50 4 getlanguagestable
 ; --------------------------
index 9df51a9..1a2a82f 100644 (file)
@@ -4,6 +4,8 @@
 /*-----------------------------------------------------------------------------------*/ 
 #include "sci_getlanguage.h"
 #include "setgetlanguage.h"
+#include "../src/tableslanguages.h"
+#include "Scierror.h"
 #include "MALLOC.h"
 /*-----------------------------------------------------------------------------------*/ 
 int C2F(sci_getlanguage) _PARAMS((char *fname,unsigned long fname_len))
@@ -11,11 +13,40 @@ int C2F(sci_getlanguage) _PARAMS((char *fname,unsigned long fname_len))
        static int l1,n1,m1;
        char *Output=NULL;
 
-       CheckRhs(0,0);
+       CheckRhs(0,1);
        CheckLhs(0,1);
 
-       Output=getlanguage();
+       if (Rhs == 1)
+       {
+               if (GetType(1) == sci_strings)
+               {
+                       char *param=NULL;
 
+                       GetRhsVar(1,"c",&m1,&n1,&l1);
+                       param=cstk(l1);
+
+                       if (strcmp(param,"LANGUAGE_DEFAULT")==0)
+                       {
+                               Output=(char*)MALLOC(sizeof(char)*(strlen(SCILABDEFAULTLANGUAGE)+1));
+                               strcpy(Output,SCILABDEFAULTLANGUAGE);
+                       }
+                       else
+                       {
+                               Scierror(999,"invalid parameter. see 'help getlanguage'.\n\n");
+                               return 0;
+                       }
+               }
+               else
+               {
+                       Scierror(999,"invalid parameter. see 'help getlanguage'.\n\n");
+                       return 0;
+               }
+       }
+       else
+       {
+               Output=getlanguage();
+       }
+       
        n1=1;
        CreateVarFromPtr( 1, "c",(m1=(int)strlen(Output), &m1),&n1,&Output);
        LhsVar(1) = 1;
diff --git a/scilab/modules/localization/sci_gateway/sci_getlanguagestable.c b/scilab/modules/localization/sci_gateway/sci_getlanguagestable.c
new file mode 100644 (file)
index 0000000..b32e3ec
--- /dev/null
@@ -0,0 +1,57 @@
+/*-----------------------------------------------------------------------------------*/\r
+/* INRIA 2007 */\r
+/* Allan CORNET */\r
+/*-----------------------------------------------------------------------------------*/ \r
+#include "sci_getlanguage.h"\r
+#include "setgetlanguage.h"\r
+#include "../src/tableslanguages.h"\r
+#include "MALLOC.h"\r
+/*-----------------------------------------------------------------------------------*/ \r
+int C2F(sci_getlanguagestable) _PARAMS((char *fname,unsigned long fname_len))\r
+{\r
+       static int l1,n1,m1;\r
+       char **Output=NULL;\r
+\r
+       int i=0;\r
+\r
+       CheckRhs(0,0);\r
+       CheckLhs(0,1);\r
+\r
+       Output=(char**)MALLOC(sizeof(char*)*2* NumberLanguages);\r
+       \r
+       for (i=0;i<NumberLanguages;i++)\r
+       {\r
+               char *alphacode=NULL;\r
+               char *language=NULL;\r
+\r
+               alphacode=(char*)MALLOC((strlen(LANGUAGE_COUNTRY_TAB[i].alphacode)+1)*sizeof(char));\r
+               strcpy(alphacode,LANGUAGE_COUNTRY_TAB[i].alphacode);\r
+\r
+               language=(char*)MALLOC((strlen(LANGUAGE_COUNTRY_TAB[i].languagedescription)+1)*sizeof(char));\r
+               strcpy(language,LANGUAGE_COUNTRY_TAB[i].languagedescription);\r
+\r
+               Output[i]=alphacode;\r
+               Output[NumberLanguages+i]=language;\r
+\r
+       }\r
+       \r
+       m1=NumberLanguages;\r
+       n1=2;\r
+       CreateVarFromPtr( 1, "S",&m1,&n1,Output);\r
+       LhsVar(1) = 1;\r
+       C2F(putlhsvar)();       \r
+\r
+       if (Output) \r
+       {\r
+               for (i=0;i<NumberLanguages;i++)\r
+               {\r
+                       FREE(Output[i]);\r
+                       Output[i]=NULL;\r
+                       FREE(Output[NumberLanguages+i]);\r
+                       Output[NumberLanguages+i]=NULL;\r
+               }\r
+       }\r
+\r
+       return 0;\r
+}\r
+/*-----------------------------------------------------------------------------------*/ \r
index b1111b3..33dbb90 100644 (file)
                                >
                        </File>
                        <File
+                               RelativePath="..\sci_gateway\sci_getlanguagestable.c"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\sci_gateway\sci_setlanguage.c"
                                >
                        </File>