Changeset 201 for trunk/src/helpers/textv_html.c
- Timestamp:
- Aug 11, 2002, 7:07:59 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/textv_html.c
r167 r201 114 114 CHAR cSaved; 115 115 116 PXHTMLDATA pxhtml; // ptr to XHTMLDATA passed to txvConvertFromHTML 116 PSZ *ppszTitle; // out: title (ptr can be NULL) 117 // V0.9.20 (2002-08-10) [umoeller] 117 118 118 119 // formatting flags while going through the text … … 133 134 134 135 // anchors count 135 USHORT usAnchorIndex; // start with 1136 // USHORT usAnchorIndex; // start with 1 removed V0.9.20 (2002-08-10) [umoeller] 136 137 137 138 // list maintenance … … 421 422 *pSource = pct->cSaved; 422 423 423 pSource = strchr(pct->pSource, '>'); 424 if (pSource) 424 if (pSource = strchr(pct->pSource, '>')) 425 425 { 426 PSZ pNextOpen = strchr(pSource, '<');427 if (pNextOpen )426 PSZ pNextOpen; 427 if (pNextOpen = strchr(pSource, '<')) 428 428 { 429 429 // extract title 430 pct->pxhtml->pszTitle = strhSubstr(pSource + 1, pNextOpen); 430 if (pct->ppszTitle) 431 *(pct->ppszTitle) = strhSubstr(pSource + 1, pNextOpen); 432 // adjusted V0.9.20 (2002-08-10) [umoeller] 431 433 432 434 if (strnicmp(pNextOpen + 1, "/TITLE", 6) == 0) … … 434 436 // closing /TITLE tag found: 435 437 // search on after that 436 pct->pNewSource = strchr(pNextOpen, '>'); 437 if (pct->pNewSource) 438 if (pct->pNewSource = strchr(pNextOpen, '>')) 438 439 pct->pNewSource++; 439 440 } … … 806 807 { 807 808 CHAR szAnchor[10]; 809 PSZ pHREF = NULL; 808 810 809 811 pct->fInLink = FALSE; 810 812 811 if ( (pct->pszAttributes) && (pct->pxhtml)) // points into main source buffer813 if (pct->pszAttributes) 812 814 { 813 815 // we have attributes: 814 PSZ pszClosingTag = strchr(pct->pszAttributes, '>');815 if (pszClosingTag )816 PSZ pszClosingTag; 817 if (pszClosingTag = strchr(pct->pszAttributes, '>')) 816 818 { 817 819 ULONG ulOfs = 0; … … 822 824 */ 823 825 824 PSZ pHREF = strhGetTextAttr(pct->pszAttributes, "HREF", &ulOfs), 825 pNAME = 0; 826 PSZ pNAME = 0; 826 827 827 828 // replace '>' with null char to mark end of search 828 829 *pszClosingTag = 0; 829 830 830 if (pHREF) 831 { 831 if (pHREF = strhGetTextAttr(pct->pszAttributes, "HREF", &ulOfs)) 832 832 // OK, we got a link target: 833 // create a link item and append it to the output list834 PXHTMLLINK pNewLink = (PXHTMLLINK)malloc(sizeof(XHTMLLINK));835 memset(pNewLink, 0, sizeof(XHTMLLINK));836 837 833 pct->fInLink = TRUE; 838 839 // this starts with anchor 1840 pNewLink->usLinkIndex = ++pct->usAnchorIndex;841 pNewLink->pszTargetFile = pHREF;842 834 // do not free 843 lstAppendItem(&pct->pxhtml->llLinks, pNewLink);844 }845 835 846 836 /* … … 849 839 */ 850 840 851 pNAME = strhGetTextAttr(pct->pszAttributes, "NAME", &ulOfs); 852 if (pNAME) 841 if (pNAME = strhGetTextAttr(pct->pszAttributes, "NAME", &ulOfs)) 853 842 { 854 843 AppendString(pct, … … 860 849 free(pNAME); 861 850 } 851 862 852 // restore '>' 863 853 *pszClosingTag = '>'; … … 865 855 } 866 856 867 if (p ct->fInLink)857 if (pHREF) 868 858 { 869 sprintf(szAnchor, "%04hX", pct->usAnchorIndex);870 859 AppendString(pct, 871 TXVESC_LINK );860 TXVESC_LINK_BEGIN); 872 861 AppendString(pct, 873 szAnchor); 862 pHREF); 863 // must be terminated with 0xFF 864 AppendChar(pct, 0xFF); 865 866 free(pHREF); 874 867 } 875 868 } … … 880 873 { 881 874 AppendString(pct, 882 TXVESC_LINK "####");875 TXVESC_LINK_END); 883 876 pct->fInLink = FALSE; 884 877 } … … 2051 2044 * 2052 2045 *@@added V0.9.3 (2000-05-06) [umoeller] 2046 *@@changed V0.9.20 (2002-08-10) [umoeller]: changed prototype 2053 2047 */ 2054 2048 2055 BOOL txvConvertFromHTML( char **ppszText,2056 P VOID pxhtml, // out: various config data (PXHTMLDATA)2049 BOOL txvConvertFromHTML(PSZ *ppszText, // in/out: text (gets reallocated) 2050 PSZ *ppszTitle, // out: if != NULL, receives malloc'd buffer with HTML title 2057 2051 PULONG pulProgress, // out: progress (ptr can be NULL) 2058 2052 PBOOL pfCancel) // in: cancel flag (ptr can be NULL) … … 2062 2056 ULONG cbSource = strlen(*ppszText); 2063 2057 2064 XHTMLDATA xhtmlTemp = {0};2065 BOOL fUsingTemp = FALSE;2066 2058 COPYTARGET ct = {0}; 2067 2059 2068 2060 lstInit(&ct.llLists, 2069 2061 TRUE); // free items 2062 2063 ct.ppszTitle = ppszTitle; // V0.9.20 (2002-08-10) [umoeller] 2064 // can be NULL 2070 2065 2071 2066 ct.pSource = *ppszText; 2072 2067 // skip leading spaces 2073 2068 ct.fSkipNextSpace = TRUE; 2074 ct.pxhtml = (PXHTMLDATA)pxhtml;2075 if (ct.pxhtml == NULL) // not specified:2076 {2077 ct.pxhtml = &xhtmlTemp;2078 fUsingTemp = TRUE;2079 }2080 2081 lstInit(&ct.pxhtml->llLinks, TRUE); // auto-free2082 2069 2083 2070 // step 2: … … 2229 2216 lstClear(&ct.llLists); 2230 2217 2231 if (fUsingTemp)2232 {2233 if (xhtmlTemp.pszTitle)2234 free(xhtmlTemp.pszTitle);2235 lstClear(&xhtmlTemp.llLinks);2236 // ### better really clear this... there are PSZ's inside2237 }2238 2239 2218 return brc; 2240 2219 }
Note:
See TracChangeset
for help on using the changeset viewer.