Subject: [OpenJade] Bugfix for +/- vs. length-specs From: Matthias Clasen <clasen@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 18 Jun 1999 00:04:28 +0200 |
Here is a fix for this recently discovered jade bug: I have added this to my jade patches collection in ftp://peano.mathematik.uni-freiburg.de/pub/jade/ --- jade-1.2.1/style/primitive.cxx Wed Oct 7 07:16:34 1998 +++ jade-1.2.1+/style/primitive.cxx Thu Jun 17 23:32:39 1999 @@ -672,40 +674,13 @@ long lResult; double dResult; bool usingD; + bool spec = 0; int dim; switch (argv[0]->quantityValue(lResult, dResult, dim)) { case ELObj::noQuantity: - { - const LengthSpec *lsp = argv[0]->lengthSpec(); - if (!lsp) - return argError(interp, loc, - InterpreterMessages::notAQuantityOrLengthSpec, 0, argv[0]); - LengthSpec ls(*lsp); - for (int i = 1; i < argc; i++) { - lsp = argv[i]->lengthSpec(); - if (lsp) - ls += *lsp; - else { - switch (argv[i]->quantityValue(lResult, dResult, dim)) { - case ELObj::noQuantity: - return argError(interp, loc, InterpreterMessages::notAQuantityOrLengthSpec, - i, argv[i]); - case ELObj::longQuantity: - dResult = lResult; - // fall through - case ELObj::doubleQuantity: - if (dim != 1) { - interp.setNextLocation(loc); - interp.message(InterpreterMessages::incompatibleDimensions); - return interp.makeError(); - } - ls += dResult; - break; - } - } - } - return new (interp) LengthSpecObj(ls); - } + dim = 1; + spec = 1; + break; case ELObj::longQuantity: usingD = 0; break; @@ -715,14 +690,16 @@ default: CANNOT_HAPPEN(); } - for (int i = 1; i < argc; i++) { + for (int i = 1; !spec && i < argc; i++) { long lResult2; double dResult2; int dim2; switch (argv[i]->quantityValue(lResult2, dResult2, dim2)) { case ELObj::noQuantity: - return argError(interp, loc, InterpreterMessages::notAQuantity, - i, argv[i]); + // FIXME shouldn't quantityValue set dim to 1 for length-specs ? + dim2 = 1; + spec = 1; + break; case ELObj::longQuantity: if (!usingD) { if (lResult2 < 0) { @@ -758,6 +735,35 @@ return interp.makeError(); } } + + if (spec) { + LengthSpec ls; + for (int i = 0; i < argc; i++) { + const LengthSpec *lsp = argv[i]->lengthSpec(); + if (lsp) + ls += *lsp; + else { + switch (argv[i]->quantityValue(lResult, dResult, dim)) { + case ELObj::noQuantity: + return argError(interp, loc, InterpreterMessages::notAQuantityOrLengthSpec, + i, argv[i]); + case ELObj::longQuantity: + dResult = lResult; + // fall through + case ELObj::doubleQuantity: + if (dim != 1) { + interp.setNextLocation(loc); + interp.message(InterpreterMessages::incompatibleDimensions); + return interp.makeError(); + } + ls += dResult; + break; + } + } + } + return new (interp) LengthSpecObj(ls); + } + if (!usingD) { if (dim == 0) return interp.makeInteger(lResult); @@ -777,41 +783,13 @@ long lResult; double dResult; bool usingD; + bool spec = 0; int dim; switch (argv[0]->quantityValue(lResult, dResult, dim)) { case ELObj::noQuantity: - { - const LengthSpec *lsp = argv[0]->lengthSpec(); - if (!lsp) - return argError(interp, loc, - InterpreterMessages::notAQuantityOrLengthSpec, 0, argv[0]); - LengthSpec ls(*lsp); - for (int i = 1; i < argc; i++) { - lsp = argv[i]->lengthSpec(); - if (lsp) - ls -= *lsp; - else { - switch (argv[i]->quantityValue(lResult, dResult, dim)) { - case ELObj::noQuantity: - return argError(interp, loc, InterpreterMessages::notAQuantityOrLengthSpec, - i, argv[i]); - case ELObj::longQuantity: - dResult = lResult; - // fall through - case ELObj::doubleQuantity: - if (dim != 1) { - interp.setNextLocation(loc); - interp.message(InterpreterMessages::incompatibleDimensions); - return interp.makeError(); - } - ls -= dResult; - break; - } - } - } - return new (interp) LengthSpecObj(ls); - } - case ELObj::longQuantity: + spec = 1; + break; + case ELObj::longQuantity: usingD = 0; break; case ELObj::doubleQuantity: @@ -827,15 +805,15 @@ lResult = -lResult; } else { - for (int i = 1; i < argc; i++) { + for (int i = 1; !spec && i < argc; i++) { long lResult2; double dResult2; int dim2; switch (argv[i]->quantityValue(lResult2, dResult2, dim2)) { case ELObj::noQuantity: - return argError(interp, loc, - InterpreterMessages::notAQuantity, i, - argv[i]); + dim2 = dim; + spec = 1; + break; case ELObj::longQuantity: if (!usingD) { if (lResult2 > 0) { @@ -872,6 +850,42 @@ } } } + + if (spec) { + LengthSpec ls; + for (int i = 0; i < argc; i++) { + const LengthSpec *lsp = argv[i]->lengthSpec(); + if (lsp) { + if (i > 0 || argc == 1) + ls -= *lsp; + else + ls += *lsp; + } + else { + switch (argv[i]->quantityValue(lResult, dResult, dim)) { + case ELObj::noQuantity: + return argError(interp, loc, InterpreterMessages::notAQuantityOrLengthSpec, + i, argv[i]); + case ELObj::longQuantity: + dResult = lResult; + // fall through + case ELObj::doubleQuantity: + if (dim != 1) { + interp.setNextLocation(loc); + interp.message(InterpreterMessages::incompatibleDimensions); + return interp.makeError(); + } + if (i > 0 || argc == 1) + ls -= dResult; + else + ls += dResult; + break; + } + } + } + return new (interp) LengthSpecObj(ls); + } + if (!usingD) { if (dim == 0) return interp.makeInteger(lResult); -- Matthias Clasen, Tel. 0761/203-5606 Email: clasen@xxxxxxxxxxxxxxxxxxxxxxxxxx Mathematisches Institut, Albert-Ludwigs-Universitaet Freiburg DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: XSL FOs and DSSSL FOs -- same o, Didier PH Martin | Thread | RE: [OpenJade] Bugfix for +/- vs. l, Frank A. Christoph |
Re: Debian / Jade patches (was Re: , Matthias Clasen | Date | Re: Generating high-level formattin, Sebastian Rahtz |
Month |