y_url.cpp
来自「Pegasus is an open-source implementation」· C++ 代码 · 共 1,826 行 · 第 1/4 页
CPP
1,826 行
} } ; break;}case 31:#line 466 "url.y"{ yyval._atl = &attrHead; if (yyvsp[0]._atl != NULL) { _LSLP_INSERT_BEFORE(yyvsp[0]._atl, yyval._atl); } ; break;}case 32:#line 473 "url.y"{ yyval._atl = &attrHead; if (yyvsp[0]._atl != NULL) { _LSLP_INSERT_BEFORE(yyvsp[0]._atl, yyval._atl); } ; break;}case 33:#line 482 "url.y"{ if(NULL != (yyval._atl = (lslpAtomList *)calloc(1, sizeof(lslpAtomList)))) { yyval._atl->prev = yyval._atl->next = yyval._atl; if(NULL != (yyval._atl->str = (char *)calloc(1 + strlen(yyvsp[0]._s), sizeof(char)))) { strcpy(yyval._atl->str, yyvsp[0]._s); yyval._atl->hash = lslpCheckSum(yyval._atl->str, (int16)strlen(yyval._atl->str)); } else { free(yyval._atl); yyval._atl = NULL; } } ; break;}case 34:#line 499 "url.y"{ if(NULL != (yyval._atl = (lslpAtomList *)calloc(1, sizeof(lslpAtomList)))) { yyval._atl->prev = yyval._atl->next = yyval._atl; if(NULL != (yyval._atl->str = (char *)calloc(2 + strlen(yyvsp[-2]._s) + strlen(yyvsp[0]._s), sizeof(char)))) { strcpy(yyval._atl->str, yyvsp[-2]._s); strcat(yyval._atl->str, "="); strcat(yyval._atl->str, yyvsp[0]._s); yyval._atl->hash = lslpCheckSum(yyval._atl->str, (int16)strlen(yyval._atl->str)); } else { free(yyval._atl); yyval._atl = NULL; } } ; break;}}#line 705 "bison.simple" yyvsp -= yylen; yyssp -= yylen;#if YYLSP_NEEDED yylsp -= yylen;#endif#if YYDEBUG if (yydebug) { short *yyssp1 = yyss - 1; YYFPRINTF (stderr, "state stack now"); while (yyssp1 != yyssp) YYFPRINTF (stderr, " %d", *++yyssp1); YYFPRINTF (stderr, "\n"); }#endif *++yyvsp = yyval;#if YYLSP_NEEDED *++yylsp = yyloc;#endif /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTBASE] + *yyssp; if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTBASE]; goto yynewstate;/*------------------------------------.| yyerrlab -- here on detecting error |`------------------------------------*/yyerrlab: /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs;#ifdef YYERROR_VERBOSE yyn = yypact[yystate]; if (yyn > YYFLAG && yyn < YYLAST) { YYSIZE_T yysize = 0; char *yymsg; int yyx, yycount; yycount = 0; /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ for (yyx = yyn < 0 ? -yyn : 0; yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) if (yycheck[yyx + yyn] == yyx) yysize += yystrlen (yytname[yyx]) + 15, yycount++; yysize += yystrlen ("parse error, unexpected ") + 1; yysize += yystrlen (yytname[YYTRANSLATE (yychar)]); yymsg = (char *) YYSTACK_ALLOC (yysize); if (yymsg != 0) { char *yyp = yystpcpy (yymsg, "parse error, unexpected "); yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]); if (yycount < 5) { yycount = 0; for (yyx = yyn < 0 ? -yyn : 0; yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) if (yycheck[yyx + yyn] == yyx) { const char *yyq = ! yycount ? ", expecting " : " or "; yyp = yystpcpy (yyp, yyq); yyp = yystpcpy (yyp, yytname[yyx]); yycount++; } } yyerror (yymsg); YYSTACK_FREE (yymsg); } else yyerror ("parse error; also virtual memory exhausted"); } else#endif /* defined (YYERROR_VERBOSE) */ yyerror ("parse error"); } goto yyerrlab1;/*--------------------------------------------------.| yyerrlab1 -- error raised explicitly by an action |`--------------------------------------------------*/yyerrlab1: if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ /* return failure if at end of input */ if (yychar == YYEOF) YYABORT; YYDPRINTF ((stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1])); yychar = YYEMPTY; } /* Else will try to reuse lookahead token after shifting the error token. */ yyerrstatus = 3; /* Each real token shifted decrements this */ goto yyerrhandle;/*-------------------------------------------------------------------.| yyerrdefault -- current state does not do anything special for the || error token. |`-------------------------------------------------------------------*/yyerrdefault:#if 0 /* This is wrong; only states that explicitly want error tokens should shift them. */ /* If its default is to accept any token, ok. Otherwise pop it. */ yyn = yydefact[yystate]; if (yyn) goto yydefault;#endif/*---------------------------------------------------------------.| yyerrpop -- pop the current state because it cannot handle the || error token |`---------------------------------------------------------------*/yyerrpop: if (yyssp == yyss) YYABORT; yyvsp--; yystate = *--yyssp;#if YYLSP_NEEDED yylsp--;#endif#if YYDEBUG if (yydebug) { short *yyssp1 = yyss - 1; YYFPRINTF (stderr, "Error: state stack now"); while (yyssp1 != yyssp) YYFPRINTF (stderr, " %d", *++yyssp1); YYFPRINTF (stderr, "\n"); }#endif/*--------------.| yyerrhandle. |`--------------*/yyerrhandle: yyn = yypact[yystate]; if (yyn == YYFLAG) goto yyerrdefault; yyn += YYTERROR; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) goto yyerrdefault; yyn = yytable[yyn]; if (yyn < 0) { if (yyn == YYFLAG) goto yyerrpop; yyn = -yyn; goto yyreduce; } else if (yyn == 0) goto yyerrpop; if (yyn == YYFINAL) YYACCEPT; YYDPRINTF ((stderr, "Shifting error token, ")); *++yyvsp = yylval;#if YYLSP_NEEDED *++yylsp = yylloc;#endif yystate = yyn; goto yynewstate;/*-------------------------------------.| yyacceptlab -- YYACCEPT comes here. |`-------------------------------------*/yyacceptlab: yyresult = 0; goto yyreturn;/*-----------------------------------.| yyabortlab -- YYABORT comes here. |`-----------------------------------*/yyabortlab: yyresult = 1; goto yyreturn;/*---------------------------------------------.| yyoverflowab -- parser overflow comes here. |`---------------------------------------------*/yyoverflowlab: yyerror ("parser stack overflow"); yyresult = 2; /* Fall through. */yyreturn:#ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss);#endif return yyresult;}#line 519 "url.y" lslpAtomList *lslpAllocAtom(void){ lslpAtomList *temp = (lslpAtomList *)calloc(1, sizeof(lslpAtomList)); if (temp != NULL) { temp->next = temp->prev = temp; } return(temp);} lslpAtomList *lslpAllocAtomList(void){ lslpAtomList *temp =lslpAllocAtom(); if (temp != NULL) temp->isHead = TRUE; return(temp);} void lslpFreeAtom(lslpAtomList *a ){ assert(a != NULL); if (a->str != NULL) free(a->str); free(a); return;} void lslpFreeAtomList(lslpAtomList *l, int32 flag){ lslpAtomList *temp; assert(l != NULL); assert(_LSLP_IS_HEAD(l)); while (! _LSLP_IS_EMPTY(l)) { temp = l->next; temp->prev->next = temp->next; temp->next->prev = temp->prev; lslpFreeAtom(temp); } if (flag) lslpFreeAtom(l); return;} lslpAtomizedURL *lslpAllocAtomizedURL(void){ lslpAtomizedURL *temp = (lslpAtomizedURL *)calloc(1, sizeof(lslpAtomizedURL)); if (temp != NULL) { temp->prev = temp->next = temp; } return(temp);} lslpAtomizedURL *lslpAllocAtomizedURLList(void){ lslpAtomizedURL *temp = lslpAllocAtomizedURL(); if (temp != NULL) { temp->isHead = TRUE; } return(temp);} void lslpFreeAtomizedURL(lslpAtomizedURL *u){ assert(u != NULL); if (u->url != NULL) free(u->url); if (! _LSLP_IS_EMPTY(&(u->srvcs))) lslpFreeAtomList(&(u->srvcs), 0); if (! _LSLP_IS_EMPTY(&(u->site))) lslpFreeAtomList(&(u->site), 0); if (! _LSLP_IS_EMPTY(&(u->path))) lslpFreeAtomList(&(u->path), 0); if (! _LSLP_IS_EMPTY(&(u->attrs))) lslpFreeAtomList(&(u->attrs), 0); free(u); return;} void lslpFreeAtomizedURLList(lslpAtomizedURL *l, int32 flag){ lslpAtomizedURL *temp; assert(l != NULL); assert(_LSLP_IS_HEAD(l)); while (! (_LSLP_IS_HEAD(l->next))) { temp = l->next; temp->prev->next = temp->next; temp->next->prev = temp->prev; lslpFreeAtomizedURL(temp); } if (flag) free(l); return;} void lslpInitAtomLists(void){ srvcHead.next = srvcHead.prev = &srvcHead; siteHead.next = siteHead.prev = &siteHead; pathHead.next = pathHead.prev = &pathHead; attrHead.next = attrHead.prev = &attrHead; return;} void lslpInitURLList(void){ urlHead.next = urlHead.prev = &urlHead; return;} void lslpCleanUpURLLists(void){ lslpFreeAtomList(&srvcHead, 0); lslpFreeAtomList(&siteHead, 0); lslpFreeAtomList(&pathHead, 0); lslpFreeAtomList(&attrHead, 0); lslpFreeAtomizedURLList(&urlHead, 0);}lslpAtomizedURL *_lslpDecodeURLs(char *u[], int32 count){ int32 i; uint32 lexer = 0; lslpAtomizedURL *temp = NULL; assert(u != NULL && u[count - 1] != NULL); lslpInitURLList(); lslpInitAtomLists(); for (i = 0; i < count; i++) { if (NULL == u[i]) break; if((0 != (lexer = url_init_lexer(u[i])))) { if(urlparse()) lslpCleanUpURLLists(); url_close_lexer(lexer); } } if (! _LSLP_IS_EMPTY(&urlHead)) { if(NULL != (temp = lslpAllocAtomizedURLList())) { _LSLP_LINK_HEAD(temp, &urlHead); } } return(temp); }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?