$OpenBSD: patch-cups_pstopxl_in,v 1.1 2011/07/18 20:24:36 kili Exp $

From jirib via http://bugs.ghostscript.com/show_bug.cgi?id=692328

--- cups/pstopxl.in.orig	Tue Jun 29 05:48:17 2010
+++ cups/pstopxl.in	Thu Jul  7 12:53:16 2011
@@ -51,9 +51,9 @@ ps_code=
 ppd_opts=
 
 resolution=
-eval "$(printf "%s" "$5" | sed @SED_EXTENDED_REGEX_OPT@ 's/.*(^|\s)Resolution=([0-9.]+(x[0-9.]+)?).*/resolution="${resolution:-\2}"/p')"
+eval "$(printf "%s" "$5" | sed @SED_EXTENDED_REGEX_OPT@ 's/.*(^|[[:space:]])Resolution=([0-9.]+(x[0-9.]+)?).*/resolution="${resolution:-\2}"/p')"
 if test -e "$PPD"; then
-  eval "$(sed @SED_EXTENDED_REGEX_OPT@ 's/^\*DefaultResolution:\s+([0-9.]+(x[0-9.]+)?).*/resolution="${resolution:-\1}"/p' "$PPD")"
+  eval "$(sed @SED_EXTENDED_REGEX_OPT@ 's/^\*DefaultResolution:[[:space:]]+([0-9.]+(x[0-9.]+)?).*/resolution="${resolution:-\1}"/p' "$PPD")"
 fi
 echo "DEBUG: Resolution: $resolution" >&2
 if test -n "$resolution"; then
@@ -61,15 +61,15 @@ if test -n "$resolution"; then
 fi
 
 pagesize=
-eval "$(printf "%s" "$5" | sed @SED_EXTENDED_REGEX_OPT@ 's/.*(^|\s)(media|PageSize)=(\S+).*/pagesize="${pagesize:-\3}"/p')"
+eval "$(printf "%s" "$5" | sed @SED_EXTENDED_REGEX_OPT@ 's/.*(^|[[:space:]])(media|PageSize)=([^[:space:]]+).*/pagesize="${pagesize:-\3}"/p')"
 if test -e "$PPD"; then
-  eval "$(sed @SED_EXTENDED_REGEX_OPT@ 's/^\*DefaultPageSize:\s+(\S+).*/pagesize="${pagesize:-\1}"/p' "$PPD")"
+  eval "$(sed @SED_EXTENDED_REGEX_OPT@ 's/^\*DefaultPageSize:[[:space:]]+([^[:space:]]+).*/pagesize="${pagesize:-\1}"/p' "$PPD")"
 fi
 echo "DEBUG: Page size: $pagesize" >&2
 width=
 height=
 if test -n "$pagesize" && test -e "$PPD"; then
-  eval "$(sed @SED_EXTENDED_REGEX_OPT@ 's|^\*PaperDimension\s+'"$pagesize"'/[^:]+:\s+"(\S+)\s+(\S+)".*|width="\1"; height="\2"|p' "$PPD")"
+  eval "$(sed @SED_EXTENDED_REGEX_OPT@ 's|^\*PaperDimension[[:space:]]+'"$pagesize"'/[^:]+:[[:space:]]+"([^[:space:]]+)[[:space:]]+([^[:space:]]+)".*|width="\1"; height="\2"|p' "$PPD")"
 fi
 echo "DEBUG: Width: $width, height: $height" >&2
 if test -n "$width"; then
@@ -84,7 +84,7 @@ bl_y=
 tr_x=
 tr_y=
 if test -n "$pagesize" && test -e "$PPD"; then
-  eval "$(sed @SED_EXTENDED_REGEX_OPT@ 's|^\*ImageableArea\s+'"$pagesize"'/[^:]+:\s+"(\S+)\s+(\S+)\s+(\S+)\s+(\S+)".*|bl_x="\1"; bl_y="\2"; tr_x="\3"; tr_y="\4"|p' "$PPD")"
+  eval "$(sed @SED_EXTENDED_REGEX_OPT@ 's|^\*ImageableArea[[:space:]]+'"$pagesize"'/[^:]+:[[:space:]]+"([^[:space:]]+)[[:space:]]+([^[:space:]]+)[[:space:]]+([^[:space:]]+)[[:space:]]+([^[:space:]]+)".*|bl_x="\1"; bl_y="\2"; tr_x="\3"; tr_y="\4"|p' "$PPD")"
 fi
 echo "DEBUG: Absolute margins: $bl_x, $bl_y, $tr_x, $tr_y" >&2
 margin_l=
@@ -106,14 +106,14 @@ if test -n "$margin_l" && test -n "$margin_b" && \
 fi
 
 inputslot=
-eval "$(printf "%s" "$5" | sed @SED_EXTENDED_REGEX_OPT@ 's/.*(^|\s)(InputSlot)=(\S+).*/inputslot="${inputslot:-\3}"/p')"
+eval "$(printf "%s" "$5" | sed @SED_EXTENDED_REGEX_OPT@ 's/.*(^|[[:space:]])(InputSlot)=([^[:space:]]+).*/inputslot="${inputslot:-\3}"/p')"
 if test -e "$PPD"; then
-  eval "$(sed @SED_EXTENDED_REGEX_OPT@ 's/^\*DefaultInputSlot:\s+(\S+).*/inputslot="${inputslot:-\1}"/p' "$PPD")"
+  eval "$(sed @SED_EXTENDED_REGEX_OPT@ 's/^\*DefaultInputSlot:[[:space:]]+([^[:space:]]+).*/inputslot="${inputslot:-\1}"/p' "$PPD")"
 fi
 echo "DEBUG: InputSlot: $inputslot" >&2
 inputslot_val=
 if test -n "$inputslot" && test -e "$PPD"; then
