/ Call the Flex preparser to convert a date format to a sscanf input */ format and a Strftime output format. Flag if not 0 indicates that */ non quoted blanks are not included in the output format. */ /
| 665 | /* non quoted blanks are not included in the output format. */ |
| 666 | /***********************************************************************/ |
| 667 | PDTP MakeDateFormat(PGLOBAL g, PCSZ dfmt, bool in, bool out, int flag) |
| 668 | { |
| 669 | int rc; |
| 670 | PDTP pdp = (PDTP)PlugSubAlloc(g, NULL, sizeof(DATPAR)); |
| 671 | |
| 672 | if (trace(1)) |
| 673 | htrc("MakeDateFormat: dfmt=%s\n", dfmt); |
| 674 | |
| 675 | memset(pdp, 0, sizeof(DATPAR)); |
| 676 | pdp->Format = pdp->Curp = PlugDup(g, dfmt); |
| 677 | pdp->Outsize = 2 * strlen(dfmt) + 1; |
| 678 | |
| 679 | if (in) |
| 680 | pdp->InFmt = (char*)PlugSubAlloc(g, NULL, pdp->Outsize); |
| 681 | |
| 682 | if (out) |
| 683 | pdp->OutFmt = (char*)PlugSubAlloc(g, NULL, pdp->Outsize); |
| 684 | |
| 685 | pdp->Flag = flag; |
| 686 | |
| 687 | /*********************************************************************/ |
| 688 | /* Call the FLEX generated parser. In multi-threading mode the next */ |
| 689 | /* instruction is protected by mutex fmdflex using static variables. */ |
| 690 | /*********************************************************************/ |
| 691 | pthread_mutex_lock(&parmut); |
| 692 | rc = fmdflex(pdp); |
| 693 | pthread_mutex_unlock(&parmut); |
| 694 | |
| 695 | if (trace(1)) |
| 696 | htrc("Done: in=%s out=%s rc=%d\n", SVP(pdp->InFmt), SVP(pdp->OutFmt), rc); |
| 697 | |
| 698 | return pdp; |
| 699 | } // end of MakeDateFormat |
| 700 | |
| 701 | /***********************************************************************/ |
| 702 | /* Extract the date from a formatted string according to format. */ |
no test coverage detected