summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Fiorina <fiorinaf@gnutls.org>2003-09-18 19:33:44 +0000
committerFabio Fiorina <fiorinaf@gnutls.org>2003-09-18 19:33:44 +0000
commit15bc224d3ecdf8f7074d13eff46a1b06d699472f (patch)
tree4742d92c9387547e8c7c968c1867136de0094bca
parentf75e8e5f5e3f77b6b19bdfe625abb94ae3664088 (diff)
downloadlibtasn1-15bc224d3ecdf8f7074d13eff46a1b06d699472f.tar.gz
manage 'INTEGER(1 | 2)' syntaxlibtasn1_0_2_6
-rw-r--r--NEWS7
-rw-r--r--configure.in2
-rw-r--r--lib/ASN1.y27
-rw-r--r--lib/int.h2
-rw-r--r--lib/libtasn1.h2
-rw-r--r--src/asn1Coding.c1
-rw-r--r--tests/Test_parser.asn4
-rw-r--r--tests/Test_tree.c2
8 files changed, 33 insertions, 14 deletions
diff --git a/NEWS b/NEWS
index 041ea42..ccefa65 100644
--- 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.
diff --git a/configure.in b/configure.in
index a197fc3..94c9f94 100644
--- a/configure.in
+++ b/configure.in
@@ -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")
diff --git a/lib/ASN1.y b/lib/ASN1.y
index c90c8f8..136deac 100644
--- a/lib/ASN1.y
+++ b/lib/ASN1.y
@@ -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) */
}
}
diff --git a/lib/int.h b/lib/int.h
index 9aa0543..65d45eb 100644
--- 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
diff --git a/lib/libtasn1.h b/lib/libtasn1.h
index e1bb380..68d245a 100644
--- a/lib/libtasn1.h
+++ b/lib/libtasn1.h
@@ -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>
diff --git a/src/asn1Coding.c b/src/asn1Coding.c
index aaefe07..774547b 100644
--- a/src/asn1Coding.c
+++ b/src/asn1Coding.c
@@ -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;
diff --git a/tests/Test_parser.asn b/tests/Test_parser.asn
index e9b0ce9..42c6e4a 100644
--- a/tests/Test_parser.asn
+++ b/tests/Test_parser.asn
@@ -11,8 +11,8 @@ BEGIN
Sequence1 ::= SEQUENCE{
- int1 INTEGER,
- int2 INTEGER,
+ int1 -- Test -- INTEGER (5),
+ int2 INTEGER (10 | 12),
generic GeneralString
}
diff --git a/tests/Test_tree.c b/tests/Test_tree.c
index ea367c1..d25c28f 100644
--- a/tests/Test_tree.c
+++ b/tests/Test_tree.c
@@ -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)