-  eval "$(sed @SED_EXTENDED_REGEX_OPT@ 's|^\*InputSlot\s+'"$inputslot"'/[^:]+:\s+"\s*<\s*<\s*/MediaPosition\s*([0-9]+)\s*>\s*>\s*setpagedevice\s*".*|inputslot_val="\1"|p' "$PPD")"
+  eval "$(sed @SED_EXTENDED_REGEX_OPT@ 's|^\*InputSlot[[:space:]]+'"$inputslot"'/[^:]+:[[:space:]]+"[[:space:]]*<[[:space:]]*<[[:space:]]*/MediaPosition[[:space:]]*([0-9]+)[[:space:]]*>[[:space:]]*>[[:space:]]*setpagedevice[[:space:]]*".*|inputslot_val="\1"|p' "$PPD")"
 fi
 echo "DEBUG: Value for MediaPosition: $inputslot_val" >&2
 if test -n "$inputslot_val"; then
@@ -121,14 +121,14 @@ if test -n "$inputslot_val"; then
 fi
 
 colormodel=
-eval "$(printf "%s" "$5" | sed @SED_EXTENDED_REGEX_OPT@ 's/.*(^|\s)(ColorModel)=(\S+).*/colormodel="${colormodel:-\3}"/p')"
+eval "$(printf "%s" "$5" | sed @SED_EXTENDED_REGEX_OPT@ 's/.*(^|[[:space:]])(ColorModel)=([^[:space:]]+).*/colormodel="${colormodel:-\3}"/p')"
 if test -e "$PPD"; then
-  eval "$(sed @SED_EXTENDED_REGEX_OPT@ 's/^\*DefaultColorModel:\s+(\S+).*/colormodel="${colormodel:-\1}"/p' "$PPD")"
+  eval "$(sed @SED_EXTENDED_REGEX_OPT@ 's/^\*DefaultColorModel:[[:space:]]+([^[:space:]]+).*/colormodel="${colormodel:-\1}"/p' "$PPD")"
 fi
 echo "DEBUG: ColorModel: $colormodel" >&2
 colormodel_val=
 if test -n "$colormodel" && test -e "$PPD"; then
-  eval "$(sed @SED_EXTENDED_REGEX_OPT@ 's|^\*ColorModel\s+'"$colormodel"'/[^:]+:\s+"\s*<\s*<\s*/BitsPerPixel\s*([0-9]*)\s*>\s*>\s*setpagedevice\s*".*|colormodel_val="\1"|p' "$PPD")"
+  eval "$(sed @SED_EXTENDED_REGEX_OPT@ 's|^\*ColorModel[[:space:]]+'"$colormodel"'/[^:]+:[[:space:]]+"[[:space:]]*<[[:space:]]*<[[:space:]]*/BitsPerPixel[[:space:]]*([0-9]*)[[:space:]]*>[[:space:]]*>[[:space:]]*setpagedevice[[:space:]]*".*|colormodel_val="\1"|p' "$PPD")"
 fi
 echo "DEBUG: Value for BitsPerPixel: $colormodel_val" >&2
 if test -n "$colormodel_val"; then
@@ -136,15 +136,15 @@ if test -n "$colormodel_val"; then
 fi
 
 duplex=
-eval "$(printf "%s" "$5" | sed @SED_EXTENDED_REGEX_OPT@ 's/.*(^|\s)(Duplex)=(\S+).*/duplex="${duplex:-\3}"/p')"
+eval "$(printf "%s" "$5" | sed @SED_EXTENDED_REGEX_OPT@ 's/.*(^|[[:space:]])(Duplex)=([^[:space:]]+).*/duplex="${duplex:-\3}"/p')"
 if test -e "$PPD"; then
-  eval "$(sed @SED_EXTENDED_REGEX_OPT@ 's/^\*DefaultDuplex:\s+(\S+).*/duplex="${duplex:-\1}"/p' "$PPD")"
+  eval "$(sed @SED_EXTENDED_REGEX_OPT@ 's/^\*DefaultDuplex:[[:space:]]+([^[:space:]]+).*/duplex="${duplex:-\1}"/p' "$PPD")"
 fi
 echo "DEBUG: Duplex: $duplex" >&2
 duplex_val=
 tumble_val=
 if test -n "$duplex" && test -e "$PPD"; then
-  eval "$(sed @SED_EXTENDED_REGEX_OPT@ 's|^\*Duplex\s+'"$duplex"'/[^:]+:\s+"\s*<\s*<\s*/Duplex\s*(\S*)\s*(/Tumble\s*(\S*)\s*)?>\s*>\s*setpagedevice\s*".*|duplex_val="\1"; tumble_val="\3"|p' "$PPD")"
+  eval "$(sed @SED_EXTENDED_REGEX_OPT@ 's|^\*Duplex[[:space:]]+'"$duplex"'/[^:]+:[[:space:]]+"[[:space:]]*<[[:space:]]*<[[:space:]]*/Duplex[[:space:]]*([^[:space:]]*)[[:space:]]*(/Tumble[[:space:]]*([^[:space:]]*)[[:space:]]*)?>[[:space:]]*>[[:space:]]*setpagedevice[[:space:]]*".*|duplex_val="\1"; tumble_val="\3"|p' "$PPD")"
 fi
 echo "DEBUG: Value for Duplex: $duplex_val; Value for Tumble: $tumble_val" >&2
 if test -n "$duplex_val"; then
