/ Parse the eventual passed Jpath information. */ This information can be specified in the Fieldfmt column option when */ creating the table. It permits to indicate the position of the node */ corresponding to that column. */ /
| 212 | /* corresponding to that column. */ |
| 213 | /*********************************************************************************/ |
| 214 | my_bool JSNX::ParseJpath(PGLOBAL g) |
| 215 | { |
| 216 | char *p, *p1 = NULL, *p2 = NULL, *pbuf = NULL; |
| 217 | int i; |
| 218 | my_bool a; |
| 219 | |
| 220 | if (Parsed) |
| 221 | return false; // Already done |
| 222 | else if (!Jpath) |
| 223 | { |
| 224 | // Jpath = Name; |
| 225 | snprintf(g->Message, sizeof(g->Message), MSG(ARG_IS_NULL)); |
| 226 | return true; |
| 227 | } |
| 228 | |
| 229 | if (trace(1)) |
| 230 | htrc("ParseJpath %s\n", SVP(Jpath)); |
| 231 | |
| 232 | if (!(pbuf = PlgDBDup(g, Jpath))) |
| 233 | return true; |
| 234 | |
| 235 | if (*pbuf == '$') pbuf++; |
| 236 | if (*pbuf == '.') pbuf++; |
| 237 | if (*pbuf == '[') p1 = pbuf++; |
| 238 | |
| 239 | // Estimate the required number of nodes |
| 240 | for (i = 0, p = pbuf; (p = NextChr(p, '.')); i++, p++) |
| 241 | Nod++; // One path node found |
| 242 | |
| 243 | if (!(Nodes = (PJNODE)PlgDBSubAlloc(g, NULL, (++Nod) * sizeof(JNODE)))) |
| 244 | return true; |
| 245 | |
| 246 | memset(Nodes, 0, (Nod)* sizeof(JNODE)); |
| 247 | |
| 248 | // Analyze the Jpath for this column |
| 249 | for (i = 0, p = pbuf; p && i < Nod; i++, p = (p2 ? p2 : NULL)) { |
| 250 | a = (p1 != NULL); |
| 251 | p1 = strchr(p, '['); |
| 252 | p2 = strchr(p, '.'); |
| 253 | |
| 254 | if (!p2) |
| 255 | p2 = p1; |
| 256 | else if (p1) { |
| 257 | if (p1 < p2) |
| 258 | p2 = p1; |
| 259 | else if (p1 == p2 + 1) |
| 260 | *p2++ = 0; // Old syntax .[ |
| 261 | else |
| 262 | p1 = NULL; |
| 263 | |
| 264 | } // endif p1 |
| 265 | |
| 266 | if (p2) |
| 267 | *p2++ = 0; |
| 268 | |
| 269 | // Jpath must be explicit |
| 270 | if (a || *p == 0 || *p == '[' || IsNum(p)) { |
| 271 | // Analyse intermediate array processing |
nothing calls this directly
no test coverage detected