pretty formatting with tabs for gnuplot reading
[yaz-moved-to-github.git] / util / yaz-asncomp
index 3e6bf21..c73adb7 100755 (executable)
@@ -3,10 +3,10 @@
 exec tclsh "$0" "$@"
 #
 # yaz-comp: ASN.1 Compiler for YAZ
-# (c) Index Data 1996-2003
+# (c) Index Data 1996-2004
 # See the file LICENSE for details.
 #
-# $Id: yaz-asncomp,v 1.1 2003-05-27 21:12:23 adam Exp $
+# $Id: yaz-asncomp,v 1.4 2004-11-01 20:16:44 adam Exp $
 #
 
 set yc_version 0.3
@@ -523,7 +523,8 @@ proc asnSequence {name tag implicit tagtype} {
 
         lappend l "\tif (!odr_sequence_begin (o, p, sizeof(**p), 0))"
         lappend l "\t\{"
-        lappend l "\t\t*p = 0;"
+       lappend l "\t\tif(o->direction == ODR_DECODE)"
+        lappend l "\t\t\t*p = 0;"
         lappend l "\t\treturn 0;"
         lappend l "\t\}"
     }
@@ -735,7 +736,8 @@ proc asnOf {name tag implicit tagtype isset} {
     }
     lappend j "\}"
     lappend l "\t\treturn 1;"
-    lappend l "\t*p = 0;"
+    lappend l "\tif(o->direction == ODR_DECODE)"
+    lappend l "\t\t*p = 0;"
     lappend l "\treturn odr_missing(o, opt, name);"
     return [list [join $l \n] [join $j \n]]
 }
@@ -840,8 +842,6 @@ proc asnChoice {name tag implicit tagtype} {
        lappend l "\todr_implicit_settag(o, $tagtype, $tag);"
        lappend l "\tif (odr_choice(o, arm, &(*p)->[lindex $uName 1], &(*p)->[lindex $uName 0], name))"
     } else {
-       lappend l "\tif (!*p && o->direction != ODR_DECODE)"
-       lappend l "\t\treturn opt;"
        lappend l "\tif (!odr_constructed_begin(o, p, $tagtype, $tag, 0))"
        lappend l "\t\treturn odr_missing(o, opt, name);"
        lappend l "\tif (!odr_initmember(o, p, sizeof(**p)))"
@@ -850,7 +850,10 @@ proc asnChoice {name tag implicit tagtype} {
        lappend l "\t\todr_constructed_end(o))"
     }
     lappend l "\t\treturn 1;"
-    lappend l "\t*p = 0;"
+
+    lappend l "\tif(o->direction == ODR_DECODE)"
+    lappend l "\t\t*p = 0;"
+
     lappend l "\treturn odr_missing(o, opt, name);"
     return [list [join $l \n] [join $j \n]]
 }
@@ -1387,8 +1390,8 @@ if {![info exists inf(iname)]} {
     puts "YAZ ASN.1 Compiler ${yc_version}"
     puts "Usage:"      
     puts -nonewline ${argv0}
-    puts { [-v] [-c cfile] [-h hfile] [-p hfile] [-d dfile] [-I iout] [-i idir]}
-    puts {    [-m module] file}
+    puts { [-v] [-c cfile] [-h hfile] [-p hfile] [-d dfile] [-I iout]}
+    puts {    [-i idir] [-m module] file}
     exit 1
 }