manage 'INTEGER(1 | 2)' syntax
authorFabio Fiorina <fiorinaf@gnutls.org>
Thu, 18 Sep 2003 19:33:44 +0000 (19:33 +0000)
committerFabio Fiorina <fiorinaf@gnutls.org>
Thu, 18 Sep 2003 19:33:44 +0000 (19:33 +0000)
NEWS
configure.in
lib/ASN1.y
lib/int.h
lib/libtasn1.h
src/asn1Coding.c
tests/Test_parser.asn
tests/Test_tree.c

diff --git a/NEWS b/NEWS
index 041ea42..ccefa65 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,10 @@
+Version 0.2.6
+- ASN.1 parser accepts these kinds of integer definitions:
+  "INTEGER (5 | 10)" and
+  "INTEGER (5)"
+- Comments start at "--" and finish at the "end of line" or
+  with another "--". 
+
 Version 0.2.5
 - Bug fix in ordering procedure for SET OF and SEQUENCE OF
   types coding.
index a197fc3..94c9f94 100644 (file)
@@ -12,7 +12,7 @@ AC_DEFINE_UNQUOTED(T_OS, "$target_os")
 dnl libtasn1 Version
 ASN1_MAJOR_VERSION=0
 ASN1_MINOR_VERSION=2
-ASN1_MICRO_VERSION=5
+ASN1_MICRO_VERSION=6
 ASN1_VERSION=$ASN1_MAJOR_VERSION.$ASN1_MINOR_VERSION.$ASN1_MICRO_VERSION
 
 AC_DEFINE_UNQUOTED(ASN1_VERSION, "$ASN1_VERSION")
index c90c8f8..136deac 100644 (file)
@@ -16,7 +16,7 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
  */
-
 
 /*****************************************************/
 /* File: x509_ASN.y                                  */
@@ -107,7 +107,8 @@ int _asn1_yylex(void);
 %type <node> definitions_id Time bit_element bit_element_list set_def
 %type <node> tag_type tag type_assig_right_tag generalstring_def
 %type <node> type_assig_right_tag_default enumerated_def
-%type <str>  pos_num neg_num pos_neg_num pos_neg_identifier num_identifier 
+%type <str>  pos_num neg_num pos_neg_num pos_neg_identifier pos_neg_list 
+%type <str>  num_identifier 
 %type <constant> class explicit_implicit
 
 %%
@@ -192,10 +193,17 @@ default :  DEFAULT pos_neg_identifier {$$=_asn1_add_node(TYPE_DEFAULT);
          | DEFAULT FALSE          {$$=_asn1_add_node(TYPE_DEFAULT|CONST_FALSE);}
 ;
 
+
+pos_neg_list:  pos_neg_num                       
+            |  pos_neg_list '|' pos_neg_num  
+;
+
+
 integer_def: INTEGER                    {$$=_asn1_add_node(TYPE_INTEGER);}
            | INTEGER'{'constant_list'}' {$$=_asn1_add_node(TYPE_INTEGER|CONST_LIST);
                                         _asn1_set_down($$,$3);}
-           | integer_def'('num_identifier'.''.'num_identifier')'
+           | INTEGER'(' pos_neg_list ')' {$$=_asn1_add_node(TYPE_INTEGER);}
+           | INTEGER'('num_identifier'.''.'num_identifier')'
                                         {$$=_asn1_add_node(TYPE_INTEGER|CONST_MIN_MAX);
                                          _asn1_set_down($$,_asn1_add_node(TYPE_SIZE)); 
                                          _asn1_set_value(_asn1_get_down($$),$6,strlen($6)+1); 
@@ -412,7 +420,7 @@ const int key_word_token[]={ASSIG,OPTIONAL,INTEGER,SIZE,OCTET,STRING
 int 
 _asn1_yylex() 
 {
-  int c,counter=0,k;
+  int c,counter=0,k,lastc;
   char string[MAX_NAME_SIZE+1]; /* will contain the next token */  
 
   while(1)
@@ -427,7 +435,7 @@ _asn1_yylex()
 
     if(c=='(' || c==')' || c=='[' || c==']' || 
        c=='{' || c=='}' || c==',' || c=='.' ||
-       c=='+'){
+       c=='+' || c=='|'){
       lastToken[0]=c;lastToken[1]=0;
       return c;
     }
@@ -438,15 +446,18 @@ _asn1_yylex()
        return '-';
       }
       else{ /* Comments */
+       lastc=0;
        counter=0;
-       /* A comment finishes at the end of line */
-       while((c=fgetc(file_asn1))!=EOF && c!='\n');
+       /* A comment finishes at the next double hypen or the end of line */
+       while((c=fgetc(file_asn1))!=EOF && c!='\n' &&
+             (lastc!='-' || (lastc=='-' && c!='-')))
+         lastc=c;
        if(c==EOF){
          strcpy(lastToken,"End Of File");
          return 0;
        }
        else{
-         lineNumber++;
+         if(c=='\n') lineNumber++;
          continue; /* next char, please! (repeat the search) */
        }
       }
index 9aa0543..65d45eb 100644 (file)
--- a/lib/int.h
+++ b/lib/int.h
@@ -32,7 +32,7 @@
 
 #include <mem.h>
 
-#define LIBTASN1_VERSION "0.2.5"
+#define LIBTASN1_VERSION "0.2.6"
 
 #define MAX32 4294967295
 #define MAX24 16777215
index e1bb380..68d245a 100644 (file)
@@ -28,7 +28,7 @@
 extern "C" {
 #endif
 
-#define LIBTASN1_VERSION "0.2.5"
+#define LIBTASN1_VERSION "0.2.6"
 
 #include <sys/types.h>
 #include <time.h>
index aaefe07..774547b 100644 (file)
@@ -77,6 +77,7 @@ int readAssignment(FILE *file,char *varName, char *value){
 
   ret=fscanf(file,"%s",varName);
   if(ret==EOF) return ASSIGNMENT_EOF;
+  if(!strcmp(varName,"''")) varName[0]=0;
 
   ret=fscanf(file,"%s",value);
   if(ret==EOF) return ASSIGNMENT_ERROR;
index e9b0ce9..42c6e4a 100644 (file)
@@ -11,8 +11,8 @@ BEGIN
 
 
 Sequence1 ::= SEQUENCE{
-    int1     INTEGER,
-    int2     INTEGER,
+    int1  -- Test --   INTEGER (5),
+    int2     INTEGER (10 | 12),
     generic  GeneralString
 }
 
index ea367c1..d25c28f 100644 (file)
@@ -411,7 +411,7 @@ main(int argc,char *argv[])
   printf(    "/****************************************/\n\n");
 
   /* Check version */
-  if(asn1_check_version("0.2.5")==NULL)
+  if(asn1_check_version("0.2.6")==NULL)
     printf("\nLibrary version check ERROR:\n actual version: %s\n\n",asn1_check_version(NULL));
 
   if(1)