* xmlXPathCompNumber: * @ctxt: the XPath Parser context * * [30] Number ::= Digits ('.' Digits?)? * | '.' Digits * [31] Digits ::= [0-9]+ * * Compile a Number, then push it on the stack * */
| 9103 | * |
| 9104 | */ |
| 9105 | static void |
| 9106 | xmlXPathCompNumber(xmlXPathParserContextPtr ctxt) |
| 9107 | { |
| 9108 | double ret = 0.0; |
| 9109 | int ok = 0; |
| 9110 | int exponent = 0; |
| 9111 | int is_exponent_negative = 0; |
| 9112 | xmlXPathObjectPtr num; |
| 9113 | #ifdef __GNUC__ |
| 9114 | unsigned long tmp = 0; |
| 9115 | double temp; |
| 9116 | #endif |
| 9117 | |
| 9118 | CHECK_ERROR; |
| 9119 | if ((CUR != '.') && ((CUR < '0') || (CUR > '9'))) { |
| 9120 | XP_ERROR(XPATH_NUMBER_ERROR); |
| 9121 | } |
| 9122 | #ifdef __GNUC__ |
| 9123 | /* |
| 9124 | * tmp/temp is a workaround against a gcc compiler bug |
| 9125 | * http://veillard.com/gcc.bug |
| 9126 | */ |
| 9127 | ret = 0; |
| 9128 | while ((CUR >= '0') && (CUR <= '9')) { |
| 9129 | ret = ret * 10; |
| 9130 | tmp = (CUR - '0'); |
| 9131 | ok = 1; |
| 9132 | NEXT; |
| 9133 | temp = (double) tmp; |
| 9134 | ret = ret + temp; |
| 9135 | } |
| 9136 | #else |
| 9137 | ret = 0; |
| 9138 | while ((CUR >= '0') && (CUR <= '9')) { |
| 9139 | ret = ret * 10 + (CUR - '0'); |
| 9140 | ok = 1; |
| 9141 | NEXT; |
| 9142 | } |
| 9143 | #endif |
| 9144 | if (CUR == '.') { |
| 9145 | int v, frac = 0, max; |
| 9146 | double fraction = 0; |
| 9147 | |
| 9148 | NEXT; |
| 9149 | if (((CUR < '0') || (CUR > '9')) && (!ok)) { |
| 9150 | XP_ERROR(XPATH_NUMBER_ERROR); |
| 9151 | } |
| 9152 | while (CUR == '0') { |
| 9153 | frac = frac + 1; |
| 9154 | NEXT; |
| 9155 | } |
| 9156 | max = frac + MAX_FRAC; |
| 9157 | while ((CUR >= '0') && (CUR <= '9') && (frac < max)) { |
| 9158 | v = (CUR - '0'); |
| 9159 | fraction = fraction * 10 + v; |
| 9160 | frac = frac + 1; |
| 9161 | NEXT; |
| 9162 | } |
no test coverage detected