[libpng16] scripts/pnglibconf.dfa formatting improvements back ported from libpng 1.7.

This commit is contained in:
John Bowler 2013-02-16 00:18:20 -06:00 committed by Glenn Randers-Pehrson
parent b724c812ec
commit 23a101e06d
4 changed files with 128 additions and 75 deletions

View File

@ -36,6 +36,7 @@ Version 1.6.1 [February 16, 2013]
Since all .dfn output is now protected in double quotes unless it is to be macro Since all .dfn output is now protected in double quotes unless it is to be macro
substituted the fix should work everywhere. substituted the fix should work everywhere.
Enabled parallel tests - back ported from libpng-1.7. Enabled parallel tests - back ported from libpng-1.7.
scripts/pnglibconf.dfa formatting improvements back ported from libpng 1.7.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

View File

@ -4392,6 +4392,7 @@ Version 1.6.1 [February 16, 2013]
Since all .dfn output is now protected in double quotes unless it is to be macro Since all .dfn output is now protected in double quotes unless it is to be macro
substituted the fix should work everywhere. substituted the fix should work everywhere.
Enabled parallel tests - back ported from libpng-1.7. Enabled parallel tests - back ported from libpng-1.7.
scripts/pnglibconf.dfa formatting improvements back ported from libpng 1.7.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

View File

