|
10 | 10 | #include "extern.h"
|
11 | 11 | #include "sqlca.h"
|
12 | 12 |
|
13 |
| -#ifdef WIN32_ONLY_COMPILER |
14 |
| -#define strtok_r(s,d,p) strtok_s(s,d,p) |
15 |
| -#endif |
16 |
| - |
17 | 13 | #ifdef ENABLE_THREAD_SAFETY
|
18 | 14 | static pthread_mutex_t connections_mutex = PTHREAD_MUTEX_INITIALIZER;
|
19 | 15 | static pthread_key_t actual_connection_key;
|
@@ -560,25 +556,37 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
|
560 | 556 | }
|
561 | 557 | if (options)
|
562 | 558 | {
|
563 |
| - char *saveptr, *token1, *token2, *str; |
| 559 | + char *str; |
564 | 560 |
|
565 | 561 | /* options look like this "option1 = value1 option2 = value2 ... */
|
566 | 562 | /* we have to break up the string into single options */
|
567 |
| - for (str = options; ; str = NULL) |
| 563 | + for (str = options; *str;) |
568 | 564 | {
|
569 |
| - token1 = strtok_r(str, "=", &saveptr); |
570 |
| - if (token1 == NULL) |
571 |
| - break; |
572 |
| - /* strip leading blanks */ |
573 |
| - for (; *token1 && *token1 == ' '; token1++); |
| 565 | + int e, a; |
| 566 | + char *token1, *token2; |
574 | 567 |
|
575 |
| - token2 = strtok_r(NULL, "&", &saveptr); |
576 |
| - if (token2 == NULL) |
577 |
| - break; |
| 568 | + for (token1 = str; *token1 && *token1 == ' '; token1++); |
| 569 | + for (e = 0; token1[e] && token1[e] != '='; e++); |
| 570 | + if (token1[e]) /* found "=" */ |
| 571 | + { |
| 572 | + token1[e] = '\0'; |
| 573 | + for (token2 = token1 + e + 1; *token2 && *token2 == ' '; token2++); |
| 574 | + for (a = 0; token2[a] && token2[a] != '&'; a++); |
| 575 | + if (token2[a]) /* found "&" => another option follows */ |
| 576 | + { |
| 577 | + token2[a] = '\0'; |
| 578 | + str = token2 + a + 1; |
| 579 | + } |
| 580 | + else |
| 581 | + str = token2 + a; |
578 | 582 |
|
579 |
| - conn_keywords[i] = token1; |
580 |
| - conn_values[i] = token2; |
581 |
| - i++; |
| 583 | + conn_keywords[i] = token1; |
| 584 | + conn_values[i] = token2; |
| 585 | + i++; |
| 586 | + } |
| 587 | + else |
| 588 | + /* the parser should not be able to create this invalid option */ |
| 589 | + str = token1 + e; |
582 | 590 | }
|
583 | 591 |
|
584 | 592 | }
|
|
0 commit comments