| 316 | // |
| 317 | |
| 318 | gpre_nod* EXP_literal() |
| 319 | { |
| 320 | switch (gpreGlob.sw_sql_dialect) |
| 321 | { |
| 322 | case 1: |
| 323 | if (!(gpreGlob.token_global.tok_type == tok_number || isQuoted(gpreGlob.token_global.tok_type))) |
| 324 | return NULL; |
| 325 | break; |
| 326 | default: |
| 327 | if (!(gpreGlob.token_global.tok_type == tok_number || gpreGlob.token_global.tok_type == tok_sglquoted)) |
| 328 | return NULL; |
| 329 | } |
| 330 | |
| 331 | ref* reference = (ref*) MSC_alloc(REF_LEN); |
| 332 | gpre_nod* node = MSC_unary(nod_literal, (gpre_nod*) reference); |
| 333 | if (isQuoted(gpreGlob.token_global.tok_type)) |
| 334 | { |
| 335 | TEXT* string = (TEXT *) MSC_alloc(gpreGlob.token_global.tok_length + 3); |
| 336 | reference->ref_value = string; |
| 337 | strcat(string, "\'"); |
| 338 | MSC_copy(gpreGlob.token_global.tok_string, gpreGlob.token_global.tok_length, string + 1); |
| 339 | strcat((string + gpreGlob.token_global.tok_length + 1), "\'"); |
| 340 | // What kind of hack is this? The token has not been enlarged nor modified. |
| 341 | gpreGlob.token_global.tok_length += 2; |
| 342 | } |
| 343 | else |
| 344 | { |
| 345 | TEXT* string = (TEXT *) MSC_alloc(gpreGlob.token_global.tok_length + 1); |
| 346 | reference->ref_value = string; |
| 347 | MSC_copy(gpreGlob.token_global.tok_string, gpreGlob.token_global.tok_length, string); |
| 348 | } |
| 349 | |
| 350 | // Begin date/time/timestamp |
| 351 | switch (gpreGlob.token_global.tok_keyword) |
| 352 | { |
| 353 | case KW_DATE: |
| 354 | reference->ref_flags |= REF_sql_date; |
| 355 | break; |
| 356 | |
| 357 | case KW_TIME: |
| 358 | reference->ref_flags |= REF_sql_time; |
| 359 | break; |
| 360 | |
| 361 | case KW_TIMESTAMP: |
| 362 | reference->ref_flags |= REF_timestamp; |
| 363 | break; |
| 364 | // Do not put a default here |
| 365 | } |
| 366 | // End date/time/timestamp |
| 367 | |
| 368 | if ((gpreGlob.token_global.tok_type == tok_sglquoted && gpreGlob.token_global.tok_charset) || |
| 369 | ((isQuoted(gpreGlob.token_global.tok_type) && gpreGlob.sw_sql_dialect == 1) && |
| 370 | gpreGlob.token_global.tok_charset)) |
| 371 | { |
| 372 | reference->ref_flags |= REF_ttype; |
| 373 | gpre_sym* symbol = gpreGlob.token_global.tok_charset; |
| 374 | reference->ref_ttype = ((intlsym*) (symbol->sym_object))->intlsym_ttype; |
| 375 | } |
no test coverage detected