Severity: 8192
Message: Function create_function() is deprecated
Filename: geshi/geshi.php
Line Number: 4698
Backtrace:
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4698
Function: _error_handler
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4621
Function: _optimize_regexp_list_tokens_to_string
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 1655
Function: optimize_regexp_list
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2029
Function: optimize_keyword_group
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2168
Function: build_parse_cache
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/Process.php
Line: 45
Function: parse_code
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/models/Pastes.php
Line: 517
Function: syntax
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 693
Function: getPaste
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once
//?????????PYZ????
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <fstream>
#define char_num 1000 //???????
using namespace std;
struct Node //?????????????
{
char content[char_num] = {0}; //?????????
int LineNum;//??
Node *next = nullptr;//?????
Node *priv = nullptr;//?????
};
class TextArea //??????;?????TextArea?????????????;???????????????????,?????????
{
public:
int LineCount = 0;//???
int CharCount = 0;//????
Node *last = nullptr; //?????????????
Node *first = nullptr;//???????????
Node *head = nullptr; //?????content???next?????????
TextArea() = default; //??????
};
void PrintNodes(Node *);//?????????????????????
void PrintNode(Node *);//??????
void DelNode(int, TextArea &);//??????
Node *GoTo(int, TextArea &); //???????
int main()
{
TextArea text1; //??????
text1.head = new Node; //??????????next???????,????????
text1.head->LineNum = -1;
char *InFileName = new char[100]; //???????
char *OutFileName = new char[100]; //???????
cout << "??????????(??????)?";
cin >> InFileName;
cout << "??????????(??????)?";
cin >> OutFileName;
fstream InFile; //??fstream?????
InFile.open(InFileName, fstream::in | fstream::out); //??????
if (!InFile.is_open()) //??????????InFile.is_open()=1????????????
{
cout << "????????????????Y/N" << endl;
char YN;
cin >> YN;
if (YN >= 'A' && YN <= 'Z')
{
YN += 'a' - 'A'; //?????
}
if (YN == 'y')
{
InFile.open(InFileName, fstream::in | fstream::out | fstream::trunc); //????
}
else
exit(1); //?????
}
Node *CurNode = new Node;
text1.head->next = CurNode;
if (!InFile.eof()) //????????
{
InFile.getline(CurNode->content, char_num - 1); //?????????????????????????????????
text1.CharCount += strlen(CurNode->content); //????
text1.LineCount++; //????
CurNode->LineNum = text1.LineCount; //????
}
while (!InFile.eof()) //????????????????????
{
Node *TempNode = CurNode;
CurNode->next = new Node;
CurNode = CurNode->next;
CurNode->priv = TempNode; //???????
text1.LineCount++;
CurNode->LineNum = text1.LineCount;
InFile.getline(CurNode->content, char_num - 1);//????????content(????)
text1.CharCount += strlen(CurNode->content);
//???????
}
InFile.close();//????
text1.last = CurNode; //???????????
text1.first = text1.head->next; //??????????
char action;
Node *CurNode2 = nullptr; //??????????????????
Node *temp = nullptr; //?????????temp??
int CurLine = 0; //????????0????
while (1)
{
cout << "?????(??H ? h????? ) : ";
cin >> action;
getchar(); //??????????
if (action >= 'A' && action <= 'Z')
{
action += 'a' - 'A'; //?????
}
switch (action)
{
case 'h': //Help
cout << "???????(??????)" << endl;
cout << "V:????????" << endl;
cout << "F:?????" << endl;
cout << "L:??????" << endl;
cout << "N:?????" << endl;
cout << "P:?????" << endl;
cout << "G:???????" << endl;
cout << "D:??????" << endl;
cout << "O:???????" << endl;
cout << "S:????????" << endl;
cout << "R:????????" << endl;
cout << "T:??????" << endl;
cout << "C:????" << endl;
cout << "E:?????" << endl;
break;
case 'v': //View The Whole File
PrintNodes(text1.head);
break;
case 'g': //Goto A Line
int GoNum;
cout << "??????????";
if (!(cin >> GoNum))
{
cout << "????!" << endl;
break;
}
temp = GoTo(GoNum, text1);
if (temp == nullptr)
{
cout << "?????" << endl;
break;
}
CurNode2 = temp;
CurLine = CurNode2->LineNum;
PrintNode(CurNode2);
temp = nullptr; //temp???????
break;
case 'e': //Exit
exit(0);
break;
case 'f': //Go To First Line
CurLine = 1;
CurNode2 = GoTo(1, text1);
PrintNode(GoTo(1, text1));
break;
case 'l': //Go To Last Line
CurLine = text1.LineCount;
CurNode2 = GoTo(text1.LineCount, text1);
PrintNode(CurNode2);
break;
case 'n': //Go To Next Line
if (CurLine == 0)//?????????????????????????????CurNode2=nullptr,????
{
CurLine = 1;
CurNode2 = GoTo(1, text1);
PrintNode(GoTo(1, text1));
break;
}
if (CurLine == text1.LineCount)
{
cout << "???????" << endl;
break;
}
CurLine++;
CurNode2 = CurNode2->next;
PrintNode(CurNode2);
break;
case 'p': //Go To Previous Line
if (CurLine == 1 || CurLine == 0)
{
cout << "??????" << endl;
break;
}
CurLine--;
CurNode2 = CurNode2->priv;
PrintNode(CurNode2);
break;
case 'd': //Delete A Line
int DelNum;
cout << "??????????";
cin >> DelNum;
if (DelNum < CurLine) //???????????(????????????????????????????????
{
CurLine--;//?????????????????????????
}
else if (DelNum == CurLine) //???????????
{
if (CurNode2->next) //??Curnode2?next??????????????????????????
{
CurNode2 = CurNode2->next;
}
else //??CurNode2??next(????????)
{
if (CurNode2->priv) //?priv
{
CurLine--;
CurNode2 = CurNode2->priv;
}
else //??next????priv????????
{
//CurLine?CurNode2??
}
}
}
DelNode(DelNum, text1);//?????????????
break;
case 'i': //Insert A Line After Current Line
if (CurNode2) //CurNode2!=nullptr????????0?
{
temp = CurNode2;
while (temp->next) //????????????????(???????????while???????while(temp?next))
{
temp = temp->next;
temp->LineNum++;
}
temp = new Node;
temp->LineNum = CurLine + 1; //???????????????
if (CurNode2->next)
{
temp->priv = CurNode2;
temp->next = CurNode2->next;
CurNode2->next->priv = temp;
CurNode2->next = temp;
}
else //CurNode2?next?????????????????????
{
CurNode2->next = temp;
temp->priv = CurNode2;
temp->next = nullptr;//?????????
}
text1.LineCount++; //?????
cout << "??????????";
fgets(temp->content, char_num - 1, stdin);
if (temp->content[strlen(temp->content) - 1] == '\n') //fgets????????????content,????????????????
temp->content[strlen(temp->content) - 1] = 0;
CurLine++;
CurNode2 = temp; //????????????
cout << "?????" << endl;
temp = nullptr;
break;
}
cout << "?????????????" << endl;//?????????CurNode2??
break;
case 'o': //Override Current Line
if (CurNode2)
{
memset(CurNode2->content, 0, char_num);//????????
cout << "???????????????";
fgets(CurNode2->content, char_num - 1, stdin);
if (CurNode2->content[strlen(CurNode2->content) - 1] == '\n')
CurNode2->content[strlen(CurNode2->content) - 1] = 0;
cout << "?????" << endl;
break;
}
cout << "?????????????" << endl;
break;
case 's': //Search For A SubString In Current Line
if (CurNode2)
{
cout << "??????" << endl;
PrintNode(CurNode2);//?????????
cout << "??????????????";
char SearchChar[char_num] = {0};//???????
fgets(SearchChar, char_num - 1, stdin);//????????
if (SearchChar[strlen(SearchChar) - 1] == '\n')//????
SearchChar[strlen(SearchChar) - 1] = 0;
char *Place = strstr(CurNode2->content, SearchChar); //????????????????
int PlaceInt = Place - CurNode2->content; //?????(????????????????????????????)
if (PlaceInt < 0)
{
cout << "???????" << endl;
break;
}
cout << "???????????" << PlaceInt << endl;
break;
}
cout << "?????????????" << endl;
break;
case 'r': //Repalce A SubString In Current Line
if (CurNode2)
{
cout << "??????" << endl;
PrintNode(CurNode2);
cout << "???????????????";
char ToReplaceChar[char_num] = {0};
fgets(ToReplaceChar, char_num - 1, stdin);
if (ToReplaceChar[strlen(ToReplaceChar) - 1] == '\n')
ToReplaceChar[strlen(ToReplaceChar) - 1] = 0;
char *Place = strstr(CurNode2->content, ToReplaceChar);
int PlaceInt = Place - CurNode2->content;//???????????
if (PlaceInt < 0)
{
cout << "??????????" << endl;
break;
}
cout << "???????????";
char ReplaceChar[char_num] = {0};
fgets(ReplaceChar, char_num - 1, stdin);
if (ReplaceChar[strlen(ReplaceChar) - 1] == '\n')
ReplaceChar[strlen(ReplaceChar) - 1] = 0;
char FinalChar[char_num] = {0};//???????????
int FCCount = 0;//FinalChar????
for (int i = 0; i < strlen(CurNode2->content); i++)//?content?????????FinalChar
{
if (i == PlaceInt)//?????????
{
for (int j = 0; j < strlen(ReplaceChar); j++)//??????????
{
FinalChar[FCCount++] = ReplaceChar[j];
}
i += strlen(ToReplaceChar) - 1;//???i????????????(?????????)?????????
continue;
}
else
{
FinalChar[FCCount++] = CurNode2->content[i];
}
}
strcpy(CurNode2->content, FinalChar);//???FinalChar???content
break;
}
cout << "?????????????" << endl;
break;
case 't': //Show The Whole Line Number And Char Number(??"?")
cout << "????" << text1.LineCount << " ? \t"
<< "????(???)?" << text1.CharCount << endl;
break;
case 'c': //Save File(??"?")
fstream OutFile(OutFileName, fstream::out);
temp = text1.head;
while (temp->next)
{
temp = temp->next;
OutFile << temp->content;//?????????
if (temp->next != nullptr)//???????????????????
OutFile << "\n";
}
OutFile.close();
break;
}
}
cout << "==============ALL DONE=================";
}
void PrintNodes(Node *head)//???????????????????
{
if (head->next)
{
Node *CurNode = head->next;
cout << CurNode->LineNum << " |";//???????????
if (CurNode->content[0])//???????????????'\0',?????????????????????????;??if?????????????if
{
cout << CurNode->content;
}
cout << endl;
while (CurNode->next) //???????????
{
CurNode = CurNode->next;
cout << CurNode->LineNum << " |" << CurNode->content << endl;
}
}
}
void PrintNode(Node *Line)//?????????
{
cout << Line->LineNum << " |";
if (Line->content[0])
{
cout << Line->content;
}
cout << endl;
}
Node *GoTo(int GoNum, TextArea &TA)//????????,?????????TextArea???,????head???;???????????
{
if (TA.head->next)
{
Node *CurNode = TA.head->next;
if (CurNode->LineNum == GoNum)//????????
{
return CurNode;
}
while (CurNode->next)//??????????
{
CurNode = CurNode->next;
if (CurNode->LineNum == GoNum)
{
return CurNode;
}
}
}
return nullptr; //?????????,?????????????????,????????,???
//????,?????????,?????????????????1????????????????????????????????
}
void DelNode(int DelNum, TextArea &TA)//?????
{
if (DelNum < 1 || DelNum > TA.LineCount)//?????,????????????????
{
cout << "??????" << endl;
return;
}
Node *CurNode = GoTo(DelNum, TA);//?????????????
if (CurNode->next)//????????next
{
if (CurNode->priv)//???????priv,??????????
{
CurNode->priv->next = CurNode->next;
CurNode->next->priv = CurNode->priv;//????????????
Node *Temp = CurNode;
while (CurNode->next)//???????????
{
CurNode = CurNode->next;
CurNode->LineNum--;
}
delete Temp;
TA.LineCount--;//?????
cout << "?????" << endl;
return;
}
else//??priv?????????
{
TA.head->next = CurNode->next;//????????????????next
CurNode->next->priv = nullptr;//??????(????????????)?priv??
TA.first = CurNode->next;//?????????????
Node *Temp = CurNode;
while (CurNode->next)//????
{
CurNode = CurNode->next;
CurNode->LineNum--;
}
delete Temp;
TA.LineCount--;//?????
cout << "?????" << endl;
return;
}
}
else//???????next?????????
{
if (CurNode->priv)//????priv??????"???????????"
{
CurNode->priv->next = nullptr;//??????????next??
delete CurNode;
TA.LineCount--;//?????
cout << "?????" << endl;
return;
}
else//?????next???priv?????????????????
{
memset(CurNode->content, 0, char_num);//????????
cout << "?????" << endl;
return;
}
}
}