| 1 |
|
| /*################################################################################### |
| 2 |
|
| # |
| 3 |
|
| # Embperl - Copyright (c) 1997-2008 Gerald Richter / ecos gmbh www.ecos.de |
| 4 |
|
| # Embperl - Copyright (c) 2008-2015 Gerald Richter |
| 5 |
|
| # Embperl - Copyright (c) 2015-2023 actevy.io |
| 6 |
|
| # |
| 7 |
|
| # You may distribute under the terms of either the GNU General Public |
| 8 |
|
| # License or the Artistic License, as specified in the Perl README file. |
| 9 |
|
| # |
| 10 |
|
| # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR |
| 11 |
|
| # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
| 12 |
|
| # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 13 |
|
| # |
| 14 |
|
| ###################################################################################*/ |
| 15 |
|
| |
| 16 |
|
| |
| 17 |
|
| #include "ep.h" |
| 18 |
|
| #include "epmacro.h" |
| 19 |
|
| |
| 20 |
|
| |
| 21 |
|
| |
| 22 |
|
| struct tTokenCmp |
| 23 |
|
| { |
| 24 |
|
| char * pStart ; |
| 25 |
|
| char * pCurr ; |
| 26 |
|
| int nLen ; |
| 27 |
|
| } ; |
| 28 |
|
| |
| 29 |
|
| |
| 30 |
|
| |
| 31 |
|
| struct tTokenTable DefaultTokenTable ; |
| 32 |
|
| |
| 33 |
|
| |
| 34 |
|
| #define parse_malloc(a,b) malloc(b) |
| 35 |
|
| |
| 36 |
|
| /* ------------------------------------------------------------------------ */ |
| 37 |
|
| /* compare tokens */ |
| 38 |
|
| /* ------------------------------------------------------------------------ */ |
| 39 |
|
| |
| 40 |
0 |
| static int CmpToken (/*in*/ const void * p1, |
| 41 |
|
| /*in*/ const void * p2) |
| 42 |
|
| |
| 43 |
|
| { |
| 44 |
0 |
| return strcmp (*((const char * *)p1), *((const char * *)p2)) ; |
| 45 |
|
| } |
| 46 |
|
| |
| 47 |
|
| /* ------------------------------------------------------------------------ */ |
| 48 |
|
| /* compare tokens */ |
| 49 |
|
| /* ------------------------------------------------------------------------ */ |
| 50 |
|
| |
| 51 |
0 |
| static int RevCmpToken (/*in*/ const void * p1, |
| 52 |
|
| /*in*/ const void * p2) |
| 53 |
|
| |
| 54 |
|
| { |
| 55 |
0 |
| return strcmp (*((const char * *)p2), *((const char * *)p1)) ; |
| 56 |
|
| } |
| 57 |
|
| |
| 58 |
|
| /* ------------------------------------------------------------------------ */ |
| 59 |
|
| /* compare tokens for descending order */ |
| 60 |
|
| /* ------------------------------------------------------------------------ */ |
| 61 |
|
| |
| 62 |
0 |
| static int CmpTokenDesc (/*in*/ const void * p1, |
| 63 |
|
| /*in*/ const void * p2) |
| 64 |
|
| |
| 65 |
|
| { |
| 66 |
0 |
| int i = strcmp (*((const char * *)p2), *((const char * *)p1)) ; |
| 67 |
0 |
▶ | return i?i:strcmp (((const char * *)p1)[1], ((const char * *)p2)[1]) ; |
Branch: 1 branch
| Branch | True | False | Total |
| return i?i:strcmp (((const char * *)p1)[1], ((const char * *)p2)[1]) ; |
0 |
0 |
0 |
|
| 68 |
|
| } |
| 69 |
|
| |
| 70 |
|
| |
| 71 |
|
| |
| 72 |
|
| /* ------------------------------------------------------------------------ */ |
| 73 |
|
| /* */ |
| 74 |
|
| /* CheckProcInfo */ |
| 75 |
|
| /* */ |
| 76 |
|
| /* Check for processor information */ |
| 77 |
|
| /* */ |
| 78 |
|
| /* ------------------------------------------------------------------------ */ |
| 79 |
|
| |
| 80 |
0 |
| static int CheckProcInfo (/*i/o*/ register req * r, |
| 81 |
|
| /*in*/ HV * pHash, |
| 82 |
|
| /*in*/ struct tToken * pToken, |
| 83 |
|
| /*i/o*/ void * * ppCompilerInfo) |
| 84 |
|
| |
| 85 |
|
| |
| 86 |
|
| { |
| 87 |
|
| HE * pEntry ; |
| 88 |
|
| char * pKey ; |
| 89 |
|
| SV * * ppSV ; |
| 90 |
|
| SV * pSVValue ; |
| 91 |
|
| I32 l ; |
| 92 |
|
| HV * pHVProcInfo ; |
| 93 |
|
| int n ; |
| 94 |
|
| int i ; |
| 95 |
|
| int m ; |
| 96 |
|
| typedef struct tSortToken |
| 97 |
|
| { |
| 98 |
|
| char * pKey ; |
| 99 |
|
| SV * pSVValue ; |
| 100 |
|
| } tSortToken ; |
| 101 |
|
| tSortToken * pSortTokenHash ; |
| 102 |
|
| epTHX ; |
| 103 |
|
| |
| 104 |
0 |
| ppSV = hv_fetch(pHash, "procinfo", sizeof ("procinfo") - 1, 0) ; |
| 105 |
0 |
▶ | if (ppSV != NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (ppSV != NULL) |
0 |
0 |
0 |
|
| 106 |
|
| { |
| 107 |
0 |
▶ | if (*ppSV == NULL || !SvROK (*ppSV) || SvTYPE (SvRV (*ppSV)) != SVt_PVHV) |
Branch: 3 branches
| Branch | True | False | Total |
| if (*ppSV == NULL || !SvROK (*ppSV) || SvTYPE (SvRV (*ppSV)) != SVt_PVHV) |
0 |
0 |
0 |
| if (*ppSV == NULL || !SvROK (*ppSV) || SvTYPE (SvRV (*ppSV)) != SVt_PVHV) |
0 |
0 |
0 |
| if (*ppSV == NULL || !SvROK (*ppSV) || SvTYPE (SvRV (*ppSV)) != SVt_PVHV) |
0 |
0 |
0 |
|
| 108 |
|
| { |
| 109 |
0 |
| strncpy (r -> errdat1, "BuildTokenHash", sizeof (r -> errdat1)) ; |
| 110 |
0 |
| sprintf (r -> errdat2, "%s => procinfo", pToken -> sText) ; |
| 111 |
0 |
| return rcNotHashRef ; |
| 112 |
|
| } |
| 113 |
|
| |
| 114 |
0 |
| pHVProcInfo = (HV *)SvRV (*ppSV) ; |
| 115 |
|
| |
| 116 |
0 |
| m = 0 ; |
| 117 |
0 |
▶ | n = HvKEYS (pHVProcInfo) ; |
Branch: 1 branch
| Branch | True | False | Total |
| n = HvKEYS (pHVProcInfo) ; |
0 |
0 |
0 |
|
| 118 |
0 |
| pSortTokenHash = (tSortToken *)malloc (sizeof (struct tSortToken) * n) ; |
| 119 |
0 |
| hv_iterinit (pHVProcInfo) ; |
| 120 |
0 |
▶ | while ((pEntry = hv_iternext (pHVProcInfo))) |
Branch: 1 branch
| Branch | True | False | Total |
| while ((pEntry = hv_iternext (pHVProcInfo))) |
0 |
0 |
0 |
|
| 121 |
|
| { |
| 122 |
0 |
| pKey = hv_iterkey (pEntry, &l) ; |
| 123 |
0 |
| pSVValue = hv_iterval (pHVProcInfo, pEntry) ; |
| 124 |
|
| |
| 125 |
0 |
| pSortTokenHash[m].pKey = pKey ; |
| 126 |
0 |
| pSortTokenHash[m].pSVValue = pSVValue ; |
| 127 |
0 |
| m++ ; |
| 128 |
|
| } |
| 129 |
|
| |
| 130 |
0 |
| qsort (pSortTokenHash, m, sizeof (struct tSortToken), RevCmpToken) ; |
| 131 |
|
| |
| 132 |
0 |
| i = 0 ; |
| 133 |
0 |
▶ | while (i < m) |
Branch: 1 branch
| Branch | True | False | Total |
| while (i < m) |
0 |
0 |
0 |
|
| 134 |
|
| { |
| 135 |
0 |
| pKey = pSortTokenHash[i].pKey ; |
| 136 |
0 |
| pSVValue = pSortTokenHash[i].pSVValue ; |
| 137 |
0 |
| i++ ; |
| 138 |
|
| |
| 139 |
0 |
▶ | if (pSVValue == NULL || !SvROK (pSVValue) || SvTYPE (SvRV (pSVValue)) != SVt_PVHV) |
Branch: 3 branches
| Branch | True | False | Total |
| if (pSVValue == NULL || !SvROK (pSVValue) || SvTYPE (SvRV (pSVValue)) != SVt_PVHV) |
0 |
0 |
0 |
| if (pSVValue == NULL || !SvROK (pSVValue) || SvTYPE (SvRV (pSVValue)) != SVt_PVHV) |
0 |
0 |
0 |
| if (pSVValue == NULL || !SvROK (pSVValue) || SvTYPE (SvRV (pSVValue)) != SVt_PVHV) |
0 |
0 |
0 |
|
| 140 |
|
| { |
| 141 |
0 |
| strncpy (r -> errdat1, "BuildTokenHash", sizeof (r -> errdat1)) ; |
| 142 |
0 |
| sprintf (r -> errdat2, "%s => procinfo", pToken -> sText) ; |
| 143 |
0 |
| free (pSortTokenHash) ; |
| 144 |
0 |
| return rcNotHashRef ; |
| 145 |
|
| } |
| 146 |
0 |
▶ | if (strcmp (pKey, "embperl") == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp (pKey, "embperl") == 0) |
0 |
0 |
0 |
|
| 147 |
0 |
| embperl_CompileInitItem (r, (HV *)(SvRV (pSVValue)), pToken -> nNodeName, pToken -> nNodeType, 1, ppCompilerInfo) ; |
| 148 |
0 |
▶ | else if (strncmp (pKey, "embperl#", 8) == 0 && (n = atoi (pKey+8)) > 0) |
Branch: 2 branches
| Branch | True | False | Total |
| else if (strncmp (pKey, "embperl#", 8) == 0 && (n = atoi (pKey+8)) > 0) |
0 |
0 |
0 |
| else if (strncmp (pKey, "embperl#", 8) == 0 && (n = atoi (pKey+8)) > 0) |
0 |
0 |
0 |
|
| 149 |
0 |
| embperl_CompileInitItem (r, (HV *)(SvRV (pSVValue)), pToken -> nNodeName, pToken -> nNodeType, n, ppCompilerInfo) ; |
| 150 |
|
| } |
| 151 |
0 |
| free (pSortTokenHash) ; |
| 152 |
|
| } |
| 153 |
|
| |
| 154 |
|
| |
| 155 |
0 |
| return ok ; |
| 156 |
|
| } |
| 157 |
|
| |
| 158 |
|
| |
| 159 |
|
| |
| 160 |
|
| |
| 161 |
|
| |
| 162 |
|
| |
| 163 |
|
| |
| 164 |
|
| /* ------------------------------------------------------------------------ */ |
| 165 |
|
| /* */ |
| 166 |
|
| /* BuildSubTokenTable */ |
| 167 |
|
| /* */ |
| 168 |
|
| /* Build the C token table out of a Perl Hash */ |
| 169 |
|
| /* */ |
| 170 |
|
| /* ------------------------------------------------------------------------ */ |
| 171 |
|
| |
| 172 |
0 |
| static int BuildSubTokenTable (/*i/o*/ register req * r, |
| 173 |
|
| /*in*/ int nLevel, |
| 174 |
|
| /*in*/ HV * pHash, |
| 175 |
|
| /*in*/ const char * pKey, |
| 176 |
|
| /*in*/ const char * pAttr, |
| 177 |
|
| /*in*/ const char * pDefEnd, |
| 178 |
|
| /*i/o*/ void * * ppCompilerInfo, |
| 179 |
|
| /*out*/ struct tTokenTable * * pTokenTable) |
| 180 |
|
| |
| 181 |
|
| |
| 182 |
|
| { |
| 183 |
|
| SV * * ppSV ; |
| 184 |
|
| int rc ; |
| 185 |
|
| epTHX ; |
| 186 |
|
| |
| 187 |
0 |
| nLevel++ ; |
| 188 |
|
| |
| 189 |
0 |
| ppSV = hv_fetch(pHash, (char *)pAttr, strlen (pAttr), 0) ; |
| 190 |
0 |
▶ | if (ppSV != NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (ppSV != NULL) |
0 |
0 |
0 |
|
| 191 |
|
| { |
| 192 |
|
| struct tTokenTable * pNewTokenTable ; |
| 193 |
|
| HV * pSubHash ; |
| 194 |
|
| |
| 195 |
0 |
▶ | if (*ppSV == NULL || !SvROK (*ppSV) || SvTYPE (SvRV (*ppSV)) != SVt_PVHV) |
Branch: 3 branches
| Branch | True | False | Total |
| if (*ppSV == NULL || !SvROK (*ppSV) || SvTYPE (SvRV (*ppSV)) != SVt_PVHV) |
0 |
0 |
0 |
| if (*ppSV == NULL || !SvROK (*ppSV) || SvTYPE (SvRV (*ppSV)) != SVt_PVHV) |
0 |
0 |
0 |
| if (*ppSV == NULL || !SvROK (*ppSV) || SvTYPE (SvRV (*ppSV)) != SVt_PVHV) |
0 |
0 |
0 |
|
| 196 |
|
| { |
| 197 |
0 |
| strncpy (r -> errdat1, "BuildTokenHash", sizeof (r -> errdat1)) ; |
| 198 |
0 |
| sprintf (r -> errdat2, "%s => %s", pKey, pAttr) ; |
| 199 |
0 |
| return rcNotHashRef ; |
| 200 |
|
| } |
| 201 |
|
| |
| 202 |
0 |
| pSubHash = (HV *)SvRV (*ppSV) ; |
| 203 |
0 |
▶ | if ((pNewTokenTable = (struct tTokenTable *)GetHashValueInt (aTHX_ pSubHash, "--cptr", 0)) == NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if ((pNewTokenTable = (struct tTokenTable *)GetHashValueInt (aTHX_ pSubHash, "--cptr", 0)) == NULL) |
0 |
0 |
0 |
|
| 204 |
|
| { |
| 205 |
0 |
▶ | if ((pNewTokenTable = parse_malloc (r, sizeof (struct tTokenTable))) == NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if ((pNewTokenTable = parse_malloc (r, sizeof (struct tTokenTable))) == NULL) |
0 |
0 |
0 |
|
| 206 |
0 |
| return rcOutOfMemory ; |
| 207 |
|
| |
| 208 |
0 |
▶ | if (r -> Component.Config.bDebug & dbgBuildToken) |
Branch: 1 branch
| Branch | True | False | Total |
| if (r -> Component.Config.bDebug & dbgBuildToken) |
0 |
0 |
0 |
|
| 209 |
0 |
| lprintf (r -> pApp, "[%d]TOKEN: %*c-> %s\n", r -> pThread -> nPid, nLevel*2, ' ', pAttr) ; |
| 210 |
0 |
▶ | if ((rc = BuildTokenTable (r, nLevel, NULL, pSubHash, pDefEnd, ppCompilerInfo, pNewTokenTable))) |
Branch: 1 branch
| Branch | True | False | Total |
| if ((rc = BuildTokenTable (r, nLevel, NULL, pSubHash, pDefEnd, ppCompilerInfo, pNewTokenTable))) |
0 |
0 |
0 |
|
| 211 |
0 |
| return rc ; |
| 212 |
0 |
▶ | if (r -> Component.Config.bDebug & dbgBuildToken) |
Branch: 1 branch
| Branch | True | False | Total |
| if (r -> Component.Config.bDebug & dbgBuildToken) |
0 |
0 |
0 |
|
| 213 |
0 |
| lprintf (r -> pApp, "[%d]TOKEN: %*c<- %s\n", r -> pThread -> nPid, nLevel*2, ' ', pAttr) ; |
| 214 |
|
| |
| 215 |
0 |
▶ | if (pNewTokenTable -> numTokens == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pNewTokenTable -> numTokens == 0) |
0 |
0 |
0 |
|
| 216 |
|
| { |
| 217 |
0 |
| strncpy (r -> errdat1, "BuildTokenHash", sizeof (r -> errdat1)) ; |
| 218 |
0 |
| sprintf (r -> errdat2, "%s => %s does not contain any tokens", pKey, pAttr) ; |
| 219 |
0 |
| return rcTokenNotFound ; |
| 220 |
|
| } |
| 221 |
|
| |
| 222 |
0 |
| hv_store(pSubHash, "--cptr", sizeof ("--cptr") - 1, newSViv ((IV)pNewTokenTable), 0) ; |
| 223 |
|
| } |
| 224 |
|
| else |
| 225 |
0 |
▶ | if (r -> Component.Config.bDebug & dbgBuildToken) |
Branch: 1 branch
| Branch | True | False | Total |
| if (r -> Component.Config.bDebug & dbgBuildToken) |
0 |
0 |
0 |
|
| 226 |
0 |
| lprintf (r -> pApp, "[%d]TOKEN: %*c-> %s already build; numTokens=%d\n", r -> pThread -> nPid, nLevel*2, ' ', pAttr, pNewTokenTable->numTokens) ; |
| 227 |
|
| |
| 228 |
|
| |
| 229 |
0 |
| *pTokenTable = pNewTokenTable ; |
| 230 |
0 |
| return ok ; |
| 231 |
|
| } |
| 232 |
|
| |
| 233 |
0 |
| *pTokenTable = NULL ; |
| 234 |
0 |
| return ok ; |
| 235 |
|
| } |
| 236 |
|
| |
| 237 |
|
| |
| 238 |
|
| /* ------------------------------------------------------------------------ */ |
| 239 |
|
| /* */ |
| 240 |
|
| /* BuildTokenTable */ |
| 241 |
|
| /* */ |
| 242 |
|
| /* Build the C token table out of a Perl Hash */ |
| 243 |
|
| /* */ |
| 244 |
|
| /* ------------------------------------------------------------------------ */ |
| 245 |
|
| |
| 246 |
0 |
| int BuildTokenTable (/*i/o*/ register req * r, |
| 247 |
|
| /*in*/ int nLevel, |
| 248 |
|
| /*in*/ const char * sName, |
| 249 |
|
| /*in*/ HV * pTokenHash, |
| 250 |
|
| /*in*/ const char * pDefEnd, |
| 251 |
|
| /*i/o*/ void * * ppCompilerInfo, |
| 252 |
|
| /*out*/ struct tTokenTable * pTokenTable) |
| 253 |
|
| |
| 254 |
|
| |
| 255 |
|
| { |
| 256 |
|
| int rc ; |
| 257 |
|
| SV * pToken ; |
| 258 |
|
| HE * pEntry ; |
| 259 |
|
| char * pKey ; |
| 260 |
|
| const char * c ; |
| 261 |
|
| int numTokens ; |
| 262 |
|
| struct tToken * pTable ; |
| 263 |
|
| struct tToken * p ; |
| 264 |
|
| I32 l ; |
| 265 |
|
| STRLEN len ; |
| 266 |
|
| int n ; |
| 267 |
|
| int m ; |
| 268 |
|
| int i ; |
| 269 |
|
| typedef struct tSortToken |
| 270 |
|
| { |
| 271 |
|
| char * pKey ; |
| 272 |
|
| SV * pToken ; |
| 273 |
|
| } tSortToken ; |
| 274 |
|
| tSortToken * pSortTokenHash ; |
| 275 |
0 |
| unsigned char * pStartChars = pTokenTable -> cStartChars ; |
| 276 |
0 |
| unsigned char * pAllChars = pTokenTable -> cAllChars ; |
| 277 |
|
| epTHX ; |
| 278 |
|
| |
| 279 |
0 |
| tainted = 0 ; |
| 280 |
|
| |
| 281 |
|
| /* r -> Component.Config.bDebug |= dbgBuildToken ; */ |
| 282 |
|
| |
| 283 |
0 |
| memset (pStartChars, 0, sizeof (pTokenTable -> cStartChars)) ; |
| 284 |
0 |
| memset (pAllChars, 0, sizeof (pTokenTable -> cAllChars)) ; |
| 285 |
0 |
| pTokenTable -> bLSearch = 0 ; |
| 286 |
0 |
| pTokenTable -> nDefNodeType = ntypCDATA ; |
| 287 |
0 |
| pTokenTable -> pContainsToken = NULL ; |
| 288 |
0 |
| pTokenTable -> pCompilerInfo = NULL ; |
| 289 |
0 |
| pTokenTable -> sRootNode = NULL ; |
| 290 |
0 |
| pTokenTable -> sName = sName ; |
| 291 |
0 |
▶ | if (ppCompilerInfo == NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (ppCompilerInfo == NULL) |
0 |
0 |
0 |
|
| 292 |
0 |
| ppCompilerInfo = &pTokenTable -> pCompilerInfo ; |
| 293 |
|
| |
| 294 |
0 |
| hv_store(pTokenHash, "--cptr", sizeof ("--cptr") - 1, newSViv ((IV)pTokenTable), 0) ; |
| 295 |
|
| |
| 296 |
0 |
| numTokens = 1 ; |
| 297 |
0 |
| hv_iterinit (pTokenHash) ; |
| 298 |
0 |
▶ | while ((pEntry = hv_iternext (pTokenHash))) |
Branch: 1 branch
| Branch | True | False | Total |
| while ((pEntry = hv_iternext (pTokenHash))) |
0 |
0 |
0 |
|
| 299 |
|
| { |
| 300 |
0 |
| pKey = hv_iterkey (pEntry, &l) ; |
| 301 |
0 |
| pToken = hv_iterval (pTokenHash, pEntry) ; |
| 302 |
0 |
▶ | if (*pKey != '-') |
Branch: 1 branch
| Branch | True | False | Total |
| if (*pKey != '-') |
0 |
0 |
0 |
|
| 303 |
0 |
| numTokens++ ; |
| 304 |
|
| } |
| 305 |
|
| |
| 306 |
0 |
▶ | if ((pTable = parse_malloc (r, sizeof (struct tToken) * numTokens)) == NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if ((pTable = parse_malloc (r, sizeof (struct tToken) * numTokens)) == NULL) |
0 |
0 |
0 |
|
| 307 |
0 |
| return rcOutOfMemory ; |
| 308 |
|
| |
| 309 |
0 |
| n = 0 ; |
| 310 |
0 |
| hv_iterinit (pTokenHash) ; |
| 311 |
0 |
▶ | while ((pEntry = hv_iternext (pTokenHash))) |
Branch: 1 branch
| Branch | True | False | Total |
| while ((pEntry = hv_iternext (pTokenHash))) |
0 |
0 |
0 |
|
| 312 |
|
| { |
| 313 |
0 |
| pKey = hv_iterkey (pEntry, &l) ; |
| 314 |
0 |
| pToken = hv_iterval (pTokenHash, pEntry) ; |
| 315 |
|
| |
| 316 |
0 |
▶ | if (*pKey == '-') |
Branch: 1 branch
| Branch | True | False | Total |
| if (*pKey == '-') |
0 |
0 |
0 |
|
| 317 |
|
| { /* special key */ |
| 318 |
0 |
▶ | if (strcmp (pKey, "-rootnode") == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp (pKey, "-rootnode") == 0) |
0 |
0 |
0 |
|
| 319 |
|
| { |
| 320 |
0 |
| pTokenTable -> sRootNode = sstrdup (r, SvPV((SV *)pToken, len)) ; |
| 321 |
|
| } |
| 322 |
0 |
▶ | if (strcmp (pKey, "-defnodetype") == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp (pKey, "-defnodetype") == 0) |
0 |
0 |
0 |
|
| 323 |
|
| { |
| 324 |
0 |
| pTokenTable -> nDefNodeType = SvIV ((SV *)pToken) ; |
| 325 |
|
| } |
| 326 |
0 |
▶ | else if (strcmp (pKey, "-lsearch") == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (strcmp (pKey, "-lsearch") == 0) |
0 |
0 |
0 |
|
| 327 |
|
| { |
| 328 |
0 |
| pTokenTable -> bLSearch = SvIV ((SV *)pToken) ; |
| 329 |
|
| } |
| 330 |
0 |
▶ | else if (strcmp (pKey, "-contains") == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (strcmp (pKey, "-contains") == 0) |
0 |
0 |
0 |
|
| 331 |
|
| { |
| 332 |
|
| STRLEN l ; |
| 333 |
0 |
| char * c = SvPV (pToken, l) ; |
| 334 |
0 |
▶ | while (*c) |
Branch: 1 branch
| Branch | True | False | Total |
| while (*c) |
0 |
0 |
0 |
|
| 335 |
|
| { |
| 336 |
0 |
| pAllChars [tolower(*c) >> 3] |= 1 << (tolower(*c) & 7) ; |
| 337 |
0 |
| pAllChars [toupper(*c) >> 3] |= 1 << (toupper(*c) & 7) ; |
| 338 |
0 |
| c++ ; |
| 339 |
|
| } |
| 340 |
|
| } |
| 341 |
|
| } |
| 342 |
|
| } |
| 343 |
|
| |
| 344 |
0 |
| m = 0 ; |
| 345 |
0 |
▶ | n = HvKEYS (pTokenHash) ; |
Branch: 1 branch
| Branch | True | False | Total |
| n = HvKEYS (pTokenHash) ; |
0 |
0 |
0 |
|
| 346 |
0 |
| pSortTokenHash = (tSortToken *)malloc (sizeof (struct tSortToken) * n) ; |
| 347 |
0 |
| hv_iterinit (pTokenHash) ; |
| 348 |
0 |
▶ | while ((pEntry = hv_iternext (pTokenHash))) |
Branch: 1 branch
| Branch | True | False | Total |
| while ((pEntry = hv_iternext (pTokenHash))) |
0 |
0 |
0 |
|
| 349 |
|
| { |
| 350 |
0 |
| pKey = hv_iterkey (pEntry, &l) ; |
| 351 |
0 |
| pToken = hv_iterval (pTokenHash, pEntry) ; |
| 352 |
|
| |
| 353 |
0 |
| pSortTokenHash[m].pKey = pKey ; |
| 354 |
0 |
| pSortTokenHash[m].pToken = pToken ; |
| 355 |
0 |
| m++ ; |
| 356 |
|
| } |
| 357 |
|
| |
| 358 |
0 |
| qsort (pSortTokenHash, m, sizeof (struct tSortToken), CmpToken) ; |
| 359 |
|
| |
| 360 |
0 |
| n = 0 ; |
| 361 |
0 |
| i = 0 ; |
| 362 |
0 |
▶ | while (i < m) |
Branch: 1 branch
| Branch | True | False | Total |
| while (i < m) |
0 |
0 |
0 |
|
| 363 |
|
| { |
| 364 |
|
| HV * pHash ; |
| 365 |
|
| struct tTokenTable * pNewTokenTable ; |
| 366 |
|
| char * sContains ; |
| 367 |
|
| char * sC ; |
| 368 |
|
| |
| 369 |
0 |
| pKey = pSortTokenHash[i].pKey ; |
| 370 |
0 |
| pToken = pSortTokenHash[i].pToken ; |
| 371 |
0 |
| i++ ; |
| 372 |
0 |
▶ | if (r -> Component.Config.bDebug & dbgBuildToken) |
Branch: 1 branch
| Branch | True | False | Total |
| if (r -> Component.Config.bDebug & dbgBuildToken) |
0 |
0 |
0 |
|
| 373 |
0 |
| lprintf (r -> pApp, "[%d]TOKENKey: %s\n", r -> pThread -> nPid, pKey) ; |
| 374 |
|
| |
| 375 |
0 |
▶ | if (*pKey != '-') |
Branch: 1 branch
| Branch | True | False | Total |
| if (*pKey != '-') |
0 |
0 |
0 |
|
| 376 |
|
| { |
| 377 |
0 |
▶ | if (!SvROK (pToken) || SvTYPE (SvRV (pToken)) != SVt_PVHV) |
Branch: 2 branches
| Branch | True | False | Total |
| if (!SvROK (pToken) || SvTYPE (SvRV (pToken)) != SVt_PVHV) |
0 |
0 |
0 |
| if (!SvROK (pToken) || SvTYPE (SvRV (pToken)) != SVt_PVHV) |
0 |
0 |
0 |
|
| 378 |
|
| { |
| 379 |
0 |
| strncpy (r -> errdat1, "BuildTokenHash", sizeof (r -> errdat1)) ; |
| 380 |
0 |
| sprintf (r -> errdat2, "%s", pKey) ; |
| 381 |
0 |
| return rcNotHashRef ; |
| 382 |
|
| } |
| 383 |
0 |
| pHash = (HV *)SvRV (pToken) ; |
| 384 |
|
| |
| 385 |
0 |
| p = &pTable[n] ; |
| 386 |
0 |
| p -> sName = pKey ; |
| 387 |
0 |
| p -> sText = GetHashValueStrDup (aTHX_ r -> pThread -> pMainPool, pHash, "text", "") ; |
| 388 |
0 |
▶ | p -> nTextLen = p -> sText?strlen (p -> sText):0 ; |
Branch: 1 branch
| Branch | True | False | Total |
| p -> nTextLen = p -> sText?strlen (p -> sText):0 ; |
0 |
0 |
0 |
|
| 389 |
0 |
| p -> sEndText = GetHashValueStrDup (aTHX_ r -> pThread -> pMainPool, pHash, "end", (char *)pDefEnd) ; |
| 390 |
0 |
| p -> sNodeName = GetHashValueStrDup (aTHX_ r -> pThread -> pMainPool, pHash, "nodename", NULL) ; |
| 391 |
0 |
| p -> nNodeType = (tNodeType)GetHashValueInt (aTHX_ pHash, "nodetype", ntypTag) ; |
| 392 |
0 |
| p -> bUnescape = GetHashValueInt (aTHX_ pHash, "unescape", 0) ; |
| 393 |
0 |
| p -> bAddFlags = GetHashValueInt (aTHX_ pHash, "addflags", 0) ; |
| 394 |
0 |
| p -> nCDataType = (tNodeType)GetHashValueInt (aTHX_ pHash, "cdatatype", pTokenTable -> nDefNodeType) ; |
| 395 |
0 |
| p -> nForceType = (tNodeType)GetHashValueInt (aTHX_ pHash, "forcetype", 0) ; |
| 396 |
0 |
▶ | p -> bRemoveSpaces = GetHashValueInt (aTHX_ pHash, "removespaces", p -> nNodeType != ntypCDATA?2:0) ; |
Branch: 1 branch
| Branch | True | False | Total |
| p -> bRemoveSpaces = GetHashValueInt (aTHX_ pHash, "removespaces", p -> nNodeType != ntypCDATA?2:0) ; |
0 |
0 |
0 |
|
| 397 |
0 |
| p -> bInsideMustExist = GetHashValueInt (aTHX_ pHash, "insidemustexist", 0) ; |
| 398 |
0 |
| p -> bMatchAll = GetHashValueInt (aTHX_ pHash, "matchall", 0) ; |
| 399 |
0 |
| p -> bDontEat = GetHashValueInt (aTHX_ pHash, "donteat", 0) ; |
| 400 |
0 |
| p -> bExitInside= GetHashValueInt (aTHX_ pHash, "exitinside", 0) ; |
| 401 |
0 |
| p -> bAddFirstChild = GetHashValueInt (aTHX_ pHash, "addfirstchild", 0) ; |
| 402 |
0 |
| p -> pStartTag = (struct tToken *)GetHashValueStrDup (aTHX_ r -> pThread -> pMainPool, pHash, "starttag", NULL) ; |
| 403 |
0 |
| p -> pEndTag = (struct tToken *)GetHashValueStrDup (aTHX_ r -> pThread -> pMainPool, pHash, "endtag", NULL) ; |
| 404 |
0 |
| p -> sParseTimePerlCode = GetHashValueStrDup (aTHX_ r -> pThread -> pMainPool, pHash, "parsetimeperlcode", NULL) ; |
| 405 |
0 |
▶ | if ((sC = sContains = GetHashValueStrDup (aTHX_ r -> pThread -> pMainPool, pHash, "contains", NULL))) |
Branch: 1 branch
| Branch | True | False | Total |
| if ((sC = sContains = GetHashValueStrDup (aTHX_ r -> pThread -> pMainPool, pHash, "contains", NULL))) |
0 |
0 |
0 |
|
| 406 |
|
| { |
| 407 |
|
| unsigned char * pC ; |
| 408 |
0 |
▶ | if ((p -> pContains = parse_malloc (r, sizeof (tCharMap))) == NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if ((p -> pContains = parse_malloc (r, sizeof (tCharMap))) == NULL) |
0 |
0 |
0 |
|
| 409 |
0 |
| return rcOutOfMemory ; |
| 410 |
|
| |
| 411 |
0 |
| pC = p -> pContains ; |
| 412 |
0 |
| memset (pC, 0, sizeof (tCharMap)) ; |
| 413 |
0 |
▶ | while (*sContains) |
Branch: 1 branch
| Branch | True | False | Total |
| while (*sContains) |
0 |
0 |
0 |
|
| 414 |
|
| { |
| 415 |
0 |
| pC[*sContains >> 3] |= 1 << (*sContains & 7) ; |
| 416 |
0 |
| pStartChars [*sContains >> 3] |= 1 << (*sContains & 7) ; |
| 417 |
0 |
| pStartChars [*sContains >> 3] |= 1 << (*sContains & 7) ; |
| 418 |
0 |
| sContains++ ; |
| 419 |
|
| } |
| 420 |
|
| } |
| 421 |
|
| else |
| 422 |
0 |
| p -> pContains = NULL ; |
| 423 |
|
| |
| 424 |
0 |
▶ | if (p -> bMatchAll) |
Branch: 1 branch
| Branch | True | False | Total |
| if (p -> bMatchAll) |
0 |
0 |
0 |
|
| 425 |
|
| { |
| 426 |
0 |
| memset (pStartChars, 0xff, sizeof(tCharMap)) ; |
| 427 |
|
| } |
| 428 |
0 |
▶ | else if ((c = p -> sText)) |
Branch: 1 branch
| Branch | True | False | Total |
| else if ((c = p -> sText)) |
0 |
0 |
0 |
|
| 429 |
|
| { |
| 430 |
0 |
| pStartChars [toupper(*c) >> 3] |= 1 << (toupper(*c) & 7) ; |
| 431 |
0 |
| pStartChars [tolower(*c) >> 3] |= 1 << (tolower(*c) & 7) ; |
| 432 |
|
| |
| 433 |
0 |
▶ | while (*c) |
Branch: 1 branch
| Branch | True | False | Total |
| while (*c) |
0 |
0 |
0 |
|
| 434 |
|
| { |
| 435 |
0 |
| pAllChars [tolower(*c) >> 3] |= 1 << (tolower(*c) & 7) ; |
| 436 |
0 |
| pAllChars [toupper(*c) >> 3] |= 1 << (toupper(*c) & 7) ; |
| 437 |
0 |
| c++ ; |
| 438 |
|
| } |
| 439 |
|
| } |
| 440 |
|
| |
| 441 |
0 |
▶ | if (r -> Component.Config.bDebug & dbgBuildToken) |
Branch: 1 branch
| Branch | True | False | Total |
| if (r -> Component.Config.bDebug & dbgBuildToken) |
0 |
0 |
0 |
|
| 442 |
0 |
▶ | lprintf (r -> pApp, "[%d]TOKEN: %*c%s ... %s unesc=%d nodetype=%d, cdatatype=%d, nodename=%s contains='%s' addfirstchild=%d\n", r -> pThread -> nPid, nLevel*2, ' ', p -> sText, p -> sEndText, p -> bUnescape, p -> nNodeType, p -> nCDataType, p -> sNodeName?p -> sNodeName:"<null>", sC?sC:"", p -> bAddFirstChild) ; |
Branch: 2 branches
| Branch | True | False | Total |
| lprintf (r -> pApp, "[%d]TOKEN: %*c%s ... %s unesc=%d nodetype=%d, cdatatype=%d, nodename=%s contains='%s' addfirstchild=%d\n", r -> pThread -> nPid, nLevel*2, ' ', p -> sText, p -> sEndText, p -> bUnescape, p -> nNodeType, p -> nCDataType, p -> sNodeName?p -> sNodeName:"<null>", sC?sC:"", p -> bAddFirstChild) ; |
0 |
0 |
0 |
| lprintf (r -> pApp, "[%d]TOKEN: %*c%s ... %s unesc=%d nodetype=%d, cdatatype=%d, nodename=%s contains='%s' addfirstchild=%d\n", r -> pThread -> nPid, nLevel*2, ' ', p -> sText, p -> sEndText, p -> bUnescape, p -> nNodeType, p -> nCDataType, p -> sNodeName?p -> sNodeName:"<null>", sC?sC:"", p -> bAddFirstChild) ; |
0 |
0 |
0 |
|
| 443 |
|
| |
| 444 |
0 |
▶ | if (p -> sNodeName) |
Branch: 1 branch
| Branch | True | False | Total |
| if (p -> sNodeName) |
0 |
0 |
0 |
|
| 445 |
|
| { |
| 446 |
0 |
▶ | if (p -> sNodeName[0] != '!') |
Branch: 1 branch
| Branch | True | False | Total |
| if (p -> sNodeName[0] != '!') |
0 |
0 |
0 |
|
| 447 |
0 |
| p -> nNodeName = String2Ndx (r -> pApp, p -> sNodeName, strlen (p -> sNodeName)) ; |
| 448 |
|
| else |
| 449 |
0 |
| p -> nNodeName = String2UniqueNdx (r -> pApp, p -> sNodeName + 1, strlen (p -> sNodeName + 1)) ; |
| 450 |
|
| } |
| 451 |
|
| else |
| 452 |
0 |
| p -> nNodeName = String2Ndx (r -> pApp, p -> sText, strlen (p -> sText)) ; |
| 453 |
|
| |
| 454 |
|
| |
| 455 |
0 |
▶ | if ((rc = CheckProcInfo (r, pHash, p, ppCompilerInfo)) != ok) |
Branch: 1 branch
| Branch | True | False | Total |
| if ((rc = CheckProcInfo (r, pHash, p, ppCompilerInfo)) != ok) |
0 |
0 |
0 |
|
| 456 |
0 |
| return rc ; |
| 457 |
|
| |
| 458 |
|
| |
| 459 |
0 |
▶ | if ((rc = BuildSubTokenTable (r, nLevel, pHash, pKey, "follow", p -> sEndText, ppCompilerInfo, &pNewTokenTable))) |
Branch: 1 branch
| Branch | True | False | Total |
| if ((rc = BuildSubTokenTable (r, nLevel, pHash, pKey, "follow", p -> sEndText, ppCompilerInfo, &pNewTokenTable))) |
0 |
0 |
0 |
|
| 460 |
0 |
| return rc ; |
| 461 |
0 |
| p -> pFollowedBy = pNewTokenTable ; |
| 462 |
|
| |
| 463 |
0 |
▶ | if ((rc = BuildSubTokenTable (r, nLevel, pHash, pKey, "inside", "", ppCompilerInfo, &pNewTokenTable))) |
Branch: 1 branch
| Branch | True | False | Total |
| if ((rc = BuildSubTokenTable (r, nLevel, pHash, pKey, "inside", "", ppCompilerInfo, &pNewTokenTable))) |
0 |
0 |
0 |
|
| 464 |
0 |
| return rc ; |
| 465 |
0 |
| p -> pInside = pNewTokenTable ; |
| 466 |
|
| |
| 467 |
0 |
| n++ ; |
| 468 |
|
| } |
| 469 |
|
| } |
| 470 |
|
| |
| 471 |
0 |
| free (pSortTokenHash) ; |
| 472 |
|
| |
| 473 |
0 |
▶ | qsort (pTable, numTokens - 1, sizeof (struct tToken), pTokenTable -> bLSearch?CmpTokenDesc:CmpToken) ; |
Branch: 1 branch
| Branch | True | False | Total |
| qsort (pTable, numTokens - 1, sizeof (struct tToken), pTokenTable -> bLSearch?CmpTokenDesc:CmpToken) ; |
0 |
0 |
0 |
|
| 474 |
|
| |
| 475 |
|
| |
| 476 |
0 |
▶ | for (i = 0; i < n; i++) |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < n; i++) |
0 |
0 |
0 |
|
| 477 |
|
| { |
| 478 |
0 |
▶ | if (pTable[i].pContains && !pTable[i].sText[0]) |
Branch: 2 branches
| Branch | True | False | Total |
| if (pTable[i].pContains && !pTable[i].sText[0]) |
0 |
0 |
0 |
| if (pTable[i].pContains && !pTable[i].sText[0]) |
0 |
0 |
0 |
|
| 479 |
0 |
| pTokenTable -> pContainsToken = &pTable[i] ; |
| 480 |
0 |
▶ | if (pTable[i].pEndTag) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pTable[i].pEndTag) |
0 |
0 |
0 |
|
| 481 |
|
| { |
| 482 |
0 |
| char * s = (char *)pTable[i].pEndTag ; |
| 483 |
|
| int j ; |
| 484 |
|
| |
| 485 |
0 |
| pTable[i].pEndTag = NULL ; |
| 486 |
0 |
▶ | for (j = 0; j < n; j++) |
Branch: 1 branch
| Branch | True | False | Total |
| for (j = 0; j < n; j++) |
0 |
0 |
0 |
|
| 487 |
|
| { |
| 488 |
0 |
▶ | if (strcmp (pTable[j].sName, s) == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp (pTable[j].sName, s) == 0) |
0 |
0 |
0 |
|
| 489 |
0 |
| pTable[i].pEndTag = &pTable[j] ; |
| 490 |
|
| } |
| 491 |
0 |
▶ | if (pTable[i].pEndTag == NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pTable[i].pEndTag == NULL) |
0 |
0 |
0 |
|
| 492 |
|
| { |
| 493 |
0 |
| strncpy (r -> errdat1, "BuildTokenHash", sizeof (r -> errdat1)) ; |
| 494 |
0 |
| sprintf (r -> errdat2, " EndTag %s for %s not found", pTable[i].sText, s) ; |
| 495 |
0 |
| return rcTokenNotFound ; |
| 496 |
|
| } |
| 497 |
|
| |
| 498 |
|
| } |
| 499 |
0 |
▶ | if (pTable[i].pStartTag) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pTable[i].pStartTag) |
0 |
0 |
0 |
|
| 500 |
|
| { |
| 501 |
0 |
| char * s = (char *)pTable[i].pStartTag ; |
| 502 |
|
| int j ; |
| 503 |
|
| |
| 504 |
0 |
| pTable[i].pStartTag = NULL ; |
| 505 |
0 |
▶ | for (j = 0; j < n; j++) |
Branch: 1 branch
| Branch | True | False | Total |
| for (j = 0; j < n; j++) |
0 |
0 |
0 |
|
| 506 |
|
| { |
| 507 |
0 |
▶ | if (strcmp (pTable[j].sName, s) == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp (pTable[j].sName, s) == 0) |
0 |
0 |
0 |
|
| 508 |
0 |
| pTable[i].pStartTag = &pTable[j] ; |
| 509 |
|
| } |
| 510 |
0 |
▶ | if (pTable[i].pStartTag == NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pTable[i].pStartTag == NULL) |
0 |
0 |
0 |
|
| 511 |
|
| { |
| 512 |
0 |
| strncpy (r -> errdat1, "BuildTokenHash", sizeof (r -> errdat1)) ; |
| 513 |
0 |
| sprintf (r -> errdat2, " StartTag %s for %s not found", pTable[i].sText, s) ; |
| 514 |
0 |
| return rcTokenNotFound ; |
| 515 |
|
| } |
| 516 |
|
| |
| 517 |
|
| } |
| 518 |
|
| } |
| 519 |
|
| |
| 520 |
|
| |
| 521 |
0 |
| p = &pTable[n] ; |
| 522 |
0 |
| p -> sText = "" ; |
| 523 |
0 |
| p -> nTextLen = 0 ; |
| 524 |
0 |
| p -> sEndText = "" ; |
| 525 |
0 |
| p -> pFollowedBy = NULL ; |
| 526 |
0 |
| p -> pInside = NULL ; |
| 527 |
|
| |
| 528 |
|
| |
| 529 |
0 |
| pTokenTable -> pTokens = pTable ; |
| 530 |
0 |
| pTokenTable -> numTokens = numTokens - 1 ; |
| 531 |
|
| |
| 532 |
0 |
| return ok ; |
| 533 |
|
| } |
| 534 |
|
| |
| 535 |
|
| /* ------------------------------------------------------------------------ */ |
| 536 |
|
| /* */ |
| 537 |
|
| /* ExecParseTimeCode */ |
| 538 |
|
| /* */ |
| 539 |
|
| /* executes Perl code at parse time */ |
| 540 |
|
| /* */ |
| 541 |
|
| /* ------------------------------------------------------------------------ */ |
| 542 |
|
| |
| 543 |
0 |
| static int ExecParseTimeCode (/*i/o*/ register req * r, |
| 544 |
|
| /*in */ struct tToken * pToken, |
| 545 |
|
| /*in */ char * pCurr, |
| 546 |
|
| int nLen, |
| 547 |
|
| int nLinenumber) |
| 548 |
|
| |
| 549 |
|
| { |
| 550 |
|
| SV * pSV ; |
| 551 |
|
| int rc ; |
| 552 |
0 |
| const char * sPCode = pToken -> sParseTimePerlCode ; |
| 553 |
0 |
| int plen = strlen (sPCode) ; |
| 554 |
|
| char * sCode ; |
| 555 |
|
| const char * p ; |
| 556 |
|
| int n ; |
| 557 |
|
| SV * args[2] ; |
| 558 |
|
| epTHX ; |
| 559 |
|
| |
| 560 |
0 |
▶ | if ((p = strnstr (sPCode, "%%", nLen))) |
Branch: 1 branch
| Branch | True | False | Total |
| if ((p = strnstr (sPCode, "%%", nLen))) |
0 |
0 |
0 |
|
| 561 |
|
| { |
| 562 |
0 |
| sCode = parse_malloc (r, nLen + plen + 1) ; |
| 563 |
0 |
| n = p - sPCode ; |
| 564 |
0 |
| memcpy (sCode, sPCode, n) ; |
| 565 |
0 |
| memcpy (sCode + n, pCurr, nLen) ; |
| 566 |
0 |
| memcpy (sCode + n + nLen, sPCode + n + 2, plen - n - 2) ; |
| 567 |
0 |
| nLen = nLen + plen - 2 ; |
| 568 |
0 |
| sCode[nLen] = '\0' ; |
| 569 |
|
| } |
| 570 |
|
| else |
| 571 |
|
| { |
| 572 |
0 |
| sCode = (char *)sPCode ; |
| 573 |
0 |
| nLen = plen ; |
| 574 |
|
| } |
| 575 |
|
| |
| 576 |
0 |
▶ | if (nLen && r -> Component.Config.bDebug & dbgParse) |
Branch: 2 branches
| Branch | True | False | Total |
| if (nLen && r -> Component.Config.bDebug & dbgParse) |
0 |
0 |
0 |
| if (nLen && r -> Component.Config.bDebug & dbgParse) |
0 |
0 |
0 |
|
| 577 |
0 |
| lprintf (r -> pApp, "[%d]PARSE: ParseTimeCode: %*.*s\n", r -> pThread -> nPid, nLen, nLen, sCode) ; |
| 578 |
|
| |
| 579 |
0 |
| pSV = newSVpvf("package %s ;\nmy ($_ep_req) = @_;\n#line %d \"%s\"\n%*.*s", |
| 580 |
|
| "Embperl::Parser" /*r -> Component.sEvalPackage*/, nLinenumber, r -> Component.sSourcefile, nLen, nLen, sCode) ; |
| 581 |
|
| newSVpvf2(pSV) ; |
| 582 |
0 |
| args[0] = r -> _perlsv ; |
| 583 |
0 |
▶ | if ((rc = EvalDirect (r, pSV, 1, args)) != ok) |
Branch: 1 branch
| Branch | True | False | Total |
| if ((rc = EvalDirect (r, pSV, 1, args)) != ok) |
0 |
0 |
0 |
|
| 584 |
0 |
| LogError (r, rc) ; |
| 585 |
0 |
| SvREFCNT_dec(pSV); |
| 586 |
|
| |
| 587 |
0 |
| return rc ; |
| 588 |
|
| } |
| 589 |
|
| |
| 590 |
|
| |
| 591 |
|
| |
| 592 |
|
| |
| 593 |
|
| |
| 594 |
|
| |
| 595 |
|
| /* ------------------------------------------------------------------------ */ |
| 596 |
|
| /* compare tokens */ |
| 597 |
|
| /* ------------------------------------------------------------------------ */ |
| 598 |
|
| |
| 599 |
0 |
| static int CmpTokenN (/*in*/ const void * p1, |
| 600 |
|
| /*in*/ const void * p2) |
| 601 |
|
| |
| 602 |
|
| { |
| 603 |
0 |
| struct tTokenCmp * c = (struct tTokenCmp *)p1 ; |
| 604 |
|
| int i ; |
| 605 |
0 |
| int p1Len = c -> nLen ; |
| 606 |
0 |
| int p2Len = ((struct tToken *)p2) -> nTextLen ; |
| 607 |
|
| |
| 608 |
0 |
▶ | if ((i = strnicmp (c -> pStart, *((const char * *)p2), p1Len)) == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if ((i = strnicmp (c -> pStart, *((const char * *)p2), p1Len)) == 0) |
0 |
0 |
0 |
|
| 609 |
|
| { |
| 610 |
0 |
▶ | if (p1Len == p2Len) |
Branch: 1 branch
| Branch | True | False | Total |
| if (p1Len == p2Len) |
0 |
0 |
0 |
|
| 611 |
0 |
| return 0 ; |
| 612 |
0 |
▶ | else if (p1Len > p2Len) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (p1Len > p2Len) |
0 |
0 |
0 |
|
| 613 |
0 |
| return 1 ; |
| 614 |
0 |
| return -1 ; |
| 615 |
|
| } |
| 616 |
0 |
| return i ; |
| 617 |
|
| } |
| 618 |
|
| |
| 619 |
|
| |
| 620 |
|
| /* ------------------------------------------------------------------------ */ |
| 621 |
|
| /* */ |
| 622 |
|
| /* ParseTokens */ |
| 623 |
|
| /* */ |
| 624 |
|
| /* Parse a text for tokens */ |
| 625 |
|
| /* */ |
| 626 |
|
| /* ------------------------------------------------------------------------ */ |
| 627 |
|
| |
| 628 |
0 |
| static int ParseTokens (/*i/o*/ register req * r, |
| 629 |
|
| /*in */ char * * ppCurr, |
| 630 |
|
| char * pEnd, |
| 631 |
|
| struct tTokenTable * pTokenTable, |
| 632 |
|
| const char * sEndText, |
| 633 |
|
| const unsigned char * pParentContains, |
| 634 |
|
| tNodeType nCDataType, |
| 635 |
|
| tNodeType nForceType, |
| 636 |
|
| int bUnescape, |
| 637 |
|
| int bInsideMustExist, |
| 638 |
|
| int bRemoveSpaces, |
| 639 |
|
| tStringIndex nParentNodeName, |
| 640 |
|
| tNode xParentNode, |
| 641 |
|
| int level, |
| 642 |
|
| char * pCDATAStart, |
| 643 |
|
| const char * sStopText, |
| 644 |
|
| int bDontEat) |
| 645 |
|
| |
| 646 |
|
| { |
| 647 |
0 |
| unsigned char * pStartChars = pTokenTable -> cStartChars ; |
| 648 |
|
| struct tTokenCmp c ; |
| 649 |
0 |
▶ | int nEndText = sEndText?strlen (sEndText):0 ; |
Branch: 1 branch
| Branch | True | False | Total |
| int nEndText = sEndText?strlen (sEndText):0 ; |
0 |
0 |
0 |
|
| 650 |
0 |
| char * pCurr = *ppCurr ; |
| 651 |
0 |
▶ | char * pCurrStart = pCDATAStart?pCDATAStart:pCurr ; |
Branch: 1 branch
| Branch | True | False | Total |
| char * pCurrStart = pCDATAStart?pCDATAStart:pCurr ; |
0 |
0 |
0 |
|
| 652 |
|
| tNode xNewNode ; |
| 653 |
0 |
| int rc = 0 ; |
| 654 |
0 |
| tDomTree * pDomTree = DomTree_self (r -> Component.xCurrDomTree) ; |
| 655 |
0 |
| int numInside = 0 ; |
| 656 |
|
| |
| 657 |
0 |
▶ | if (nEndText == 0 && sStopText) |
Branch: 2 branches
| Branch | True | False | Total |
| if (nEndText == 0 && sStopText) |
0 |
0 |
0 |
| if (nEndText == 0 && sStopText) |
0 |
0 |
0 |
|
| 658 |
|
| { |
| 659 |
0 |
| sEndText = sStopText ; |
| 660 |
0 |
▶ | nEndText = sEndText?strlen (sEndText):0 ; |
Branch: 1 branch
| Branch | True | False | Total |
| nEndText = sEndText?strlen (sEndText):0 ; |
0 |
0 |
0 |
|
| 661 |
|
| } |
| 662 |
|
| else |
| 663 |
0 |
| sStopText = NULL ; |
| 664 |
|
| |
| 665 |
|
| |
| 666 |
0 |
▶ | while (pCurr < pEnd) |
Branch: 1 branch
| Branch | True | False | Total |
| while (pCurr < pEnd) |
0 |
0 |
0 |
|
| 667 |
|
| { |
| 668 |
0 |
| struct tToken * pToken = NULL ; |
| 669 |
0 |
| int bFollow = 0 ; |
| 670 |
|
| |
| 671 |
0 |
▶ | if (level == 0 && pTokenTable != r -> Component.pTokenTable) |
Branch: 2 branches
| Branch | True | False | Total |
| if (level == 0 && pTokenTable != r -> Component.pTokenTable) |
0 |
0 |
0 |
| if (level == 0 && pTokenTable != r -> Component.pTokenTable) |
0 |
0 |
0 |
|
| 672 |
|
| { /* syntax has changed */ |
| 673 |
0 |
| pTokenTable = r -> Component.pTokenTable ; |
| 674 |
0 |
| pStartChars = pTokenTable -> cStartChars ; |
| 675 |
|
| } |
| 676 |
|
| |
| 677 |
0 |
▶ | if (pStartChars [*pCurr >> 3] & 1 << (*pCurr & 7)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pStartChars [*pCurr >> 3] & 1 << (*pCurr & 7)) |
0 |
0 |
0 |
|
| 678 |
|
| { /* valid token start char found */ |
| 679 |
0 |
| struct tTokenTable * pNextTokenTab = pTokenTable ; |
| 680 |
0 |
| tStringIndex nNodeName = 0 ; |
| 681 |
0 |
| char * pCurrTokenStart = pCurr ; |
| 682 |
|
| |
| 683 |
|
| |
| 684 |
|
| do |
| 685 |
|
| { |
| 686 |
0 |
| struct tToken * pTokenTab = pNextTokenTab -> pTokens ; |
| 687 |
0 |
| int numTokens = pNextTokenTab -> numTokens ; |
| 688 |
0 |
| unsigned char * pAllChars = pNextTokenTab -> cAllChars ; |
| 689 |
|
| |
| 690 |
0 |
| bFollow++ ; |
| 691 |
|
| |
| 692 |
0 |
▶ | if (pNextTokenTab -> bLSearch) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pNextTokenTab -> bLSearch) |
0 |
0 |
0 |
|
| 693 |
|
| { /* search linear thru the tokens */ |
| 694 |
0 |
| int r = 1 ; |
| 695 |
|
| int i ; |
| 696 |
|
| |
| 697 |
0 |
▶ | for (i = 0, pToken = pTokenTab; i < numTokens; i++, pToken++) |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0, pToken = pTokenTab; i < numTokens; i++, pToken++) |
0 |
0 |
0 |
|
| 698 |
|
| { |
| 699 |
0 |
▶ | if (pToken -> bMatchAll && (numInside == 0 || pToken -> bMatchAll > 0)) |
Branch: 3 branches
| Branch | True | False | Total |
| if (pToken -> bMatchAll && (numInside == 0 || pToken -> bMatchAll > 0)) |
0 |
0 |
0 |
| if (pToken -> bMatchAll && (numInside == 0 || pToken -> bMatchAll > 0)) |
0 |
0 |
0 |
| if (pToken -> bMatchAll && (numInside == 0 || pToken -> bMatchAll > 0)) |
0 |
0 |
0 |
|
| 700 |
|
| { |
| 701 |
0 |
| r = 0 ; |
| 702 |
0 |
| break ; |
| 703 |
|
| } |
| 704 |
0 |
▶ | if (pToken -> nTextLen == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pToken -> nTextLen == 0) |
0 |
0 |
0 |
|
| 705 |
0 |
| continue ; |
| 706 |
0 |
| r = strnicmp (pCurr, pToken -> sText, pToken -> nTextLen) ; |
| 707 |
|
| /* if ((r == 0 && !(pAllChars [pCurr[pToken -> nTextLen] >> 3] & (1 << (pCurr[pToken -> nTextLen] & 7)))) || */ |
| 708 |
0 |
▶ | if (r == 0 || |
Branch: 1 branch
| Branch | True | False | Total |
| if (r == 0 || |
0 |
0 |
0 |
|
| 709 |
0 |
▶ | (*pCurr > *(pToken -> sText) && pStartChars[0] != 0xff)) |
Branch: 2 branches
| Branch | True | False | Total |
| (*pCurr > *(pToken -> sText) && pStartChars[0] != 0xff)) |
0 |
0 |
0 |
| (*pCurr > *(pToken -> sText) && pStartChars[0] != 0xff)) |
0 |
0 |
0 |
|
| 710 |
|
| break ; |
| 711 |
|
| } |
| 712 |
0 |
▶ | if (r != 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (r != 0) |
0 |
0 |
0 |
|
| 713 |
0 |
| pToken = NULL ; |
| 714 |
0 |
▶ | else if (!pToken -> bMatchAll && (pToken -> bDontEat & 1) == 0) |
Branch: 2 branches
| Branch | True | False | Total |
| else if (!pToken -> bMatchAll && (pToken -> bDontEat & 1) == 0) |
0 |
0 |
0 |
| else if (!pToken -> bMatchAll && (pToken -> bDontEat & 1) == 0) |
0 |
0 |
0 |
|
| 715 |
0 |
| pCurr += pToken -> nTextLen ; |
| 716 |
|
| } |
| 717 |
|
| else |
| 718 |
|
| { /* do a binary search for tokens */ |
| 719 |
0 |
| c.pStart = pCurr ; |
| 720 |
|
| |
| 721 |
0 |
▶ | while (pAllChars [*pCurr >> 3] & (1 << (*pCurr & 7))) |
Branch: 1 branch
| Branch | True | False | Total |
| while (pAllChars [*pCurr >> 3] & (1 << (*pCurr & 7))) |
0 |
0 |
0 |
|
| 722 |
0 |
| pCurr++ ; |
| 723 |
|
| |
| 724 |
0 |
| c.nLen = pCurr - c.pStart ; |
| 725 |
0 |
| pToken = (struct tToken *)bsearch (&c, pTokenTab, numTokens, sizeof (struct tToken), CmpTokenN) ; |
| 726 |
0 |
▶ | if (!pToken) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!pToken) |
0 |
0 |
0 |
|
| 727 |
|
| { |
| 728 |
0 |
| pCurr = c.pStart ; |
| 729 |
|
| /* bFollow = 0 ; */ |
| 730 |
|
| } |
| 731 |
|
| } |
| 732 |
|
| |
| 733 |
0 |
▶ | if (pToken) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pToken) |
0 |
0 |
0 |
|
| 734 |
|
| { |
| 735 |
0 |
| numInside++ ; |
| 736 |
0 |
▶ | if (pToken -> bRemoveSpaces & 2) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pToken -> bRemoveSpaces & 2) |
0 |
0 |
0 |
|
| 737 |
0 |
▶ | while (isspace (*pCurr)) |
Branch: 1 branch
| Branch | True | False | Total |
| while (isspace (*pCurr)) |
0 |
0 |
0 |
|
| 738 |
0 |
| pCurr++ ; |
| 739 |
0 |
▶ | else if (pToken -> bRemoveSpaces & 8) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (pToken -> bRemoveSpaces & 8) |
0 |
0 |
0 |
|
| 740 |
0 |
▶ | while ((*pCurr == ' ' || *pCurr == '\t' || *pCurr == '\r')) |
Branch: 3 branches
| Branch | True | False | Total |
| while ((*pCurr == ' ' || *pCurr == '\t' || *pCurr == '\r')) |
0 |
0 |
0 |
| while ((*pCurr == ' ' || *pCurr == '\t' || *pCurr == '\r')) |
0 |
0 |
0 |
| while ((*pCurr == ' ' || *pCurr == '\t' || *pCurr == '\r')) |
0 |
0 |
0 |
|
| 741 |
0 |
| pCurr++ ; |
| 742 |
|
| |
| 743 |
0 |
▶ | if (pToken -> sNodeName) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pToken -> sNodeName) |
0 |
0 |
0 |
|
| 744 |
0 |
| nNodeName = pToken -> nNodeName ; |
| 745 |
|
| } |
| 746 |
|
| else |
| 747 |
|
| { |
| 748 |
0 |
| pToken = pNextTokenTab -> pContainsToken ; |
| 749 |
|
| /* |
| 750 |
|
| if (pToken = pNextTokenTab -> pContainsToken) |
| 751 |
|
| { |
| 752 |
|
| unsigned char * pContains ; |
| 753 |
|
| if (!(pToken -> pInside) && (!(pContains = pToken -> pContains) || !(pContains [*pCurr >> 3] & (1 << (*pCurr & 7))))) |
| 754 |
|
| pToken = NULL ; |
| 755 |
|
| } |
| 756 |
|
| */ |
| 757 |
0 |
▶ | if (pToken && pToken -> sNodeName) |
Branch: 2 branches
| Branch | True | False | Total |
| if (pToken && pToken -> sNodeName) |
0 |
0 |
0 |
| if (pToken && pToken -> sNodeName) |
0 |
0 |
0 |
|
| 758 |
0 |
| nNodeName = pToken -> nNodeName ; |
| 759 |
|
| |
| 760 |
0 |
| break ; |
| 761 |
|
| } |
| 762 |
|
| |
| 763 |
|
| |
| 764 |
|
| } |
| 765 |
0 |
▶ | while ((pNextTokenTab = pToken -> pFollowedBy)) ; |
Branch: 1 branch
| Branch | True | False | Total |
| while ((pNextTokenTab = pToken -> pFollowedBy)) ; |
0 |
0 |
0 |
|
| 766 |
|
| |
| 767 |
0 |
▶ | if (pToken) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pToken) |
0 |
0 |
0 |
|
| 768 |
|
| { /* matching token found */ |
| 769 |
|
| struct tTokenTable * pInside ; |
| 770 |
|
| |
| 771 |
0 |
▶ | if (pCurrStart < pCurrTokenStart) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pCurrStart < pCurrTokenStart) |
0 |
0 |
0 |
|
| 772 |
|
| { |
| 773 |
0 |
▶ | if (nCDataType) |
Branch: 1 branch
| Branch | True | False | Total |
| if (nCDataType) |
0 |
0 |
0 |
|
| 774 |
|
| { /* add text before current token as node */ |
| 775 |
0 |
| const char * pEnd = pCurrTokenStart - 1; |
| 776 |
0 |
▶ | if (pToken -> bRemoveSpaces & 1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pToken -> bRemoveSpaces & 1) |
0 |
0 |
0 |
|
| 777 |
0 |
▶ | while (pEnd >= pCurrStart && isspace (*pEnd)) |
Branch: 2 branches
| Branch | True | False | Total |
| while (pEnd >= pCurrStart && isspace (*pEnd)) |
0 |
0 |
0 |
| while (pEnd >= pCurrStart && isspace (*pEnd)) |
0 |
0 |
0 |
|
| 778 |
0 |
| pEnd-- ; |
| 779 |
0 |
▶ | else if (pToken -> bRemoveSpaces & 4) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (pToken -> bRemoveSpaces & 4) |
0 |
0 |
0 |
|
| 780 |
0 |
▶ | while (pEnd >= pCurrStart && (*pEnd == ' ' || *pEnd == '\t' || *pEnd == '\r')) |
Branch: 4 branches
| Branch | True | False | Total |
| while (pEnd >= pCurrStart && (*pEnd == ' ' || *pEnd == '\t' || *pEnd == '\r')) |
0 |
0 |
0 |
| while (pEnd >= pCurrStart && (*pEnd == ' ' || *pEnd == '\t' || *pEnd == '\r')) |
0 |
0 |
0 |
| while (pEnd >= pCurrStart && (*pEnd == ' ' || *pEnd == '\t' || *pEnd == '\r')) |
0 |
0 |
0 |
| while (pEnd >= pCurrStart && (*pEnd == ' ' || *pEnd == '\t' || *pEnd == '\r')) |
0 |
0 |
0 |
|
| 781 |
0 |
| pEnd-- ; |
| 782 |
0 |
▶ | else if (pToken -> bRemoveSpaces & 16) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (pToken -> bRemoveSpaces & 16) |
0 |
0 |
0 |
|
| 783 |
|
| { |
| 784 |
0 |
▶ | while (pEnd >= pCurrStart && isspace (*pEnd)) |
Branch: 2 branches
| Branch | True | False | Total |
| while (pEnd >= pCurrStart && isspace (*pEnd)) |
0 |
0 |
0 |
| while (pEnd >= pCurrStart && isspace (*pEnd)) |
0 |
0 |
0 |
|
| 785 |
0 |
| pEnd-- ; |
| 786 |
0 |
▶ | if (pEnd >= pCurrStart && pEnd < pCurrTokenStart - 1) |
Branch: 2 branches
| Branch | True | False | Total |
| if (pEnd >= pCurrStart && pEnd < pCurrTokenStart - 1) |
0 |
0 |
0 |
| if (pEnd >= pCurrStart && pEnd < pCurrTokenStart - 1) |
0 |
0 |
0 |
|
| 787 |
0 |
| pEnd++ ; |
| 788 |
|
| } |
| 789 |
|
| |
| 790 |
0 |
▶ | if (bUnescape) |
Branch: 1 branch
| Branch | True | False | Total |
| if (bUnescape) |
0 |
0 |
0 |
|
| 791 |
|
| { |
| 792 |
|
| int newlen ; |
| 793 |
0 |
| r -> Component.bEscInUrl = bUnescape - 1 ; |
| 794 |
0 |
| newlen = TransHtml (r, pCurrStart, pEnd - pCurrStart + 1) ; |
| 795 |
0 |
| pEnd = pCurrStart + newlen - 1 ; |
| 796 |
0 |
| r -> Component.bEscInUrl = 0 ; |
| 797 |
|
| } |
| 798 |
|
| |
| 799 |
|
| |
| 800 |
0 |
▶ | if (pEnd - pCurrStart + 1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pEnd - pCurrStart + 1) |
0 |
0 |
0 |
|
| 801 |
0 |
▶ | if (!(xNewNode = Node_appendChild (r -> pApp, pDomTree, xParentNode, 0, nCDataType, 0, pCurrStart, pEnd - pCurrStart + 1, level, GetLineNoOf (r, pCurrStart), NULL))) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(xNewNode = Node_appendChild (r -> pApp, pDomTree, xParentNode, 0, nCDataType, 0, pCurrStart, pEnd - pCurrStart + 1, level, GetLineNoOf (r, pCurrStart), NULL))) |
0 |
0 |
0 |
|
| 802 |
0 |
| return 1 ; |
| 803 |
|
| } |
| 804 |
0 |
| pCurrStart = pCurrTokenStart ; |
| 805 |
|
| } |
| 806 |
|
| |
| 807 |
0 |
▶ | if (nNodeName == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (nNodeName == 0) |
0 |
0 |
0 |
|
| 808 |
0 |
| nNodeName = pToken -> nNodeName ; |
| 809 |
|
| |
| 810 |
0 |
▶ | if (pToken -> nNodeType == ntypEndTag && level > 0) |
Branch: 2 branches
| Branch | True | False | Total |
| if (pToken -> nNodeType == ntypEndTag && level > 0) |
0 |
0 |
0 |
| if (pToken -> nNodeType == ntypEndTag && level > 0) |
0 |
0 |
0 |
|
| 811 |
0 |
| { /* end token found */ |
| 812 |
|
| tNodeData * pStartTag ; |
| 813 |
0 |
| char * pEndCurr = strstr (pCurr, pToken -> sEndText) ; |
| 814 |
0 |
▶ | if (!pEndCurr && pToken -> sEndText[0] == '\n' && pToken -> sEndText[1] == '\n' && sEndText[2] == '\0') |
Branch: 4 branches
| Branch | True | False | Total |
| if (!pEndCurr && pToken -> sEndText[0] == '\n' && pToken -> sEndText[1] == '\n' && sEndText[2] == '\0') |
0 |
0 |
0 |
| if (!pEndCurr && pToken -> sEndText[0] == '\n' && pToken -> sEndText[1] == '\n' && sEndText[2] == '\0') |
0 |
0 |
0 |
| if (!pEndCurr && pToken -> sEndText[0] == '\n' && pToken -> sEndText[1] == '\n' && sEndText[2] == '\0') |
0 |
0 |
0 |
| if (!pEndCurr && pToken -> sEndText[0] == '\n' && pToken -> sEndText[1] == '\n' && sEndText[2] == '\0') |
0 |
0 |
0 |
|
| 815 |
|
| { |
| 816 |
0 |
| pEndCurr = strstr (pCurr, "\n\r\n") ; |
| 817 |
0 |
▶ | if (pEndCurr && pEndCurr[-1] == '\r') |
Branch: 2 branches
| Branch | True | False | Total |
| if (pEndCurr && pEndCurr[-1] == '\r') |
0 |
0 |
0 |
| if (pEndCurr && pEndCurr[-1] == '\r') |
0 |
0 |
0 |
|
| 818 |
0 |
| pEndCurr-- ; |
| 819 |
|
| } |
| 820 |
0 |
▶ | if (pEndCurr) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pEndCurr) |
0 |
0 |
0 |
|
| 821 |
|
| { |
| 822 |
|
| tNode xNewAttrNode ; |
| 823 |
0 |
▶ | if (pEndCurr - pCurr && pToken -> nCDataType && pToken -> nCDataType != ntypCDATA) |
Branch: 3 branches
| Branch | True | False | Total |
| if (pEndCurr - pCurr && pToken -> nCDataType && pToken -> nCDataType != ntypCDATA) |
0 |
0 |
0 |
| if (pEndCurr - pCurr && pToken -> nCDataType && pToken -> nCDataType != ntypCDATA) |
0 |
0 |
0 |
| if (pEndCurr - pCurr && pToken -> nCDataType && pToken -> nCDataType != ntypCDATA) |
0 |
0 |
0 |
|
| 824 |
|
| { /* add text before end of token as node */ |
| 825 |
0 |
| char * pEnd = pEndCurr ; |
| 826 |
|
| char c; |
| 827 |
|
| |
| 828 |
0 |
▶ | if (pToken -> bRemoveSpaces & 32) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pToken -> bRemoveSpaces & 32) |
0 |
0 |
0 |
|
| 829 |
0 |
▶ | while (pEnd > pCurrStart && isspace (*(pEnd-1))) |
Branch: 2 branches
| Branch | True | False | Total |
| while (pEnd > pCurrStart && isspace (*(pEnd-1))) |
0 |
0 |
0 |
| while (pEnd > pCurrStart && isspace (*(pEnd-1))) |
0 |
0 |
0 |
|
| 830 |
0 |
| pEnd-- ; |
| 831 |
0 |
▶ | else if (pToken -> bRemoveSpaces & 64) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (pToken -> bRemoveSpaces & 64) |
0 |
0 |
0 |
|
| 832 |
0 |
▶ | while (pEnd > pCurrStart && ((c = *(pEnd-1)) == ' ' || c == '\t' || c == '\r')) |
Branch: 4 branches
| Branch | True | False | Total |
| while (pEnd > pCurrStart && ((c = *(pEnd-1)) == ' ' || c == '\t' || c == '\r')) |
0 |
0 |
0 |
| while (pEnd > pCurrStart && ((c = *(pEnd-1)) == ' ' || c == '\t' || c == '\r')) |
0 |
0 |
0 |
| while (pEnd > pCurrStart && ((c = *(pEnd-1)) == ' ' || c == '\t' || c == '\r')) |
0 |
0 |
0 |
| while (pEnd > pCurrStart && ((c = *(pEnd-1)) == ' ' || c == '\t' || c == '\r')) |
0 |
0 |
0 |
|
| 833 |
0 |
| pEnd-- ; |
| 834 |
|
| |
| 835 |
0 |
▶ | if (pToken -> bUnescape) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pToken -> bUnescape) |
0 |
0 |
0 |
|
| 836 |
|
| { |
| 837 |
|
| int newlen ; |
| 838 |
0 |
| r -> Component.bEscInUrl = pToken -> bUnescape - 1 ; |
| 839 |
0 |
| newlen = TransHtml (r, pCurr, pEnd - pCurr) ; |
| 840 |
0 |
| pEnd = pCurr + newlen ; |
| 841 |
0 |
| r -> Component.bEscInUrl = 0 ; |
| 842 |
|
| } |
| 843 |
|
| |
| 844 |
0 |
▶ | if (!(xNewAttrNode = Node_appendChild (r -> pApp, pDomTree, xParentNode, 0, pToken -> nCDataType, 0, pCurr, pEnd - pCurr, level+1, GetLineNoOf (r, pCurr), NULL))) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(xNewAttrNode = Node_appendChild (r -> pApp, pDomTree, xParentNode, 0, pToken -> nCDataType, 0, pCurr, pEnd - pCurr, level+1, GetLineNoOf (r, pCurr), NULL))) |
0 |
0 |
0 |
|
| 845 |
0 |
| return 1 ; |
| 846 |
0 |
▶ | if (pToken -> bAddFlags) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pToken -> bAddFlags) |
0 |
0 |
0 |
|
| 847 |
0 |
| Node_self (pDomTree, xNewAttrNode) -> bFlags |= pToken -> bAddFlags ; |
| 848 |
|
| |
| 849 |
|
| } |
| 850 |
0 |
| pCurr = pEndCurr + strlen (pToken -> sEndText) ; |
| 851 |
|
| } |
| 852 |
0 |
| level-- ; |
| 853 |
0 |
▶ | xParentNode = Node_parentNode (r -> pApp, pDomTree, xParentNode, 0) ; |
Branch: 2 branches
| Branch | True | False | Total |
| xParentNode = Node_parentNode (r -> pApp, pDomTree, xParentNode, 0) ; |
0 |
0 |
0 |
| xParentNode = Node_parentNode (r -> pApp, pDomTree, xParentNode, 0) ; |
0 |
0 |
0 |
|
| 854 |
0 |
| pStartTag = Node_selfLastChild (r -> pApp, pDomTree, Node_self (pDomTree, xParentNode), 0) ; |
| 855 |
0 |
▶ | if (pStartTag -> nText != pToken -> nNodeName && |
Branch: 1 branch
| Branch | True | False | Total |
| if (pStartTag -> nText != pToken -> nNodeName && |
0 |
0 |
0 |
|
| 856 |
0 |
▶ | (pToken -> pStartTag == NULL |
Branch: 1 branch
| Branch | True | False | Total |
| (pToken -> pStartTag == NULL |
0 |
0 |
0 |
|
| 857 |
0 |
▶ | || pStartTag -> nText != pToken -> pStartTag -> nNodeName)) |
Branch: 1 branch
| Branch | True | False | Total |
| || pStartTag -> nText != pToken -> pStartTag -> nNodeName)) |
0 |
0 |
0 |
|
| 858 |
|
| { |
| 859 |
0 |
| strncpy (r -> errdat2, Ndx2String (pStartTag -> nText), sizeof (r -> errdat2)) ; |
| 860 |
0 |
| strncpy (r -> errdat1, Ndx2String (pToken -> nNodeName), sizeof (r -> errdat1)) ; |
| 861 |
0 |
| r -> Component.pCurrPos = pCurrTokenStart ; |
| 862 |
0 |
| return rcTagMismatch ; |
| 863 |
|
| } |
| 864 |
|
| } |
| 865 |
|
| else |
| 866 |
|
| { |
| 867 |
0 |
▶ | if (pToken -> nNodeType == ntypEndStartTag && level > 0) |
Branch: 2 branches
| Branch | True | False | Total |
| if (pToken -> nNodeType == ntypEndStartTag && level > 0) |
0 |
0 |
0 |
| if (pToken -> nNodeType == ntypEndStartTag && level > 0) |
0 |
0 |
0 |
|
| 868 |
|
| { |
| 869 |
0 |
▶ | xParentNode = Node_parentNode (r -> pApp, pDomTree, xParentNode, 0) ; |
Branch: 2 branches
| Branch | True | False | Total |
| xParentNode = Node_parentNode (r -> pApp, pDomTree, xParentNode, 0) ; |
0 |
0 |
0 |
| xParentNode = Node_parentNode (r -> pApp, pDomTree, xParentNode, 0) ; |
0 |
0 |
0 |
|
| 870 |
0 |
| level-- ; |
| 871 |
|
| } |
| 872 |
0 |
▶ | if ((pToken -> nNodeType && pToken -> nNodeType != ntypCDATA) || pToken -> sNodeName) |
Branch: 3 branches
| Branch | True | False | Total |
| if ((pToken -> nNodeType && pToken -> nNodeType != ntypCDATA) || pToken -> sNodeName) |
0 |
0 |
0 |
| if ((pToken -> nNodeType && pToken -> nNodeType != ntypCDATA) || pToken -> sNodeName) |
0 |
0 |
0 |
| if ((pToken -> nNodeType && pToken -> nNodeType != ntypCDATA) || pToken -> sNodeName) |
0 |
0 |
0 |
|
| 873 |
0 |
| { |
| 874 |
|
| /* add token as node if not cdata*/ |
| 875 |
0 |
| tNodeType nType = pToken -> nNodeType ; |
| 876 |
0 |
▶ | if (nType == ntypStartEndTag) |
Branch: 1 branch
| Branch | True | False | Total |
| if (nType == ntypStartEndTag) |
0 |
0 |
0 |
|
| 877 |
0 |
| nType = ntypStartTag ; |
| 878 |
|
| |
| 879 |
0 |
▶ | if (!(xNewNode = Node_appendChild (r -> pApp, pDomTree, xParentNode, 0, nType, (nCDataType == ntypAttrValue && pToken -> nNodeType != ntypAttr)?(pToken -> nForceType?2:1):0, NULL, nNodeName, level, GetLineNoOf (r, pCurrTokenStart), pToken -> sText))) |
Branch: 4 branches
| Branch | True | False | Total |
| if (!(xNewNode = Node_appendChild (r -> pApp, pDomTree, xParentNode, 0, nType, (nCDataType == ntypAttrValue && pToken -> nNodeType != ntypAttr)?(pToken -> nForceType?2:1):0, NULL, nNodeName, level, GetLineNoOf (r, pCurrTokenStart), pToken -> sText))) |
0 |
0 |
0 |
| if (!(xNewNode = Node_appendChild (r -> pApp, pDomTree, xParentNode, 0, nType, (nCDataType == ntypAttrValue && pToken -> nNodeType != ntypAttr)?(pToken -> nForceType?2:1):0, NULL, nNodeName, level, GetLineNoOf (r, pCurrTokenStart), pToken -> sText))) |
0 |
0 |
0 |
| if (!(xNewNode = Node_appendChild (r -> pApp, pDomTree, xParentNode, 0, nType, (nCDataType == ntypAttrValue && pToken -> nNodeType != ntypAttr)?(pToken -> nForceType?2:1):0, NULL, nNodeName, level, GetLineNoOf (r, pCurrTokenStart), pToken -> sText))) |
0 |
0 |
0 |
| if (!(xNewNode = Node_appendChild (r -> pApp, pDomTree, xParentNode, 0, nType, (nCDataType == ntypAttrValue && pToken -> nNodeType != ntypAttr)?(pToken -> nForceType?2:1):0, NULL, nNodeName, level, GetLineNoOf (r, pCurrTokenStart), pToken -> sText))) |
0 |
0 |
0 |
|
| 880 |
|
| { |
| 881 |
0 |
| r -> Component.pCurrPos = pCurrTokenStart ; |
| 882 |
|
| |
| 883 |
0 |
| return rc ; |
| 884 |
|
| } |
| 885 |
0 |
▶ | if (pToken -> bAddFlags) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pToken -> bAddFlags) |
0 |
0 |
0 |
|
| 886 |
0 |
| Node_self (pDomTree, xNewNode) -> bFlags |= pToken -> bAddFlags ; |
| 887 |
0 |
▶ | if (!pToken -> pInside) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!pToken -> pInside) |
0 |
0 |
0 |
|
| 888 |
0 |
| bInsideMustExist = 0 ; |
| 889 |
|
| |
| 890 |
0 |
▶ | if (pToken -> bAddFirstChild) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pToken -> bAddFirstChild) |
0 |
0 |
0 |
|
| 891 |
|
| { |
| 892 |
0 |
▶ | if (!(Node_appendChild (r -> pApp, pDomTree, xNewNode, 0, nCDataType, |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(Node_appendChild (r -> pApp, pDomTree, xNewNode, 0, nCDataType, |
0 |
0 |
0 |
|
| 893 |
|
| 0, |
| 894 |
|
| "", 0, |
| 895 |
|
| 0, 0, NULL))) |
| 896 |
|
| { |
| 897 |
0 |
| return rc ; |
| 898 |
|
| } |
| 899 |
|
| } |
| 900 |
|
| } |
| 901 |
|
| else |
| 902 |
|
| { |
| 903 |
0 |
| xNewNode = xParentNode ; |
| 904 |
|
| } |
| 905 |
|
| |
| 906 |
0 |
▶ | if ((pInside = pToken -> pInside)) |
Branch: 1 branch
| Branch | True | False | Total |
| if ((pInside = pToken -> pInside)) |
0 |
0 |
0 |
|
| 907 |
|
| { /* parse for further tokens inside of this token */ |
| 908 |
0 |
▶ | rc = ParseTokens (r, &pCurr, pEnd, pInside, |
Branch: 1 branch
| Branch | True | False | Total |
| rc = ParseTokens (r, &pCurr, pEnd, pInside, |
0 |
0 |
0 |
|
| 909 |
|
| pToken -> sEndText, |
| 910 |
0 |
| pToken -> pContains, |
| 911 |
0 |
▶ | (tNodeType)(pToken -> nCDataType == ntypCDATA && !pToken -> sNodeName?ntypAttrValue:pToken -> nCDataType), |
Branch: 1 branch
| Branch | True | False | Total |
| (tNodeType)(pToken -> nCDataType == ntypCDATA && !pToken -> sNodeName?ntypAttrValue:pToken -> nCDataType), |
0 |
0 |
0 |
|
| 912 |
|
| 0, |
| 913 |
|
| pToken -> bUnescape, |
| 914 |
0 |
▶ | pToken -> bInsideMustExist + bInsideMustExist, |
Branch: 1 branch
| Branch | True | False | Total |
| pToken -> bInsideMustExist + bInsideMustExist, |
0 |
0 |
0 |
|
| 915 |
|
| pToken -> bRemoveSpaces, |
| 916 |
|
| nNodeName, |
| 917 |
|
| xNewNode, |
| 918 |
|
| level+1, |
| 919 |
0 |
▶ | pToken -> nNodeType == ntypCDATA?pCurrTokenStart:NULL, |
Branch: 1 branch
| Branch | True | False | Total |
| pToken -> nNodeType == ntypCDATA?pCurrTokenStart:NULL, |
0 |
0 |
0 |
|
| 920 |
0 |
▶ | sEndText && *sEndText?sEndText:NULL, |
Branch: 1 branch
| Branch | True | False | Total |
| sEndText && *sEndText?sEndText:NULL, |
0 |
0 |
0 |
|
| 921 |
|
| pToken -> bDontEat) ; |
| 922 |
0 |
▶ | if (rc == ok) |
Branch: 1 branch
| Branch | True | False | Total |
| if (rc == ok) |
0 |
0 |
0 |
|
| 923 |
0 |
| bInsideMustExist = 0 ; |
| 924 |
0 |
▶ | else if (pToken -> bInsideMustExist && rc == rcTokenNotFound) |
Branch: 2 branches
| Branch | True | False | Total |
| else if (pToken -> bInsideMustExist && rc == rcTokenNotFound) |
0 |
0 |
0 |
| else if (pToken -> bInsideMustExist && rc == rcTokenNotFound) |
0 |
0 |
0 |
|
| 925 |
|
| { |
| 926 |
0 |
| rc = ok ; |
| 927 |
|
| /* |
| 928 |
|
| pToken = NULL ; |
| 929 |
|
| bFollow = 0 ; |
| 930 |
|
| sEndText = NULL ; |
| 931 |
|
| nEndText = 0 ; |
| 932 |
|
| pCurr = pCurrTokenStart ; |
| 933 |
|
| */ |
| 934 |
0 |
▶ | if (xNewNode != xParentNode) |
Branch: 1 branch
| Branch | True | False | Total |
| if (xNewNode != xParentNode) |
0 |
0 |
0 |
|
| 935 |
|
| { |
| 936 |
0 |
| Node_removeChild (r -> pApp, pDomTree, xParentNode, xNewNode, 0) ; |
| 937 |
0 |
▶ | if (r -> Component.Config.bDebug & dbgParse) |
Branch: 1 branch
| Branch | True | False | Total |
| if (r -> Component.Config.bDebug & dbgParse) |
0 |
0 |
0 |
|
| 938 |
0 |
| lprintf (r -> pApp, "[%d]PARSE: DelNode: +%02d %*s parent=%d node=%d\n", |
| 939 |
0 |
| r -> pThread -> nPid, level, level * 2, "", xParentNode, xNewNode) ; |
| 940 |
|
| } |
| 941 |
|
| |
| 942 |
|
| /* add as cdata*/ |
| 943 |
0 |
▶ | if (!(xNewNode = Node_appendChild (r -> pApp, pDomTree, xParentNode, 0, (tNodeType)pTokenTable -> nDefNodeType, 0, pCurrStart, pCurr - pCurrStart, level, GetLineNoOf (r, pCurrStart), NULL))) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(xNewNode = Node_appendChild (r -> pApp, pDomTree, xParentNode, 0, (tNodeType)pTokenTable -> nDefNodeType, 0, pCurrStart, pCurr - pCurrStart, level, GetLineNoOf (r, pCurrStart), NULL))) |
0 |
0 |
0 |
|
| 944 |
0 |
| return 1 ; |
| 945 |
|
| } |
| 946 |
0 |
▶ | else if (rc != rcTokenNotFound) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (rc != rcTokenNotFound) |
0 |
0 |
0 |
|
| 947 |
|
| { |
| 948 |
0 |
| return rc ; |
| 949 |
|
| } |
| 950 |
0 |
▶ | if (pToken -> nNodeType == ntypStartEndTag) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pToken -> nNodeType == ntypStartEndTag) |
0 |
0 |
0 |
|
| 951 |
|
| { |
| 952 |
0 |
▶ | xParentNode = Node_parentNode (r -> pApp, pDomTree, xNewNode, 0) ; |
Branch: 2 branches
| Branch | True | False | Total |
| xParentNode = Node_parentNode (r -> pApp, pDomTree, xNewNode, 0) ; |
0 |
0 |
0 |
| xParentNode = Node_parentNode (r -> pApp, pDomTree, xNewNode, 0) ; |
0 |
0 |
0 |
|
| 953 |
0 |
| pToken = NULL ; |
| 954 |
0 |
| bFollow = 2 ; |
| 955 |
|
| } |
| 956 |
|
| } |
| 957 |
|
| else |
| 958 |
|
| { /* nothing more inside of this token allowed, so search for the end of the token */ |
| 959 |
|
| char * pEndCurr ; |
| 960 |
|
| unsigned char * pContains ; |
| 961 |
0 |
| int nSkip = 0 ; |
| 962 |
0 |
▶ | if ((pContains = pToken -> pContains)) |
Branch: 1 branch
| Branch | True | False | Total |
| if ((pContains = pToken -> pContains)) |
0 |
0 |
0 |
|
| 963 |
|
| { |
| 964 |
0 |
| pEndCurr = pCurr ; |
| 965 |
0 |
▶ | while (pContains [*pEndCurr >> 3] & (1 << (*pEndCurr & 7))) |
Branch: 1 branch
| Branch | True | False | Total |
| while (pContains [*pEndCurr >> 3] & (1 << (*pEndCurr & 7))) |
0 |
0 |
0 |
|
| 966 |
0 |
| pEndCurr++ ; |
| 967 |
0 |
| nSkip = 0 ; |
| 968 |
|
| /* |
| 969 |
|
| if (pEndCurr == pCurr) |
| 970 |
|
| { |
| 971 |
|
| pEndCurr = NULL ; |
| 972 |
|
| pToken = NULL ; |
| 973 |
|
| } |
| 974 |
|
| */ |
| 975 |
|
| } |
| 976 |
|
| else |
| 977 |
|
| { |
| 978 |
0 |
| pEndCurr = NULL ; |
| 979 |
0 |
▶ | if (strcmp (pToken -> sEndText, "\n\n") == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (strcmp (pToken -> sEndText, "\n\n") == 0) |
0 |
0 |
0 |
|
| 980 |
|
| { |
| 981 |
0 |
▶ | if ((pEndCurr = strstr (pCurr, "\n\r\n"))) |
Branch: 1 branch
| Branch | True | False | Total |
| if ((pEndCurr = strstr (pCurr, "\n\r\n"))) |
0 |
0 |
0 |
|
| 982 |
|
| { |
| 983 |
0 |
▶ | if (pEndCurr[-1] == '\r') |
Branch: 1 branch
| Branch | True | False | Total |
| if (pEndCurr[-1] == '\r') |
0 |
0 |
0 |
|
| 984 |
|
| { |
| 985 |
0 |
| pEndCurr-- ; |
| 986 |
0 |
▶ | nSkip = pCurr[4] == '\r'?5:4 ; |
Branch: 1 branch
| Branch | True | False | Total |
| nSkip = pCurr[4] == '\r'?5:4 ; |
0 |
0 |
0 |
|
| 987 |
|
| } |
| 988 |
|
| else |
| 989 |
0 |
▶ | nSkip = pCurr[3] == '\r'?4:3 ; |
Branch: 1 branch
| Branch | True | False | Total |
| nSkip = pCurr[3] == '\r'?4:3 ; |
0 |
0 |
0 |
|
| 990 |
|
| } |
| 991 |
|
| } |
| 992 |
0 |
▶ | if (!pEndCurr) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!pEndCurr) |
0 |
0 |
0 |
|
| 993 |
|
| { |
| 994 |
0 |
| pEndCurr = strstr (pCurr, pToken -> sEndText) ; |
| 995 |
0 |
| nSkip = strlen (pToken -> sEndText) ; |
| 996 |
|
| } |
| 997 |
0 |
▶ | if (pToken -> bDontEat & 2) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pToken -> bDontEat & 2) |
0 |
0 |
0 |
|
| 998 |
0 |
| nSkip = 0 ; |
| 999 |
|
| |
| 1000 |
0 |
▶ | if (pToken -> nNodeType == ntypCDATA && pEndCurr && !pToken -> sNodeName) |
Branch: 3 branches
| Branch | True | False | Total |
| if (pToken -> nNodeType == ntypCDATA && pEndCurr && !pToken -> sNodeName) |
0 |
0 |
0 |
| if (pToken -> nNodeType == ntypCDATA && pEndCurr && !pToken -> sNodeName) |
0 |
0 |
0 |
| if (pToken -> nNodeType == ntypCDATA && pEndCurr && !pToken -> sNodeName) |
0 |
0 |
0 |
|
| 1001 |
|
| { |
| 1002 |
0 |
| pEndCurr += nSkip ; |
| 1003 |
0 |
| nSkip = 0 ; |
| 1004 |
0 |
| pCurr = pCurrTokenStart ; |
| 1005 |
|
| } |
| 1006 |
|
| } |
| 1007 |
|
| |
| 1008 |
0 |
▶ | if (pEndCurr) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pEndCurr) |
0 |
0 |
0 |
|
| 1009 |
|
| { |
| 1010 |
|
| tNode xNewAttrNode ; |
| 1011 |
0 |
▶ | if (pEndCurr - pCurr && pToken -> nCDataType) |
Branch: 2 branches
| Branch | True | False | Total |
| if (pEndCurr - pCurr && pToken -> nCDataType) |
0 |
0 |
0 |
| if (pEndCurr - pCurr && pToken -> nCDataType) |
0 |
0 |
0 |
|
| 1012 |
|
| { |
| 1013 |
|
| int nLine ; |
| 1014 |
0 |
| char * pEnd = pEndCurr ; |
| 1015 |
|
| char c; |
| 1016 |
|
| |
| 1017 |
0 |
▶ | if (pToken -> bRemoveSpaces & 32) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pToken -> bRemoveSpaces & 32) |
0 |
0 |
0 |
|
| 1018 |
0 |
▶ | while (pEnd > pCurrStart && isspace (*(pEnd-1))) |
Branch: 2 branches
| Branch | True | False | Total |
| while (pEnd > pCurrStart && isspace (*(pEnd-1))) |
0 |
0 |
0 |
| while (pEnd > pCurrStart && isspace (*(pEnd-1))) |
0 |
0 |
0 |
|
| 1019 |
0 |
| pEnd-- ; |
| 1020 |
0 |
▶ | else if (pToken -> bRemoveSpaces & 64) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (pToken -> bRemoveSpaces & 64) |
0 |
0 |
0 |
|
| 1021 |
0 |
▶ | while (pEnd > pCurrStart && ((c = *(pEnd-1)) == ' ' || c == '\t' || c == '\r')) |
Branch: 4 branches
| Branch | True | False | Total |
| while (pEnd > pCurrStart && ((c = *(pEnd-1)) == ' ' || c == '\t' || c == '\r')) |
0 |
0 |
0 |
| while (pEnd > pCurrStart && ((c = *(pEnd-1)) == ' ' || c == '\t' || c == '\r')) |
0 |
0 |
0 |
| while (pEnd > pCurrStart && ((c = *(pEnd-1)) == ' ' || c == '\t' || c == '\r')) |
0 |
0 |
0 |
| while (pEnd > pCurrStart && ((c = *(pEnd-1)) == ' ' || c == '\t' || c == '\r')) |
0 |
0 |
0 |
|
| 1022 |
0 |
| pEnd-- ; |
| 1023 |
|
| |
| 1024 |
0 |
▶ | if (pToken -> bUnescape) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pToken -> bUnescape) |
0 |
0 |
0 |
|
| 1025 |
|
| { |
| 1026 |
|
| int newlen ; |
| 1027 |
0 |
| r -> Component.bEscInUrl = pToken -> bUnescape - 1 ; |
| 1028 |
0 |
| newlen = TransHtml (r, pCurr, pEnd - pCurr) ; |
| 1029 |
0 |
| pEnd = pCurr + newlen ; |
| 1030 |
0 |
| r -> Component.bEscInUrl = 0 ; |
| 1031 |
|
| } |
| 1032 |
|
| |
| 1033 |
|
| |
| 1034 |
0 |
▶ | if (!(xNewAttrNode = Node_appendChild (r -> pApp, pDomTree, xNewNode, 0, pToken -> nCDataType, |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(xNewAttrNode = Node_appendChild (r -> pApp, pDomTree, xNewNode, 0, pToken -> nCDataType, |
0 |
0 |
0 |
|
| 1035 |
0 |
| 0, pCurr, pEnd - pCurr, level+1, |
| 1036 |
0 |
| nLine = GetLineNoOf (r, pCurr), pToken -> sText))) |
| 1037 |
0 |
| return 1 ; |
| 1038 |
0 |
▶ | if (pToken -> bAddFlags) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pToken -> bAddFlags) |
0 |
0 |
0 |
|
| 1039 |
0 |
| Node_self (pDomTree, xNewAttrNode) -> bFlags |= pToken -> bAddFlags ; |
| 1040 |
0 |
▶ | if (pToken -> sParseTimePerlCode) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pToken -> sParseTimePerlCode) |
0 |
0 |
0 |
|
| 1041 |
0 |
▶ | if ((rc = ExecParseTimeCode (r, pToken, pCurr, pEnd - pCurr, nLine)) != ok) |
Branch: 1 branch
| Branch | True | False | Total |
| if ((rc = ExecParseTimeCode (r, pToken, pCurr, pEnd - pCurr, nLine)) != ok) |
0 |
0 |
0 |
|
| 1042 |
|
| { |
| 1043 |
0 |
| r -> Component.pCurrPos = pCurrTokenStart ; |
| 1044 |
0 |
| return rc ; |
| 1045 |
|
| } |
| 1046 |
|
| } |
| 1047 |
|
| |
| 1048 |
0 |
▶ | if (pToken -> nNodeType == ntypStartEndTag) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pToken -> nNodeType == ntypStartEndTag) |
0 |
0 |
0 |
|
| 1049 |
|
| { |
| 1050 |
0 |
▶ | xParentNode = Node_parentNode (r -> pApp, pDomTree, xNewNode, 0) ; |
Branch: 2 branches
| Branch | True | False | Total |
| xParentNode = Node_parentNode (r -> pApp, pDomTree, xNewNode, 0) ; |
0 |
0 |
0 |
| xParentNode = Node_parentNode (r -> pApp, pDomTree, xNewNode, 0) ; |
0 |
0 |
0 |
|
| 1051 |
0 |
| pToken = NULL ; |
| 1052 |
|
| } |
| 1053 |
|
| |
| 1054 |
|
| |
| 1055 |
0 |
| pCurr = pEndCurr + nSkip ; |
| 1056 |
|
| } |
| 1057 |
|
| } |
| 1058 |
|
| |
| 1059 |
0 |
▶ | if (pToken && (pToken -> nNodeType == ntypStartTag || |
Branch: 2 branches
| Branch | True | False | Total |
| if (pToken && (pToken -> nNodeType == ntypStartTag || |
0 |
0 |
0 |
| if (pToken && (pToken -> nNodeType == ntypStartTag || |
0 |
0 |
0 |
|
| 1060 |
0 |
▶ | pToken -> nNodeType == ntypEndStartTag || |
Branch: 1 branch
| Branch | True | False | Total |
| pToken -> nNodeType == ntypEndStartTag || |
0 |
0 |
0 |
|
| 1061 |
0 |
▶ | pToken -> nNodeType == ntypStartEndTag)) |
Branch: 1 branch
| Branch | True | False | Total |
| pToken -> nNodeType == ntypStartEndTag)) |
0 |
0 |
0 |
|
| 1062 |
|
| { |
| 1063 |
0 |
▶ | if (level++ > 1000) |
Branch: 1 branch
| Branch | True | False | Total |
| if (level++ > 1000) |
0 |
0 |
0 |
|
| 1064 |
|
| { |
| 1065 |
0 |
| r -> Component.pCurrPos = pCurrTokenStart ; |
| 1066 |
0 |
| return rcTooDeepNested ; |
| 1067 |
|
| } |
| 1068 |
0 |
| xParentNode = xNewNode ; |
| 1069 |
0 |
| nCDataType = pTokenTable -> nDefNodeType ; |
| 1070 |
|
| } |
| 1071 |
|
| } |
| 1072 |
0 |
| pCurrStart = pCurr ; |
| 1073 |
|
| } |
| 1074 |
|
| } |
| 1075 |
0 |
▶ | if (pParentContains && ((pParentContains [*pCurr >> 3] & 1 << (*pCurr & 7)) == 0) ) |
Branch: 2 branches
| Branch | True | False | Total |
| if (pParentContains && ((pParentContains [*pCurr >> 3] & 1 << (*pCurr & 7)) == 0) ) |
0 |
0 |
0 |
| if (pParentContains && ((pParentContains [*pCurr >> 3] & 1 << (*pCurr & 7)) == 0) ) |
0 |
0 |
0 |
|
| 1076 |
|
| { |
| 1077 |
0 |
▶ | if (pCurr - pCurrStart && nCDataType) |
Branch: 2 branches
| Branch | True | False | Total |
| if (pCurr - pCurrStart && nCDataType) |
0 |
0 |
0 |
| if (pCurr - pCurrStart && nCDataType) |
0 |
0 |
0 |
|
| 1078 |
|
| { |
| 1079 |
0 |
▶ | if (!(xNewNode = Node_appendChild (r -> pApp, pDomTree, xParentNode, 0, nCDataType, 0, |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(xNewNode = Node_appendChild (r -> pApp, pDomTree, xParentNode, 0, nCDataType, 0, |
0 |
0 |
0 |
|
| 1080 |
0 |
| pCurrStart, pCurr - pCurrStart, level, |
| 1081 |
|
| GetLineNoOf (r, pCurrStart), NULL))) |
| 1082 |
0 |
| return 1 ; |
| 1083 |
|
| } |
| 1084 |
0 |
| *ppCurr = pCurr ; |
| 1085 |
0 |
▶ | return bInsideMustExist?rcTokenNotFound:ok ; |
Branch: 1 branch
| Branch | True | False | Total |
| return bInsideMustExist?rcTokenNotFound:ok ; |
0 |
0 |
0 |
|
| 1086 |
|
| } |
| 1087 |
0 |
▶ | else if (sEndText == NULL || |
Branch: 1 branch
| Branch | True | False | Total |
| else if (sEndText == NULL || |
0 |
0 |
0 |
|
| 1088 |
0 |
▶ | ((*pCurr == *sEndText && (strncmp (pCurr, sEndText, nEndText) == 0)) || |
Branch: 2 branches
| Branch | True | False | Total |
| ((*pCurr == *sEndText && (strncmp (pCurr, sEndText, nEndText) == 0)) || |
0 |
0 |
0 |
| ((*pCurr == *sEndText && (strncmp (pCurr, sEndText, nEndText) == 0)) || |
0 |
0 |
0 |
|
| 1089 |
0 |
▶ | (pCurr[0] == '\n' && pCurr[1] == '\r' && pCurr[2] == '\n' && sEndText[1] == '\n' && sEndText[2] == '\0')) || |
Branch: 5 branches
| Branch | True | False | Total |
| (pCurr[0] == '\n' && pCurr[1] == '\r' && pCurr[2] == '\n' && sEndText[1] == '\n' && sEndText[2] == '\0')) || |
0 |
0 |
0 |
| (pCurr[0] == '\n' && pCurr[1] == '\r' && pCurr[2] == '\n' && sEndText[1] == '\n' && sEndText[2] == '\0')) || |
0 |
0 |
0 |
| (pCurr[0] == '\n' && pCurr[1] == '\r' && pCurr[2] == '\n' && sEndText[1] == '\n' && sEndText[2] == '\0')) || |
0 |
0 |
0 |
| (pCurr[0] == '\n' && pCurr[1] == '\r' && pCurr[2] == '\n' && sEndText[1] == '\n' && sEndText[2] == '\0')) || |
0 |
0 |
0 |
| (pCurr[0] == '\n' && pCurr[1] == '\r' && pCurr[2] == '\n' && sEndText[1] == '\n' && sEndText[2] == '\0')) || |
0 |
0 |
0 |
|
| 1090 |
0 |
▶ | (pCurr[0] == '\r' && pCurr[1] == '\n' && pCurr[2] == '\r' && pCurr[3] == '\n' && sEndText[0] == '\n' && sEndText[1] == '\n' && sEndText[2] == '\0') |
Branch: 7 branches
| Branch | True | False | Total |
| (pCurr[0] == '\r' && pCurr[1] == '\n' && pCurr[2] == '\r' && pCurr[3] == '\n' && sEndText[0] == '\n' && sEndText[1] == '\n' && sEndText[2] == '\0') |
0 |
0 |
0 |
| (pCurr[0] == '\r' && pCurr[1] == '\n' && pCurr[2] == '\r' && pCurr[3] == '\n' && sEndText[0] == '\n' && sEndText[1] == '\n' && sEndText[2] == '\0') |
0 |
0 |
0 |
| (pCurr[0] == '\r' && pCurr[1] == '\n' && pCurr[2] == '\r' && pCurr[3] == '\n' && sEndText[0] == '\n' && sEndText[1] == '\n' && sEndText[2] == '\0') |
0 |
0 |
0 |
| (pCurr[0] == '\r' && pCurr[1] == '\n' && pCurr[2] == '\r' && pCurr[3] == '\n' && sEndText[0] == '\n' && sEndText[1] == '\n' && sEndText[2] == '\0') |
0 |
0 |
0 |
| (pCurr[0] == '\r' && pCurr[1] == '\n' && pCurr[2] == '\r' && pCurr[3] == '\n' && sEndText[0] == '\n' && sEndText[1] == '\n' && sEndText[2] == '\0') |
0 |
0 |
0 |
| (pCurr[0] == '\r' && pCurr[1] == '\n' && pCurr[2] == '\r' && pCurr[3] == '\n' && sEndText[0] == '\n' && sEndText[1] == '\n' && sEndText[2] == '\0') |
0 |
0 |
0 |
| (pCurr[0] == '\r' && pCurr[1] == '\n' && pCurr[2] == '\r' && pCurr[3] == '\n' && sEndText[0] == '\n' && sEndText[1] == '\n' && sEndText[2] == '\0') |
0 |
0 |
0 |
|
| 1091 |
|
| ) |
| 1092 |
|
| { |
| 1093 |
|
| char * pEnd ; |
| 1094 |
0 |
▶ | if (pCDATAStart) |
Branch: 1 branch
| Branch | True | False | Total |
| if (pCDATAStart) |
0 |
0 |
0 |
|
| 1095 |
0 |
| pCurr += nEndText ; |
| 1096 |
0 |
| pEnd = pCurr - 1 ; |
| 1097 |
|
| |
| 1098 |
0 |
▶ | if (bRemoveSpaces & 32) |
Branch: 1 branch
| Branch | True | False | Total |
| if (bRemoveSpaces & 32) |
0 |
0 |
0 |
|
| 1099 |
0 |
▶ | while (pEnd >= pCurrStart && isspace (*pEnd)) |
Branch: 2 branches
| Branch | True | False | Total |
| while (pEnd >= pCurrStart && isspace (*pEnd)) |
0 |
0 |
0 |
| while (pEnd >= pCurrStart && isspace (*pEnd)) |
0 |
0 |
0 |
|
| 1100 |
0 |
| pEnd-- ; |
| 1101 |
0 |
▶ | else if (bRemoveSpaces & 64) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (bRemoveSpaces & 64) |
0 |
0 |
0 |
|
| 1102 |
0 |
▶ | while (pEnd >= pCurrStart && (*pEnd == ' ' || *pEnd == '\t' || *pEnd == '\r')) |
Branch: 4 branches
| Branch | True | False | Total |
| while (pEnd >= pCurrStart && (*pEnd == ' ' || *pEnd == '\t' || *pEnd == '\r')) |
0 |
0 |
0 |
| while (pEnd >= pCurrStart && (*pEnd == ' ' || *pEnd == '\t' || *pEnd == '\r')) |
0 |
0 |
0 |
| while (pEnd >= pCurrStart && (*pEnd == ' ' || *pEnd == '\t' || *pEnd == '\r')) |
0 |
0 |
0 |
| while (pEnd >= pCurrStart && (*pEnd == ' ' || *pEnd == '\t' || *pEnd == '\r')) |
0 |
0 |
0 |
|
| 1103 |
0 |
| pEnd-- ; |
| 1104 |
|
| |
| 1105 |
0 |
▶ | if ((pEnd - pCurrStart + 1 != 0 || nCDataType == ntypAttrValue) && nCDataType) |
Branch: 3 branches
| Branch | True | False | Total |
| if ((pEnd - pCurrStart + 1 != 0 || nCDataType == ntypAttrValue) && nCDataType) |
0 |
0 |
0 |
| if ((pEnd - pCurrStart + 1 != 0 || nCDataType == ntypAttrValue) && nCDataType) |
0 |
0 |
0 |
| if ((pEnd - pCurrStart + 1 != 0 || nCDataType == ntypAttrValue) && nCDataType) |
0 |
0 |
0 |
|
| 1106 |
0 |
▶ | if (!(xNewNode = Node_appendChild (r -> pApp, pDomTree, xParentNode, 0, nCDataType, 0, |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(xNewNode = Node_appendChild (r -> pApp, pDomTree, xParentNode, 0, nCDataType, 0, |
0 |
0 |
0 |
|
| 1107 |
0 |
| pCurrStart, pEnd - pCurrStart + 1, level, |
| 1108 |
|
| GetLineNoOf (r, pCurr), NULL))) |
| 1109 |
0 |
| return 1 ; |
| 1110 |
|
| |
| 1111 |
0 |
▶ | if (!pCDATAStart && !sStopText && (bDontEat & 2) == 0) |
Branch: 3 branches
| Branch | True | False | Total |
| if (!pCDATAStart && !sStopText && (bDontEat & 2) == 0) |
0 |
0 |
0 |
| if (!pCDATAStart && !sStopText && (bDontEat & 2) == 0) |
0 |
0 |
0 |
| if (!pCDATAStart && !sStopText && (bDontEat & 2) == 0) |
0 |
0 |
0 |
|
| 1112 |
0 |
| pCurr += nEndText ; |
| 1113 |
0 |
| *ppCurr = pCurr ; |
| 1114 |
0 |
▶ | return bInsideMustExist?rcTokenNotFound:ok ; |
Branch: 1 branch
| Branch | True | False | Total |
| return bInsideMustExist?rcTokenNotFound:ok ; |
0 |
0 |
0 |
|
| 1115 |
|
| } |
| 1116 |
0 |
▶ | else if (!pToken && bFollow < 2) |
Branch: 2 branches
| Branch | True | False | Total |
| else if (!pToken && bFollow < 2) |
0 |
0 |
0 |
| else if (!pToken && bFollow < 2) |
0 |
0 |
0 |
|
| 1117 |
0 |
| pCurr++ ; |
| 1118 |
|
| |
| 1119 |
0 |
▶ | if (pToken && (pToken -> bExitInside)) |
Branch: 2 branches
| Branch | True | False | Total |
| if (pToken && (pToken -> bExitInside)) |
0 |
0 |
0 |
| if (pToken && (pToken -> bExitInside)) |
0 |
0 |
0 |
|
| 1120 |
|
| { |
| 1121 |
0 |
| *ppCurr = pCurr ; |
| 1122 |
0 |
| return ok ; |
| 1123 |
|
| } |
| 1124 |
|
| } |
| 1125 |
|
| |
| 1126 |
0 |
▶ | if (nCDataType && pCurr - pCurrStart) |
Branch: 2 branches
| Branch | True | False | Total |
| if (nCDataType && pCurr - pCurrStart) |
0 |
0 |
0 |
| if (nCDataType && pCurr - pCurrStart) |
0 |
0 |
0 |
|
| 1127 |
0 |
▶ | if (!(xNewNode = Node_appendChild (r -> pApp, pDomTree, xParentNode, 0, nCDataType, 0, |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(xNewNode = Node_appendChild (r -> pApp, pDomTree, xParentNode, 0, nCDataType, 0, |
0 |
0 |
0 |
|
| 1128 |
0 |
| pCurrStart, pCurr - pCurrStart, level, |
| 1129 |
|
| GetLineNoOf (r, pCurrStart), NULL))) |
| 1130 |
0 |
| return 1 ; |
| 1131 |
|
| |
| 1132 |
0 |
| *ppCurr = pCurr ; |
| 1133 |
0 |
▶ | return bInsideMustExist?rcTokenNotFound:ok ; |
Branch: 1 branch
| Branch | True | False | Total |
| return bInsideMustExist?rcTokenNotFound:ok ; |
0 |
0 |
0 |
|
| 1134 |
|
| } |
| 1135 |
|
| |
| 1136 |
|
| |
| 1137 |
|
| |
| 1138 |
|
| /* ------------------------------------------------------------------------ */ |
| 1139 |
|
| /* */ |
| 1140 |
|
| /* embperl_Parse */ |
| 1141 |
|
| /* */ |
| 1142 |
|
| /*! |
| 1143 |
|
| * \_en |
| 1144 |
|
| * Parse source into given DomTree |
| 1145 |
|
| * |
| 1146 |
|
| * @param r Embperl request record |
| 1147 |
|
| * @param pSource Sourcetext |
| 1148 |
|
| * @param nLen Length of Sourcetext |
| 1149 |
|
| * @param pDomTree Destination DomTree |
| 1150 |
|
| * @return error code |
| 1151 |
|
| * \endif |
| 1152 |
|
| * |
| 1153 |
|
| * \_de |
| 1154 |
|
| * Parst die Quelle in den gegebenen DomTree |
| 1155 |
|
| * |
| 1156 |
|
| * @param r Embperl request record |
| 1157 |
|
| * @param pSource Quellentext |
| 1158 |
|
| * @param nLen Länge des Quellentext |
| 1159 |
|
| * @param pDomTree Ziel DomTree |
| 1160 |
|
| * @return Fehlercode |
| 1161 |
|
| * \endif |
| 1162 |
|
| * |
| 1163 |
|
| * ------------------------------------------------------------------------ */ |
| 1164 |
|
| |
| 1165 |
|
| |
| 1166 |
0 |
| static int embperl_ParseSource (/*i/o*/ register req * r, |
| 1167 |
|
| /*in*/ char * pSource, |
| 1168 |
|
| /*in*/ size_t nLen, |
| 1169 |
|
| /*in*/ tDomTree * pDomTree) |
| 1170 |
|
| |
| 1171 |
|
| { |
| 1172 |
0 |
| char * pStart = pSource ; |
| 1173 |
0 |
| char * pEnd = pSource + nLen ; |
| 1174 |
|
| int rc ; |
| 1175 |
|
| tNode xDocNode ; |
| 1176 |
|
| tNode xDocNode2 ; |
| 1177 |
|
| tNode xNode ; |
| 1178 |
|
| tTokenTable * pTokenTableSave ; |
| 1179 |
0 |
| clock_t cl1 = clock () ; |
| 1180 |
|
| clock_t cl2 ; |
| 1181 |
|
| |
| 1182 |
0 |
| r -> Component.pBuf = (char *)pStart ; |
| 1183 |
0 |
| r -> Component.pEndPos = (char *)pEnd ; |
| 1184 |
0 |
| r -> Component.pSourcelinePos = r -> Component.pCurrPos = r -> Component.pBuf ; |
| 1185 |
|
| |
| 1186 |
0 |
▶ | if (r -> Component.Config.bDebug & dbgParse) |
Branch: 1 branch
| Branch | True | False | Total |
| if (r -> Component.Config.bDebug & dbgParse) |
0 |
0 |
0 |
|
| 1187 |
0 |
| lprintf (r -> pApp, "[%d]PARSE: Start parsing %s DomTree = %d\n", r -> pThread -> nPid, r -> Component.sSourcefile, r -> Component.xCurrDomTree) ; |
| 1188 |
|
| |
| 1189 |
0 |
| pDomTree -> xFilename = String2Ndx (r -> pApp, r -> Component.sSourcefile, strlen (r -> Component.sSourcefile)) ; |
| 1190 |
|
| |
| 1191 |
0 |
▶ | if (!(xDocNode = Node_appendChild (r -> pApp, pDomTree, 0, 0, ntypTag, 0, "attr", 3, 0, 0, NULL))) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(xDocNode = Node_appendChild (r -> pApp, pDomTree, 0, 0, ntypTag, 0, "attr", 3, 0, 0, NULL))) |
0 |
0 |
0 |
|
| 1192 |
0 |
| return rcOutOfMemory ; |
| 1193 |
|
| |
| 1194 |
0 |
▶ | if (!(xDocNode = Node_appendChild (r -> pApp, pDomTree, 0, 0, (tNodeType)((r -> Component.pPrev)?ntypDocumentFraq:ntypDocument), 0, |
Branch: 2 branches
| Branch | True | False | Total |
| if (!(xDocNode = Node_appendChild (r -> pApp, pDomTree, 0, 0, (tNodeType)((r -> Component.pPrev)?ntypDocumentFraq:ntypDocument), 0, |
0 |
0 |
0 |
| if (!(xDocNode = Node_appendChild (r -> pApp, pDomTree, 0, 0, (tNodeType)((r -> Component.pPrev)?ntypDocumentFraq:ntypDocument), 0, |
0 |
0 |
0 |
|
| 1195 |
0 |
▶ | NULL, r -> Component.pPrev?xDocumentFraq:xDocument, 0, 0, NULL))) |
Branch: 1 branch
| Branch | True | False | Total |
| NULL, r -> Component.pPrev?xDocumentFraq:xDocument, 0, 0, NULL))) |
0 |
0 |
0 |
|
| 1196 |
0 |
| return rcOutOfMemory ; |
| 1197 |
|
| |
| 1198 |
0 |
| xDocNode2 = xDocNode ; |
| 1199 |
0 |
▶ | if (r -> Component.pTokenTable -> sRootNode) |
Branch: 1 branch
| Branch | True | False | Total |
| if (r -> Component.pTokenTable -> sRootNode) |
0 |
0 |
0 |
|
| 1200 |
|
| { |
| 1201 |
|
| /* Add at least one child node before root node to make insertafter at the beginning of the document work */ |
| 1202 |
0 |
▶ | if (!(Node_appendChild (r -> pApp, pDomTree, xDocNode, 0, ntypCDATA, 0, |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(Node_appendChild (r -> pApp, pDomTree, xDocNode, 0, ntypCDATA, 0, |
0 |
0 |
0 |
|
| 1203 |
|
| "", 0, |
| 1204 |
|
| 0, 0, NULL))) |
| 1205 |
0 |
| return rcOutOfMemory ; |
| 1206 |
|
| |
| 1207 |
0 |
▶ | if (!(xDocNode2 = Node_appendChild (r -> pApp, pDomTree, xDocNode, 0, ntypStartTag, 0, |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(xDocNode2 = Node_appendChild (r -> pApp, pDomTree, xDocNode, 0, ntypStartTag, 0, |
0 |
0 |
0 |
|
| 1208 |
0 |
| r -> Component.pTokenTable -> sRootNode, |
| 1209 |
0 |
| strlen (r -> Component.pTokenTable -> sRootNode), |
| 1210 |
|
| 0, 0, NULL))) |
| 1211 |
0 |
| return rcOutOfMemory ; |
| 1212 |
|
| } |
| 1213 |
|
| |
| 1214 |
0 |
▶ | if (!(xNode = Node_appendChild (r -> pApp, pDomTree, xDocNode, 0, ntypAttr, 0, NULL, xDomTreeAttr, 0, 0, NULL))) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(xNode = Node_appendChild (r -> pApp, pDomTree, xDocNode, 0, ntypAttr, 0, NULL, xDomTreeAttr, 0, 0, NULL))) |
0 |
0 |
0 |
|
| 1215 |
0 |
| return rcOutOfMemory ; |
| 1216 |
|
| |
| 1217 |
0 |
▶ | if (!(xNode = Node_appendChild (r -> pApp, pDomTree, xNode, 0, ntypAttrValue, 0, (char *)&(r -> Component.xCurrDomTree), sizeof (r -> Component.xCurrDomTree), 0, 0, NULL))) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(xNode = Node_appendChild (r -> pApp, pDomTree, xNode, 0, ntypAttrValue, 0, (char *)&(r -> Component.xCurrDomTree), sizeof (r -> Component.xCurrDomTree), 0, 0, NULL))) |
0 |
0 |
0 |
|
| 1218 |
0 |
| return rcOutOfMemory ; |
| 1219 |
|
| |
| 1220 |
|
| /* Add at least one child node to document to make insertafter at the beginning of the document work */ |
| 1221 |
0 |
▶ | if (!(xNode = Node_appendChild (r -> pApp, pDomTree, xDocNode2, 0, ntypCDATA, 0, "", 0, 0, 0, NULL))) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(xNode = Node_appendChild (r -> pApp, pDomTree, xDocNode2, 0, ntypCDATA, 0, "", 0, 0, 0, NULL))) |
0 |
0 |
0 |
|
| 1222 |
0 |
| return rcOutOfMemory ; |
| 1223 |
|
| |
| 1224 |
0 |
| pDomTree -> xDocument = xDocNode ; |
| 1225 |
|
| |
| 1226 |
0 |
| pTokenTableSave = r -> Component.pTokenTable ; |
| 1227 |
|
| |
| 1228 |
0 |
▶ | if ((rc = ParseTokens (r, &pStart, pEnd, r -> Component.pTokenTable, "", NULL, (tNodeType)r -> Component.pTokenTable -> nDefNodeType, 0, 0, 0, 0, String2Ndx (r -> pApp, "root", 4), xDocNode2, 0, NULL, NULL, 0)) != ok) |
Branch: 1 branch
| Branch | True | False | Total |
| if ((rc = ParseTokens (r, &pStart, pEnd, r -> Component.pTokenTable, "", NULL, (tNodeType)r -> Component.pTokenTable -> nDefNodeType, 0, 0, 0, 0, String2Ndx (r -> pApp, "root", 4), xDocNode2, 0, NULL, NULL, 0)) != ok) |
0 |
0 |
0 |
|
| 1229 |
0 |
| return rc ; |
| 1230 |
|
| |
| 1231 |
|
| /* Add one child node end the end to catch loops that end at the very last node */ |
| 1232 |
0 |
▶ | if (!(xNode = Node_appendChild (r -> pApp, pDomTree, xDocNode2, 0, ntypCDATA, 0, "", 0, 0, 0, NULL))) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(xNode = Node_appendChild (r -> pApp, pDomTree, xDocNode2, 0, ntypCDATA, 0, "", 0, 0, 0, NULL))) |
0 |
0 |
0 |
|
| 1233 |
0 |
| return rcOutOfMemory ; |
| 1234 |
|
| |
| 1235 |
0 |
| r -> Component.pTokenTable = pTokenTableSave ; |
| 1236 |
|
| |
| 1237 |
|
| |
| 1238 |
|
| #ifdef CLOCKS_PER_SEC |
| 1239 |
0 |
▶ | if (r -> Component.Config.bDebug) |
Branch: 1 branch
| Branch | True | False | Total |
| if (r -> Component.Config.bDebug) |
0 |
0 |
0 |
|
| 1240 |
|
| { |
| 1241 |
0 |
| cl2 = clock () ; |
| 1242 |
0 |
| lprintf (r -> pApp, "[%d]PERF: Parse Start Time: %d ms \n", r -> pThread -> nPid, ((cl1 - r -> startclock) * 1000 / CLOCKS_PER_SEC)) ; |
| 1243 |
0 |
| lprintf (r -> pApp, "[%d]PERF: Parse End Time: %d ms \n", r -> pThread -> nPid, ((cl2 - r -> startclock) * 1000 / CLOCKS_PER_SEC)) ; |
| 1244 |
0 |
| lprintf (r -> pApp, "[%d]PERF: Parse Time: %d ms \n", r -> pThread -> nPid, ((cl2 - cl1) * 1000 / CLOCKS_PER_SEC)) ; |
| 1245 |
0 |
| DomStats (r -> pApp) ; |
| 1246 |
|
| } |
| 1247 |
|
| #endif |
| 1248 |
|
| |
| 1249 |
0 |
| return ok ; |
| 1250 |
|
| } |
| 1251 |
|
| |
| 1252 |
|
| |
| 1253 |
|
| /* ------------------------------------------------------------------------ */ |
| 1254 |
|
| /* */ |
| 1255 |
|
| /* embperl_Parse */ |
| 1256 |
|
| /* */ |
| 1257 |
|
| /*! |
| 1258 |
|
| * \_en |
| 1259 |
|
| * Parse source and create DomTree |
| 1260 |
|
| * |
| 1261 |
|
| * @param r Embperl request record |
| 1262 |
|
| * @param pSource Sourcetext |
| 1263 |
|
| * @param nLen Length of Sourcetext |
| 1264 |
|
| * @param pxDomTree Returns DomTree index |
| 1265 |
|
| * @return error code |
| 1266 |
|
| * \endif |
| 1267 |
|
| * |
| 1268 |
|
| * \_de |
| 1269 |
|
| * Parst die Quelle und erzeugt einen DomTree |
| 1270 |
|
| * |
| 1271 |
|
| * @param r Embperl request record |
| 1272 |
|
| * @param pSource Quellentext |
| 1273 |
|
| * @param nLen Länge des Quellentext |
| 1274 |
|
| * @param pxDomTree Gibt DomTree Index zurück |
| 1275 |
|
| * @return Fehlercode |
| 1276 |
|
| * \endif |
| 1277 |
|
| * |
| 1278 |
|
| * ------------------------------------------------------------------------ */ |
| 1279 |
|
| |
| 1280 |
|
| |
| 1281 |
0 |
| int embperl_Parse (/*i/o*/ register req * r, |
| 1282 |
|
| /*in*/ char * pSource, |
| 1283 |
|
| /*in*/ size_t nLen, |
| 1284 |
|
| /*out*/ tIndex * pxDomTree) |
| 1285 |
|
| |
| 1286 |
|
| { |
| 1287 |
|
| int rc ; |
| 1288 |
|
| tDomTree * pDomTree ; |
| 1289 |
|
| |
| 1290 |
0 |
▶ | if (!(r -> Component.xCurrDomTree = DomTree_new (r -> pApp, &pDomTree))) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!(r -> Component.xCurrDomTree = DomTree_new (r -> pApp, &pDomTree))) |
0 |
0 |
0 |
|
| 1291 |
0 |
| return rcOutOfMemory ; |
| 1292 |
|
| |
| 1293 |
0 |
▶ | if ((rc = embperl_ParseSource (r, pSource, nLen, pDomTree)) != ok) |
Branch: 1 branch
| Branch | True | False | Total |
| if ((rc = embperl_ParseSource (r, pSource, nLen, pDomTree)) != ok) |
0 |
0 |
0 |
|
| 1294 |
|
| { |
| 1295 |
0 |
| pDomTree = DomTree_self (r -> Component.xCurrDomTree) ; |
| 1296 |
0 |
| *pxDomTree = r -> Component.xCurrDomTree = 0 ; |
| 1297 |
0 |
| DomTree_delete (r -> pApp, pDomTree) ; |
| 1298 |
0 |
| return rc ; |
| 1299 |
|
| } |
| 1300 |
|
| |
| 1301 |
0 |
| *pxDomTree = r -> Component.xCurrDomTree ; |
| 1302 |
0 |
| return ok ; |
| 1303 |
|
| } |
| 1304 |
|
| |
| 1305 |
|
| |
| 1306 |
|
| /* ------------------------------------------------------------------------ */ |
| 1307 |
|
| /* */ |
| 1308 |
|
| /* ParseFile */ |
| 1309 |
|
| /* */ |
| 1310 |
|
| /* Parse a source file */ |
| 1311 |
|
| /* */ |
| 1312 |
|
| /* ------------------------------------------------------------------------ */ |
| 1313 |
|
| |
| 1314 |
|
| |
| 1315 |
0 |
| int ParseFile (/*i/o*/ register req * r) |
| 1316 |
|
| |
| 1317 |
|
| { |
| 1318 |
0 |
| char * pStart = r -> Component.pBuf ; |
| 1319 |
0 |
| char * pEnd = r -> Component.pEndPos ; |
| 1320 |
|
| tIndex xDomTree ; |
| 1321 |
|
| |
| 1322 |
0 |
| return embperl_Parse (r, pStart, pEnd - pStart, &xDomTree) ; |
| 1323 |
|
| } |
| 1324 |
|
| |