@ -252,46 +252,71 @@ $1 == "file" && NF >= 2{
# be later) entry may turn an option on or off explicitly. # be later) entry may turn an option on or off explicitly.
$1 == "option" && NF >= 2{ $1 == "option" && NF >= 2{
onoff = option[$2] # records current (and the default is "", enabled) opt = $2
sub(/,$/,"",opt)
onoff = option[opt] # records current (and the default is "", enabled)
key = "" key = ""
for (i=3; i<=NF; ++i) { istart = 3
if ($(i) == "on" || $(i) == "off" || $(i) == "disabled") { do {
if (istart == 1) { # continuation line
val = getline
if (val != 1) { # error reading it
if (val == 0)
print "option", opt ": ERROR: missing contination 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") {
key = "" key = ""
if (onoff != $(i)) { if (onoff != val) {
# on or off can zap disabled or enabled: # on or off can zap disabled or enabled:
if (onoff == "" || (onoff == "disabled" || onoff == "enabled") && ($(i) == "on" || $(i) == "off")) { if (onoff == "" || (onoff == "disabled" || onoff == "enabled") &&
(val == "on" || val == "off")) {
# It's easy to mis-spell the option when turning it # It's easy to mis-spell the option when turning it
# on or off, so warn about it here: # on or off, so warn about it here:
if (onoff == "" && ($(i) == "on" || $(i) == "off")) { if (onoff == "" && (val == "on" || val == "off")) {
print $2 ": ERROR: turning unrecognized option", $(i) print "option", opt ": ERROR: turning unrecognized option", val
# For the moment error out - it is safer # For the moment error out - it is safer
err = 1 # prevent END{} running err = 1 # prevent END{} running
exit 1 exit 1
} }
onoff = $(i) onoff = val
} else { } else {
# Print a message, otherwise the error # Print a message, otherwise the error
# below is incomprehensible # below is incomprehensible
print $2 ": currently", onoff ": attempt to turn", $(i) print "option", opt ": currently", onoff ": attempt to turn", val
break break
} }
} }
} else if ($(i) == "requires" || $(i) == "if" || $(i) == "enables") { } else if (val == "requires" || val == "if" || val == "enables") {
key = $(i) key = val
} else if (key == "requires") { } else if (key == "requires") {
requires[$2] = requires[$2] " " $(i) requires[opt] = requires[opt] " " val
} else if (key == "if") { } else if (key == "if") {
iffs[$2] = iffs[$2] " " $(i) iffs[opt] = iffs[opt] " " val
} else if (key == "enables") { } else if (key == "enables") {
enabledby[$(i)] = enabledby[$(i)] " " $2 enabledby[val] = enabledby[val] " " opt
} else } else
break # bad line format break # bad line format
} }
istart = 1
} while (i > NF && $0 ~ /,$/)
if (i > NF) { if (i > NF) {
# Set the option, defaulting to 'enabled' # Set the option, defaulting to 'enabled'
if (onoff == "") onoff = "enabled" if (onoff == "") onoff = "enabled"
option[$2] = onoff option[opt] = onoff
next next
} }
# Else fall through to the error handler # Else fall through to the error handler
@ -311,41 +336,62 @@ $1 == "option" && NF >= 2{
pre != 0 && $1 == "chunk" && NF >= 2{ pre != 0 && $1 == "chunk" && NF >= 2{
# 'chunk' is handled on the first pass by writing appropriate # 'chunk' is handled on the first pass by writing appropriate
# 'option' lines into the intermediate file. # 'option' lines into the intermediate file.
opt = $2
sub(/,$/,"",opt)
onoff = "" onoff = ""
reqread = "" reqread = ""
reqwrite = "" reqwrite = ""
enables = "" enables = ""
i = 3 # indicates format error
if (NF > 2) {
# read the keywords/additional OPTS
req = 0 req = 0
for (i=3; i<=NF; ++i) { istart = 3
if ($(i) == "on" || $(i) == "off" || $(i) == "disabled") { do {
if (onoff != $(i)) { if (istart == 1) { # continuation line
val = getline
if (val != 1) { # error reading it
if (val == 0)
print "chunk", opt ": ERROR: missing contination line"
else
print "chunk", opt ": ERROR: error reading continuation line"
# This is a hard error
err = 1 # prevent END{} running
exit 1
}
}
# read the keywords/additional OPTS
for (i=istart; i<=NF; ++i) {
val = $(i)
sub(/,$/,"",val)
if (val == "on" || val == "off" || val == "disabled") {
if (onoff != val) {
if (onoff == "") if (onoff == "")
onoff = $(i) onoff = val
else else
break # on/off conflict break # on/off conflict
} }
req = 0 req = 0
} else if ($(i) == "requires") } else if (val == "requires")
req = 1 req = 1
else if ($(i) == "enables") else if (val == "enables")
req = 2 req = 2
else if (req == 1){ else if (req == 1){
reqread = reqread " READ_" $(i) reqread = reqread " READ_" val
reqwrite = reqwrite " WRITE_" $(i) reqwrite = reqwrite " WRITE_" val
} else if (req == 2) } else if (req == 2)
enables = enables " " $(i) enables = enables " " val
else else
break # bad line: handled below break # bad line: handled below
} }
}
istart = 1
} while (i > NF && $0 ~ /,$/)
if (i > NF) { if (i > NF) {
# Output new 'option' lines to the intermediate file (out) # Output new 'option' lines to the intermediate file (out)
print "option READ_" $2, "requires READ_ANCILLARY_CHUNKS" reqread, "enables", $2 enables , onoff >out print "option READ_" opt, "requires READ_ANCILLARY_CHUNKS" reqread, "enables", opt enables , onoff >out
print "option WRITE_" $2, "requires WRITE_ANCILLARY_CHUNKS" reqwrite, "enables", $2 enables, onoff >out print "option WRITE_" opt, "requires WRITE_ANCILLARY_CHUNKS" reqwrite, "enables", opt enables, onoff >out
next next
} }
# Else hit the error handler below - bad line format! # Else hit the error handler below - bad line format!

View File

@ -39,6 +39,11 @@ file pnglibconf.h scripts/pnglibconf.dfa PNGLCONF_H
# used as given (e.g. enables GAMMA just expands to that on the # used as given (e.g. enables GAMMA just expands to that on the
# correspond READ_name and WRITE_name lines.) # correspond READ_name and WRITE_name lines.)
# #
# "," may be used to separate options on an 'option' line and is ignored; it
# doesn't change the meaning of the line. (NOT setting, where "," becomes
# part of the setting!) A comma at the end of an option line causes a
# continuation (the next line is included in the option too.)
#
# Note that the 'on' and 'off' keywords, while valid on both option # Note that the 'on' and 'off' keywords, while valid on both option
# and chunk, should not be used in this file because they force the # and chunk, should not be used in this file because they force the
# relevant options on or off. # relevant options on or off.
@ -390,12 +395,12 @@ option READ_TRANSFORMS requires READ
# If you handle gamma issues outside libpng then you do not need the libpng # If you handle gamma issues outside libpng then you do not need the libpng
# gamma processing; and it is an enormous waste of space. You just need to # gamma processing; and it is an enormous waste of space. You just need to
# remove the use of libpng APIs that depend on it. # remove the use of libpng APIs that depend on it.
option READ_GAMMA requires READ_TRANSFORMS READ_gAMA option READ_GAMMA requires READ_TRANSFORMS, READ_gAMA
option READ_ALPHA_MODE requires READ_TRANSFORMS READ_GAMMA option READ_ALPHA_MODE requires READ_TRANSFORMS, READ_GAMMA
option READ_BACKGROUND requires READ_TRANSFORMS READ_STRIP_ALPHA READ_GAMMA option READ_BACKGROUND requires READ_TRANSFORMS, READ_STRIP_ALPHA, READ_GAMMA
option READ_BGR requires READ_TRANSFORMS option READ_BGR requires READ_TRANSFORMS
option READ_EXPAND_16 requires READ_TRANSFORMS READ_16BIT READ_EXPAND option READ_EXPAND_16 requires READ_TRANSFORMS, READ_16BIT, READ_EXPAND
option READ_EXPAND requires READ_TRANSFORMS option READ_EXPAND requires READ_TRANSFORMS
option READ_FILLER requires READ_TRANSFORMS option READ_FILLER requires READ_TRANSFORMS
option READ_GRAY_TO_RGB requires READ_TRANSFORMS option READ_GRAY_TO_RGB requires READ_TRANSFORMS
@ -403,13 +408,13 @@ option READ_INVERT_ALPHA requires READ_TRANSFORMS
option READ_INVERT requires READ_TRANSFORMS option READ_INVERT requires READ_TRANSFORMS
option READ_PACK requires READ_TRANSFORMS option READ_PACK requires READ_TRANSFORMS
option READ_PACKSWAP requires READ_TRANSFORMS option READ_PACKSWAP requires READ_TRANSFORMS
option READ_RGB_TO_GRAY requires READ_TRANSFORMS READ_GAMMA option READ_RGB_TO_GRAY requires READ_TRANSFORMS, READ_GAMMA
option READ_SCALE_16_TO_8 requires READ_TRANSFORMS option READ_SCALE_16_TO_8 requires READ_TRANSFORMS
option READ_SHIFT requires READ_TRANSFORMS option READ_SHIFT requires READ_TRANSFORMS
option READ_STRIP_16_TO_8 requires READ_TRANSFORMS option READ_STRIP_16_TO_8 requires READ_TRANSFORMS
option READ_STRIP_ALPHA requires READ_TRANSFORMS option READ_STRIP_ALPHA requires READ_TRANSFORMS
option READ_SWAP_ALPHA requires READ_TRANSFORMS option READ_SWAP_ALPHA requires READ_TRANSFORMS
option READ_SWAP requires READ_TRANSFORMS READ_16BIT option READ_SWAP requires READ_TRANSFORMS, READ_16BIT
option READ_USER_TRANSFORM requires READ_TRANSFORMS option READ_USER_TRANSFORM requires READ_TRANSFORMS
option PROGRESSIVE_READ requires READ option PROGRESSIVE_READ requires READ
@ -448,7 +453,7 @@ option WRITE_TRANSFORMS requires WRITE
option WRITE_SHIFT requires WRITE_TRANSFORMS option WRITE_SHIFT requires WRITE_TRANSFORMS
option WRITE_PACK requires WRITE_TRANSFORMS option WRITE_PACK requires WRITE_TRANSFORMS
option WRITE_BGR requires WRITE_TRANSFORMS option WRITE_BGR requires WRITE_TRANSFORMS
option WRITE_SWAP requires WRITE_TRANSFORMS WRITE_16BIT option WRITE_SWAP requires WRITE_TRANSFORMS, WRITE_16BIT
option WRITE_PACKSWAP requires WRITE_TRANSFORMS option WRITE_PACKSWAP requires WRITE_TRANSFORMS
option WRITE_INVERT requires WRITE_TRANSFORMS option WRITE_INVERT requires WRITE_TRANSFORMS
option WRITE_FILLER requires WRITE_TRANSFORMS option WRITE_FILLER requires WRITE_TRANSFORMS
@ -470,8 +475,8 @@ option WRITE_FLUSH requires WRITE
# Note: these can be turned off explicitly if not required by the # Note: these can be turned off explicitly if not required by the
# apps implementing the user transforms # apps implementing the user transforms
option USER_TRANSFORM_PTR if READ_USER_TRANSFORM WRITE_USER_TRANSFORM option USER_TRANSFORM_PTR if READ_USER_TRANSFORM, WRITE_USER_TRANSFORM
option USER_TRANSFORM_INFO if READ_USER_TRANSFORM WRITE_USER_TRANSFORM option USER_TRANSFORM_INFO if READ_USER_TRANSFORM, WRITE_USER_TRANSFORM
# This enables API to set compression parameters for compressing # This enables API to set compression parameters for compressing
# non-IDAT chunks (zTXt, iTXt, iCCP, and unknown chunks). This feature # non-IDAT chunks (zTXt, iTXt, iCCP, and unknown chunks). This feature
@ -664,7 +669,7 @@ chunk bKGD
chunk cHRM enables COLORSPACE chunk cHRM enables COLORSPACE
chunk gAMA enables GAMMA chunk gAMA enables GAMMA
chunk hIST chunk hIST
chunk iCCP enables COLORSPACE GAMMA chunk iCCP enables COLORSPACE, GAMMA
chunk iTXt chunk iTXt
chunk oFFs chunk oFFs
chunk pCAL chunk pCAL
@ -672,7 +677,7 @@ chunk pHYs
chunk sBIT chunk sBIT
chunk sCAL chunk sCAL
chunk sPLT chunk sPLT
chunk sRGB enables COLORSPACE GAMMA chunk sRGB enables COLORSPACE, GAMMA
chunk tEXt requires TEXT chunk tEXt requires TEXT
chunk tIME chunk tIME
chunk tRNS chunk tRNS
@ -702,7 +707,7 @@ option WRITE_UNKNOWN_CHUNKS enables STORE_UNKNOWN_CHUNKS
# to png_get_unknown_chunks, the application must call # to png_get_unknown_chunks, the application must call
# png_set_keep_unknown_chunks to cause this to actually happen (see png.h) # png_set_keep_unknown_chunks to cause this to actually happen (see png.h)
option SAVE_UNKNOWN_CHUNKS requires READ requires SET_UNKNOWN_CHUNKS option SAVE_UNKNOWN_CHUNKS requires READ requires SET_UNKNOWN_CHUNKS
option SAVE_UNKNOWN_CHUNKS enables READ_UNKNOWN_CHUNKS STORE_UNKNOWN_CHUNKS option SAVE_UNKNOWN_CHUNKS enables READ_UNKNOWN_CHUNKS, STORE_UNKNOWN_CHUNKS
# The second approach is to use an application provided callback to process the # The second approach is to use an application provided callback to process the
# chunks, the callback can either handle the chunk entirely itself or request # chunks, the callback can either handle the chunk entirely itself or request
@ -710,8 +715,8 @@ option SAVE_UNKNOWN_CHUNKS enables READ_UNKNOWN_CHUNKS STORE_UNKNOWN_CHUNKS
# #
# Note that there is no 'WRITE_USER_CHUNKS' so the USER_CHUNKS option is always # Note that there is no 'WRITE_USER_CHUNKS' so the USER_CHUNKS option is always
# the same as READ_USER_CHUNKS at present # the same as READ_USER_CHUNKS at present
option READ_USER_CHUNKS requires READ requires UNKNOWN_CHUNKS option READ_USER_CHUNKS requires READ, UNKNOWN_CHUNKS
option READ_USER_CHUNKS enables READ_UNKNOWN_CHUNKS USER_CHUNKS option READ_USER_CHUNKS enables READ_UNKNOWN_CHUNKS, USER_CHUNKS
# Two further options are provided to allow detailed control of the handling. # Two further options are provided to allow detailed control of the handling.
# The first enables png_set_keep_unknown_chunks; this allows the default to be # The first enables png_set_keep_unknown_chunks; this allows the default to be
@ -778,8 +783,8 @@ option INFO_IMAGE
option CHECK_FOR_INVALID_INDEX enables READ_CHECK_FOR_INVALID_INDEX option CHECK_FOR_INVALID_INDEX enables READ_CHECK_FOR_INVALID_INDEX
option CHECK_FOR_INVALID_INDEX enables WRITE_CHECK_FOR_INVALID_INDEX option CHECK_FOR_INVALID_INDEX enables WRITE_CHECK_FOR_INVALID_INDEX
option READ_CHECK_FOR_INVALID_INDEX requires READ CHECK_FOR_INVALID_INDEX option READ_CHECK_FOR_INVALID_INDEX requires READ, CHECK_FOR_INVALID_INDEX
option WRITE_CHECK_FOR_INVALID_INDEX requires WRITE CHECK_FOR_INVALID_INDEX option WRITE_CHECK_FOR_INVALID_INDEX requires WRITE, CHECK_FOR_INVALID_INDEX
# added at libpng-1.5.15 # added at libpng-1.5.15
option GET_PALETTE_MAX enables READ_GET_PALETTE_MAX WRITE_GET_PALETTE_MAX option GET_PALETTE_MAX enables READ_GET_PALETTE_MAX WRITE_GET_PALETTE_MAX
@ -788,12 +793,11 @@ option WRITE_GET_PALETTE_MAX requires WRITE_CHECK_FOR_INVALID_INDEX disabled
# Simplified API options (added at libpng-1.6.0) # Simplified API options (added at libpng-1.6.0)
# Read: # Read:
option SIMPLIFIED_READ requires SEQUENTIAL_READ READ_TRANSFORMS SETJMP option SIMPLIFIED_READ,
option SIMPLIFIED_READ requires BENIGN_ERRORS READ_GAMMA requires SEQUENTIAL_READ READ_TRANSFORMS, SETJMP, BENIGN_ERRORS READ_GAMMA,
option SIMPLIFIED_READ enables READ_EXPAND READ_16BIT READ_EXPAND_16 enables READ_EXPAND, READ_16BIT READ_EXPAND_16, READ_SCALE_16_TO_8,
option SIMPLIFIED_READ enables READ_SCALE_16_TO_8 READ_RGB_TO_GRAY READ_RGB_TO_GRAY, READ_ALPHA_MODE READ_BACKGROUND READ_STRIP_ALPHA,
option SIMPLIFIED_READ enables READ_ALPHA_MODE READ_BACKGROUND READ_STRIP_ALPHA READ_FILLER, READ_SWAP
option SIMPLIFIED_READ enables READ_FILLER READ_SWAP
option SIMPLIFIED_READ_AFIRST requires SIMPLIFIED_READ disabled option SIMPLIFIED_READ_AFIRST requires SIMPLIFIED_READ disabled
option READ_SWAP_ALPHA enables SIMPLIFIED_READ_AFIRST option READ_SWAP_ALPHA enables SIMPLIFIED_READ_AFIRST
@ -802,8 +806,9 @@ option SIMPLIFIED_READ_BGR requires SIMPLIFIED_READ disabled
option READ_BGR enables SIMPLIFIED_READ_BGR option READ_BGR enables SIMPLIFIED_READ_BGR
# Write: # Write:
option SIMPLIFIED_WRITE requires WRITE STDIO SETJMP option SIMPLIFIED_WRITE,
option SIMPLIFIED_WRITE enables WRITE_SWAP WRITE_gAMA WRITE_sRGB WRITE_cHRM requires WRITE STDIO, SETJMP,
enables WRITE_SWAP WRITE_gAMA, WRITE_sRGB WRITE_cHRM
option SIMPLIFIED_WRITE_AFIRST requires SIMPLIFIED_WRITE disabled option SIMPLIFIED_WRITE_AFIRST requires SIMPLIFIED_WRITE disabled
option WRITE_SWAP_ALPHA enables SIMPLIFIED_WRITE_AFIRST option WRITE_SWAP_ALPHA enables SIMPLIFIED_WRITE_AFIRST
@ -812,5 +817,5 @@ option SIMPLIFIED_WRITE_BGR requires SIMPLIFIED_WRITE disabled
option WRITE_BGR enables SIMPLIFIED_WRITE_BGR option WRITE_BGR enables SIMPLIFIED_WRITE_BGR
# Formats: # Formats:
option FORMAT_AFIRST if SIMPLIFIED_READ_AFIRST SIMPLIFIED_WRITE_AFIRST option FORMAT_AFIRST if SIMPLIFIED_READ_AFIRST, SIMPLIFIED_WRITE_AFIRST
option FORMAT_BGR if SIMPLIFIED_READ_BGR SIMPLIFIED_WRITE_BGR option FORMAT_BGR if SIMPLIFIED_READ_BGR, SIMPLIFIED_WRITE_BGR