Image-PNG-Simple

 view release on metacpan or  search on metacpan

libpng-1.6.17/scripts/options.awk  view on Meta::CPAN

#   least one of the options listed after 'if' is set.  If the
#   option is set then it turns on all the options listed after 'enables'.
#
#   Note that "enables" takes priority over the required/if/disabled/off
#   setting of the target option.
#
#   The definition file may list an option as 'disabled': off by default,
#   otherwise the option is enabled: on by default.  A later (and it must
#   be later) entry may turn an option on or off explicitly.

$1 == "option" && NF >= 2{
   opt = $2
   sub(/,$/,"",opt)
   onoff = option[opt]  # records current (and the default is "", enabled)
   key = ""
   istart = 3
   do {
      if (istart == 1) {     # continuation line
         val = getline

         if (val != 1) { # error reading it
            if (val == 0)
               print "option", opt ": ERROR: missing continuation line"
            else
               print "option", opt ": ERROR: error reading continuation line"

            # This is a hard error
            err = 1 # prevent END{} running
            exit 1
         }
      }

      for (i=istart; i<=NF; ++i) {
         val=$(i)
         sub(/,$/,"",val)
         if (val == "on" || val == "off" || val == "disabled" || val =="enabled") {
            key = ""
            if (onoff != val) {
               # on or off can zap disabled or enabled:
               if (onoff == "" || (onoff == "disabled" || onoff == "enabled") &&
                   (val == "on" || val == "off")) {
                  # It's easy to mis-spell the option when turning it
                  # on or off, so warn about it here:
                  if (onoff == "" && (val == "on" || val == "off")) {
                     print "option", opt ": ERROR: turning unrecognized option", val
                     # For the moment error out - it is safer
                     err = 1 # prevent END{} running
                     exit 1
                  }
                  onoff = val
               } else {
                  # Print a message, otherwise the error
                  # below is incomprehensible
                  print "option", opt ": currently", onoff ": attempt to turn", val
                  break
               }
            }
         } else if (val == "requires" || val == "if" || val == "enables" || val =="sets") {
            key = val
         } else if (key == "requires") {
            requires[opt] = requires[opt] " " val
         } else if (key == "if") {
            iffs[opt] = iffs[opt] " " val
         } else if (key == "enables") {
            enabledby[val] = enabledby[val] " " opt
         } else if (key == "sets") {
            sets[opt] = sets[opt] " " val
            key = "setval"
            set = val
         } else if (key == "setval") {
            setval[opt " " set] = setval[opt " " set] " " val
         } else
            break # bad line format
      }

      istart = 1
   } while (i > NF && $0 ~ /,$/)

   if (i > NF) {
      # Set the option, defaulting to 'enabled'
      if (onoff == "") onoff = "enabled"
      option[opt] = onoff
      next
   }
   # Else fall through to the error handler
}

# chunk NAME [requires OPT] [enables LIST] [on|off|disabled]
#   Expands to the 'option' settings appropriate to the reading and
#   writing of an ancilliary PNG chunk 'NAME':
#
#   option READ_NAME requires READ_ANCILLARY_CHUNKS [READ_OPT]
#   option READ_NAME enables NAME LIST
#   [option READ_NAME off]
#   option WRITE_NAME requires WRITE_ANCILLARY_CHUNKS [WRITE_OPT]
#   option WRITE_NAME enables NAME LIST
#   [option WRITE_NAME off]

pre != 0 && $1 == "chunk" && NF >= 2{
   # 'chunk' is handled on the first pass by writing appropriate
   # 'option' lines into the intermediate file.
   opt = $2
   sub(/,$/,"",opt)
   onoff = ""
   reqread = ""
   reqwrite = ""
   enables = ""
   req = 0
   istart = 3
   do {
      if (istart == 1) {     # continuation line
         val = getline

         if (val != 1) { # error reading it
            if (val == 0)
               print "chunk", opt ": ERROR: missing continuation line"
            else
               print "chunk", opt ": ERROR: error reading continuation line"

            # This is a hard error
            err = 1 # prevent END{} running



( run in 1.029 second using v1.01-cache-2.11-cpan-39bf76dae61 )