More malformed patterns using -f xsd

I use libsmi 0.4.5. When I have a textual convention like this one:
1) NiceString1 ::= TEXTUAL-CONVENTION DISPLAY-HINT "2d" STATUS current DESCRIPTION "doc" SYNTAX OCTET STRING (SIZE (2))
the pattern which "dumpsmi -f xsd" translates the display hint into is:
((0|[1-9]([0-9]{0,5}))
which has unbalanced parentheses.
I think that line 655 smiAsprintf( &ret, "%s(0|[1-9]([0-9]{0,%d})", should be smiAsprintf( &ret, "%s(0|[1-9]([0-9]{0,%d}))",
2) Similar problem here:
NiceString2 ::= TEXTUAL-CONVENTION DISPLAY-HINT "4d" STATUS current DESCRIPTION "doc" SYNTAX OCTET STRING (SIZE (0..2 | 4..5))
The pattern: (((0|[1-9]([0-9]{0,5}))|((0|[1-9]([0-9]{0,10})))
I think that line 726 if( ! lengths[ i - 2 ] ) { should be if( ! lengths[0] ) {
(The fix from problem 2 is needed too here.)
3) A third problem with patterns from display hints is that a period (.) is not always escaped with a backslash (.) (for example with the display hint "1x."). My suggested fix is to use a two-character char array for 'separator', and insert the '' already when the separator is set from the hint. Then no tests are needed further down, but the %c changed to %s.

Hi Arndt!
Arndt Jonasson schrieb:
I use libsmi 0.4.5. When I have a textual convention like this one:
- NiceString1 ::= TEXTUAL-CONVENTION DISPLAY-HINT "2d" STATUS current DESCRIPTION "doc" SYNTAX OCTET STRING (SIZE (2))
the pattern which "dumpsmi -f xsd" translates the display hint into is:
((0|[1-9]([0-9]{0,5}))
which has unbalanced parentheses.
I think that line 655 smiAsprintf( &ret, "%s(0|[1-9]([0-9]{0,%d})", should be smiAsprintf( &ret, "%s(0|[1-9]([0-9]{0,%d}))",
This should be fixed by the quick-fix.
- Similar problem here:
NiceString2 ::= TEXTUAL-CONVENTION DISPLAY-HINT "4d" STATUS current DESCRIPTION "doc" SYNTAX OCTET STRING (SIZE (0..2 | 4..5))
The pattern: (((0|[1-9]([0-9]{0,5}))|((0|[1-9]([0-9]{0,10})))
I think that line 726 if( ! lengths[ i - 2 ] ) { should be if( ! lengths[0] ) {
(The fix from problem 2 is needed too here.)
You are right. Thanks, I have changed that line.
- A third problem with patterns from display hints is that a period
(.) is not always escaped with a backslash (.) (for example with the display hint "1x."). My suggested fix is to use a two-character char array for 'separator', and insert the '' already when the separator is set from the hint. Then no tests are needed further down, but the %c changed to %s.
Fixed. Thanks for the hint.
Best regards, Torsten

Arndt Jonasson writes:
- A third problem with patterns from display hints is that a period
(.) is not always escaped with a backslash (.) (for example with the display hint "1x."). My suggested fix is to use a two-character char array for 'separator', and insert the '' already when the separator is set from the hint. Then no tests are needed further down, but the %c changed to %s.
I see that my suggestion made it into the repository. Unfortunately, my suggestion had a bug: the array needs to be three characters long, since sometimes an additional backslash (to quote a period) is stored there.
So (in dump-xsd.c), char separator[3]; and dh->separator[0] = '\0'; dh->separator[1] = '\0'; dh->separator[2] = '\0';
participants (2)
-
Arndt Jonasson
-
Torsten Klie