% Copyright Barbara Liskov 1985 x_geometry = proc (spec, defspec: string) returns (int, int, int, int, bool, bool, bool) i1: int := string$indexc('x', defspec) i2: int if i1 = 0 then i1 := string$indexc('+', defspec) i2 := string$indexc('-', defspec) if i2 > 0 cand (i1 = 0 cor i2 < i1) then i1 := i2 end if i1 = 0 then i1 := string$size(defspec) + 1 end end dw: int := int$parse(string$substr(defspec, 2, i1 - 2)) except others: dw := 1 end if i1 <= string$size(defspec) cand defspec[i1] = 'x' then i1 := i1 + 1 end defspec := string$rest(defspec, i1) i1 := string$indexc('+', defspec) i2 := string$indexc('-', defspec) dxp: bool := true if i2 > 0 cand (i1 = 0 cor i2 < i1) then i1 := i2 dxp := false end if i1 = 0 then i1 := string$size(defspec) + 1 end dh: int := int$parse(string$substr(defspec, 1, i1 - 1)) except others: dh := 1 end defspec := string$rest(defspec, i1 + 1) except when bounds: defspec := "" end i1 := string$indexc('+', defspec) dyp: bool := true if i1 = 0 then i1 := string$indexc('-', defspec) if i1 = 0 then i1 := string$size(defspec) + 1 else dyp := false end end dx: int := int$parse(string$substr(defspec, 1, i1 - 1)) except others: dx := 1 end dy: int := int$parse(string$rest(defspec, i1 + 1)) except others: dy := 1 end i1 := string$indexc('x', spec) if i1 = 0 then i1 := string$indexc('+', spec) i2 := string$indexc('-', spec) if i2 > 0 cand (i1 = 0 cor i2 < i1) then i1 := i2 end if i1 = 0 then i1 := string$size(spec) + 1 end end width: int := int$parse(string$substr(spec, 2, i1 - 2)) except others: width := dw end if width <= 0 then width := dw end if i1 <= string$size(spec) cand spec[i1] = 'x' then i1 := i1 + 1 end spec := string$rest(spec, i1) i1 := string$indexc('+', spec) i2 := string$indexc('-', spec) xplus: bool := true place: bool := true if i2 > 0 cand (i1 = 0 cor i2 < i1) then i1 := i2 xplus := false end if i1 = 0 then i1 := string$size(defspec) + 1 place := false end height: int := int$parse(string$substr(spec, 1, i1 - 1)) except others: height := dh end if height <= 0 then height := dh end spec := string$rest(spec, i1 + 1) except when bounds: spec := "" end i1 := string$indexc('+', spec) yplus: bool := true if i1 = 0 then i1 := string$indexc('-', spec) if i1 = 0 then i1 := string$size(spec) + 1 else yplus := false end end x: int := int$parse(string$substr(spec, 1, i1 - 1)) except others: x := dx xplus := dxp end y: int := int$parse(string$rest(spec, i1 + 1)) except others: y := dy yplus := dyp end return(width, height, x, y, xplus, yplus, place) end x_geometry