A PHP Error was encountered

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: 575
Function: getPaste

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/system/core/Exceptions.php:271)

Filename: view/rss.php

Line Number: 2

Backtrace:

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/themes/geocities/views/view/rss.php
Line: 2
Function: header

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/core/MY_Loader.php
Line: 173
Function: include

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/core/MY_Loader.php
Line: 43
Function: _ci_load

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 579
Function: view

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once

p'p'p'p'p'p'p'p'p - Stikked p'p'p'p'p'p'p'p'p - Stikked http://geopaste.scratchbook.ch/ en Re: p'p'p'p'p'p'p'p'p http://geopaste.scratchbook.ch/view/fef2cf63 Sun, 24 Nov 2019 12:46:01 +0100 Walloping Porcupine http://geopaste.scratchbook.ch/view/fef2cf63
  1. //本代码和所有注释由PYZ倾情编写
  2. #include <iostream>
  3. #include <cstring>
  4. #include <cstdlib>
  5. #include <fstream>
  6. #define char_num 1000 //一行的字符个数
  7. using namespace std;
  8. struct Node //节点,一个节点存一行的内容
  9. {
  10.         char content[char_num] = {0}; //一行的内容字符数组
  11.         int LineNum;//行号
  12.         Node *next = nullptr;//后以个节点
  13.         Node *priv = nullptr;//前一个节点
  14. };
  15. class TextArea //包装节点的类;相当于一个TextArea类的对象就保存若干行的文字;但本程序实际上只需要存入一个文件的文字,也可以不用包装起来
  16. {
  17. public:
  18.         int LineCount = 0;//总行数
  19.         int CharCount = 0;//总字符数
  20.         Node *last = nullptr; //最后一个节点,也即最后一行
  21.         Node *first = nullptr;//第一个节点,也即第一行
  22.         Node *head = nullptr; //头节点,其content为空,next指针指向第一个节点
  23.         TextArea() = default; //默认构造函数
  24. };
  25. void PrintNodes(Node *);//打印所有节点(此处为函数声明,定义在后面)
  26. void PrintNode(Node *);//打印单个节点
  27. void DelNode(int, TextArea &);//删除单个节点
  28. Node *GoTo(int, TextArea &); //跳转到特定一行
  29. int main()
  30. {
  31.         TextArea text1; //创建一个对象
  32.         text1.head = new Node; //创建一个头节点,它的next指向第一个节点,它不存放其他内容
  33.         text1.head->LineNum = -1;
  34.         char *InFileName = new char[100]; //存放输入文件名
  35.         char *OutFileName = new char[100]; //存放输出文件名
  36.         cout << "请输入欲输入的文件名(不能包含空格):";
  37.         cin >> InFileName;
  38.         cout << "请输入欲输出的文件名(不能包含空格):";
  39.         cin >> OutFileName;
  40.         fstream InFile; //创建fstream文件流对象
  41.         InFile.open(InFileName, fstream::in | fstream::out); //打开输入文件
  42.         if (!InFile.is_open())  //如果文件成功打开,则InFile.is_open()=1,此处判断是否未成功打开
  43.         {
  44.                 cout << "文件打开失败!是否要新建该文件?Y/N" << endl;
  45.                 char YN;
  46.                 cin >> YN;
  47.                 if (YN >= 'A' && YN <= 'Z')
  48.                 {
  49.                         YN += 'a' - 'A'; //大写转小写
  50.                 }
  51.                 if (YN == 'y')
  52.                 {
  53.                         InFile.open(InFileName, fstream::in | fstream::out | fstream::trunc); //创建文件
  54.                 }
  55.                 else
  56.                         exit(1); //非正常退出
  57.         }
  58.         Node *CurNode = new Node;
  59.         text1.head->next = CurNode;
  60.         if (!InFile.eof()) //如果文件没到末尾
  61.         {
  62.                 InFile.getline(CurNode->content, char_num - 1); //先读一行进来,因为文件至少得有一行(即使是空的)【我是这样认为的】
  63.                 text1.CharCount += strlen(CurNode->content);    //字符计数
  64.                 text1.LineCount++;      //行数计数
  65.                 CurNode->LineNum = text1.LineCount;     //存入行号
  66.         }
  67.         while (!InFile.eof()) //如果文件没到末尾,则一直循环一行一行读取
  68.         {
  69.                 Node *TempNode = CurNode;
  70.                 CurNode->next = new Node;
  71.                 CurNode = CurNode->next;
  72.                 CurNode->priv = TempNode; //创建新节点完毕
  73.                 text1.LineCount++;
  74.                 CurNode->LineNum = text1.LineCount;
  75.                 InFile.getline(CurNode->content, char_num - 1);//读一行内容并存入content(不含回车)
  76.                 text1.CharCount += strlen(CurNode->content);
  77.                 //写入新节点完毕
  78.         }
  79.         InFile.close();//关闭文件
  80.         text1.last = CurNode;   //存下最后一个节点的指针
  81.         text1.first = text1.head->next; //存下第一个节点的指针
  82.         char action;
  83.         Node *CurNode2 = nullptr; //当前操作的节点,现在还未开始,故为空
  84.         Node *temp = nullptr; //供之后可重复使用的temp节点
  85.         int CurLine = 0; //当前操作的行号,0行不存在
  86.         while (1)
  87.         {
  88.                 cout << "请输入动作(输入H 或 h以显示帮助 ) : ";
  89.                 cin >> action;
  90.                 getchar(); //吃掉回车,免得出问题
  91.                 if (action >= 'A' && action <= 'Z')
  92.                 {
  93.                         action += 'a' - 'A'; //大写转小写
  94.                 }
  95.                 switch (action)
  96.                 {
  97.                 case 'h': //Help
  98.                         cout << "以下是操作列表(不区分大小写)" << endl;
  99.                         cout << "V:查看整个文件内容" << endl;
  100.                         cout << "F:转到第一行" << endl;
  101.                         cout << "L:转到最后一行" << endl;
  102.                         cout << "N:转到下一行" << endl;
  103.                         cout << "P:转到上一行" << endl;
  104.                         cout << "G:转到特定的某行" << endl;
  105.                         cout << "D:删除特定某行" << endl;
  106.                         cout << "O:覆盖当前行内容" << endl;
  107.                         cout << "S:在当前行查找子串" << endl;
  108.                         cout << "R:在当前行替换子串" << endl;
  109.                         cout << "T:显示统计信息" << endl;
  110.                         cout << "C:保存文件" << endl;
  111.                         cout << "E:退出编辑器" << endl;
  112.                         break;
  113.                 case 'v': //View The Whole File
  114.                         PrintNodes(text1.head);
  115.                         break;
  116.                 case 'g': //Goto A Line
  117.                         int GoNum;
  118.                         cout << "请输入要跳转的行数:";
  119.                         if (!(cin >> GoNum))
  120.                         {
  121.                                 cout << "输入错误!" << endl;
  122.                                 break;
  123.                         }
  124.                         temp = GoTo(GoNum, text1);
  125.                         if (temp == nullptr)
  126.                         {
  127.                                 cout << "没有这一行" << endl;
  128.                                 break;
  129.                         }
  130.                         CurNode2 = temp;
  131.                         CurLine = CurNode2->LineNum;
  132.                         PrintNode(CurNode2);
  133.                         temp = nullptr; //temp用完后重新置空
  134.                         break;
  135.                 case 'e': //Exit
  136.                         exit(0);
  137.                         break;
  138.                 case 'f': //Go To First Line
  139.                         CurLine = 1;
  140.                         CurNode2 = GoTo(1, text1);
  141.                         PrintNode(GoTo(1, text1));
  142.                         break;
  143.                 case 'l': //Go To Last Line
  144.                         CurLine = text1.LineCount;
  145.                         CurNode2 = GoTo(text1.LineCount, text1);
  146.                         PrintNode(CurNode2);
  147.                         break;
  148.                 case 'n': //Go To Next Line
  149.                         if (CurLine == 0)//因为行号是从第一行开始,所以第一次要单独判断一下,因为此时CurNode2=nullptr,没办法用
  150.                         {
  151.                                 CurLine = 1;
  152.                                 CurNode2 = GoTo(1, text1);
  153.                                 PrintNode(GoTo(1, text1));
  154.                                 break;
  155.                         }
  156.                         if (CurLine == text1.LineCount)
  157.                         {
  158.                                 cout << "已是最后一行!" << endl;
  159.                                 break;
  160.                         }
  161.                         CurLine++;
  162.                         CurNode2 = CurNode2->next;
  163.                         PrintNode(CurNode2);
  164.                         break;
  165.                 case 'p': //Go To Previous Line
  166.                         if (CurLine == 1 || CurLine == 0)
  167.                         {
  168.                                 cout << "已是第一行!" << endl;
  169.                                 break;
  170.                         }
  171.                         CurLine--;
  172.                         CurNode2 = CurNode2->priv;
  173.                         PrintNode(CurNode2);
  174.                         break;
  175.                 case 'd': //Delete A Line
  176.                         int DelNum;
  177.                         cout << "请输入要删除的行号:";
  178.                         cin >> DelNum;
  179.                         if (DelNum < CurLine) //要删除的行在当前行之前(如果要删除的在当前行之后,那么无需特别动作,只需执行删除操作即可
  180.                         {
  181.                                 CurLine--;//当前行号需要减一,但当然行指针不变,依旧指向当前行
  182.                         }
  183.                         else if (DelNum == CurLine) //要删除的行跟当前行相同
  184.                         {
  185.                                 if (CurNode2->next) //如果Curnode2有next,那么就指向它;也即是当前行指针指向被删除行的下一行
  186.                                 {
  187.                                         CurNode2 = CurNode2->next;
  188.                                 }
  189.                                 else //如果CurNode2没有next(也即它是最后一行)
  190.                                 {
  191.                                         if (CurNode2->priv) //有priv
  192.                                         {
  193.                                                 CurLine--;
  194.                                                 CurNode2 = CurNode2->priv;
  195.                                         }
  196.                                         else //没有next,也没有priv,证明它是第一行
  197.                                         {
  198.                                                 //CurLine和CurNode2不变
  199.                                         }
  200.                                 }
  201.                         }
  202.                         DelNode(DelNum, text1);//调用删除函数进行进一步操作
  203.                         break;
  204.                 case 'i': //Insert A Line After Current Line
  205.                         if (CurNode2) //CurNode2!=nullptr;也即此刻不是第0行
  206.                         {
  207.                                 temp = CurNode2;
  208.                                 while (temp->next) //把当前行之后的所有行的行号都加一(小技巧,一般这种形式的while循环,我就读作while(temp有next))
  209.                                 {
  210.                                         temp = temp->next;
  211.                                         temp->LineNum++;
  212.                                 }
  213.                                 temp = new Node;
  214.                                 temp->LineNum = CurLine + 1; //插入的新行的行号为当前行号加一
  215.                                 if (CurNode2->next)
  216.                                 {
  217.                                         temp->priv = CurNode2;
  218.                                         temp->next = CurNode2->next;
  219.                                         CurNode2->next->priv = temp;
  220.                                         CurNode2->next = temp;
  221.                                 }
  222.                                 else //CurNode2无next,即为最后一行,那么新插入的行成为最后一行
  223.                                 {
  224.                                         CurNode2->next = temp;
  225.                                         temp->priv = CurNode2;
  226.                                         temp->next = nullptr;//最后一行没有下一行
  227.                                 }
  228.                                 text1.LineCount++; //总行数加一
  229.                                 cout << "请键入增加行的内容:";
  230.                                 fgets(temp->content, char_num - 1, stdin);
  231.                                 if (temp->content[strlen(temp->content) - 1] == '\n') //fgets会连同空格和回车一起存进content,但我们不要回车,故用此法去掉回车
  232.                                         temp->content[strlen(temp->content) - 1] = 0;
  233.                                 CurLine++;
  234.                                 CurNode2 = temp; //当前行指针指向新插入的行
  235.                                 cout << "插入成功!" << endl;
  236.                                 temp = nullptr;
  237.                                 break;
  238.                         }
  239.                         cout << "错误,目前未处于任何一行!" << endl;//进入这行语句,证明CurNode2为空
  240.                         break;
  241.                 case 'o': //Override Current Line
  242.                         if (CurNode2)
  243.                         {
  244.                                 memset(CurNode2->content, 0, char_num);//清空本行原有内容
  245.                                 cout << "请输入想要将本行替换为的内容:";
  246.                                 fgets(CurNode2->content, char_num - 1, stdin);
  247.                                 if (CurNode2->content[strlen(CurNode2->content) - 1] == '\n')
  248.                                         CurNode2->content[strlen(CurNode2->content) - 1] = 0;
  249.                                 cout << "替换成功!" << endl;
  250.                                 break;
  251.                         }
  252.                         cout << "错误,目前未处于任何一行!" << endl;
  253.                         break;
  254.                 case 's': //Search For A SubString In Current Line
  255.                         if (CurNode2)
  256.                         {
  257.                                 cout << "当前行内容:" << endl;
  258.                                 PrintNode(CurNode2);//先打印一下本行内容
  259.                                 cout << "请输入想要在本行查找的内容:";
  260.                                 char SearchChar[char_num] = {0};//存想要找的子串
  261.                                 fgets(SearchChar, char_num - 1, stdin);//输入想要找的子串
  262.                                 if (SearchChar[strlen(SearchChar) - 1] == '\n')//去除回车
  263.                                         SearchChar[strlen(SearchChar) - 1] = 0;
  264.                                 char *Place = strstr(CurNode2->content, SearchChar); //返回子串第一次出现位置的内存地址
  265.                                 int PlaceInt = Place - CurNode2->content; //转换成下标(数组名就是数组第一个元素的首地址,这样相当于算出来偏移量)
  266.                                 if (PlaceInt < 0)
  267.                                 {
  268.                                         cout << "未找到该子串!" << endl;
  269.                                         break;
  270.                                 }
  271.                                 cout << "子串第一次出现位置为:" << PlaceInt << endl;
  272.                                 break;
  273.                         }
  274.                         cout << "错误,目前未处于任何一行!" << endl;
  275.                         break;
  276.                 case 'r': //Repalce A SubString In Current Line
  277.                         if (CurNode2)
  278.                         {
  279.                                 cout << "当前行内容:" << endl;
  280.                                 PrintNode(CurNode2);
  281.                                 cout << "请输入想要在本行要替换的内容:";
  282.                                 char ToReplaceChar[char_num] = {0};
  283.                                 fgets(ToReplaceChar, char_num - 1, stdin);
  284.                                 if (ToReplaceChar[strlen(ToReplaceChar) - 1] == '\n')
  285.                                         ToReplaceChar[strlen(ToReplaceChar) - 1] = 0;
  286.                                 char *Place = strstr(CurNode2->content, ToReplaceChar);
  287.                                 int PlaceInt = Place - CurNode2->content;//首先先查找要替换的内容
  288.                                 if (PlaceInt < 0)
  289.                                 {
  290.                                         cout << "未找到要替换的内容!" << endl;
  291.                                         break;
  292.                                 }
  293.                                 cout << "请输入,将目标替换成:";
  294.                                 char ReplaceChar[char_num] = {0};
  295.                                 fgets(ReplaceChar, char_num - 1, stdin);
  296.                                 if (ReplaceChar[strlen(ReplaceChar) - 1] == '\n')
  297.                                         ReplaceChar[strlen(ReplaceChar) - 1] = 0;
  298.                                 char FinalChar[char_num] = {0};//存替换完之后整行的内容
  299.                                 int FCCount = 0;//FinalChar的计数器
  300.                                 for (int i = 0; i < strlen(CurNode2->content); i++)//将content的内容一个一个赋给FinalChar
  301.                                 {
  302.                                         if (i == PlaceInt)//当到了要替换的位置
  303.                                         {
  304.                                                 for (int j = 0; j < strlen(ReplaceChar); j++)//转而赋值替换后的字符
  305.                                                 {
  306.                                                         FinalChar[FCCount++] = ReplaceChar[j];
  307.                                                 }
  308.                                                 i += strlen(ToReplaceChar) - 1;//然后把i的值加上被替换子串的长度(由于是下标,故减一),实现跳过这个子串
  309.                                                 continue;
  310.                                         }
  311.                                         else
  312.                                         {
  313.                                                 FinalChar[FCCount++] = CurNode2->content[i];
  314.                                         }
  315.                                 }
  316.                                 strcpy(CurNode2->content, FinalChar);//最后把FinalChar复制给content
  317.                                 break;
  318.                         }
  319.                         cout << "错误,目前未处于任何一行!" << endl;
  320.                         break;
  321.                 case 't': //Show The Whole Line Number And Char Number(拼音"统")
  322.                         cout << "总行数:" << text1.LineCount << " 行 \t"
  323.                                  << "总字符数(含空格):" << text1.CharCount << endl;
  324.                         break;
  325.                 case 'c': //Save File(拼音"存")
  326.                         fstream OutFile(OutFileName, fstream::out);
  327.                         temp = text1.head;
  328.                         while (temp->next)
  329.                         {
  330.                                 temp = temp->next;
  331.                                 OutFile << temp->content;//一行一行地写入文件
  332.                                 if (temp->next != nullptr)//如果不是最后一行,那么就在行末加个回车
  333.                                         OutFile << "\n";
  334.                         }
  335.                         OutFile.close();
  336.                         break;
  337.                 }
  338.         }
  339.         cout << "==============ALL DONE=================";
  340. }
  341. void PrintNodes(Node *head)//打印所有节点,需要传入一个头节点的指针
  342. {
  343.         if (head->next)
  344.         {
  345.                 Node *CurNode = head->next;
  346.                 cout << CurNode->LineNum << " |";//先打印行号,再打印内容
  347.                 if (CurNode->content[0])//判断一下内容的第一个字符是不是'\0',即空字符,如果是,则说明此行内容为空,输出一个空行;此处if判断如果不是空字符,则进入if
  348.                 {
  349.                         cout << CurNode->content;
  350.                 }
  351.                 cout << endl;
  352.                 while (CurNode->next) //循环打印剩下的所有节点
  353.                 {
  354.                         CurNode = CurNode->next;
  355.                         cout << CurNode->LineNum << " |" << CurNode->content << endl;
  356.                 }
  357.         }
  358. }
  359. void PrintNode(Node *Line)//传入单个节点并打印
  360. {
  361.         cout << Line->LineNum << " |";
  362.         if (Line->content[0])
  363.         {
  364.                 cout << Line->content;
  365.         }
  366.         cout << endl;
  367. }
  368. Node *GoTo(int GoNum, TextArea &TA)//跳转到特定的一行,传入要跳转的行号和TextArea的引用,用于调用head等成员;返回要跳转到的行的指针
  369. {
  370.         if (TA.head->next)
  371.         {
  372.                 Node *CurNode = TA.head->next;
  373.                 if (CurNode->LineNum == GoNum)//判断行号是否匹配
  374.                 {
  375.                         return CurNode;
  376.                 }
  377.                 while (CurNode->next)//遍历判断行号是否匹配
  378.                 {
  379.                         CurNode = CurNode->next;
  380.                         if (CurNode->LineNum == GoNum)
  381.                         {
  382.                                 return CurNode;
  383.                         }
  384.                 }
  385.         }
  386.         return nullptr; //如果程序执行到此处,则证明以上步骤都没有匹配到对应的行,说明不存在这一行,返回空
  387.         //写到这里,我觉得自己是个傻子,为什么不直接先判断一下行号是否小于1或者大于最后一行的行号呢?这样就能直接判断出要跳转的行存不存在了
  388. }
  389. void DelNode(int DelNum, TextArea &TA)//删除特定行
  390. {
  391.         if (DelNum < 1 || DelNum > TA.LineCount)//这里学乖了,先判断一下要删除的行是不在范围内
  392.         {
  393.                 cout << "没有这一行!" << endl;
  394.                 return;
  395.         }
  396.         Node *CurNode = GoTo(DelNum, TA);//存在则先跳转到要删除的那行
  397.         if (CurNode->next)//如果要删除的行有next
  398.         {
  399.                 if (CurNode->priv)//如果它同时还有priv,则证明它处于两行中间
  400.                 {
  401.                         CurNode->priv->next = CurNode->next;
  402.                         CurNode->next->priv = CurNode->priv;//移动它上下两行内部的指针
  403.                         Node *Temp = CurNode;
  404.                         while (CurNode->next)//把它后面行的行号都减一
  405.                         {
  406.                                 CurNode = CurNode->next;
  407.                                 CurNode->LineNum--;
  408.                         }
  409.                         delete Temp;
  410.                         TA.LineCount--;//总行数减一
  411.                         cout << "删除成功!" << endl;
  412.                         return;
  413.                 }
  414.                 else//没有priv,则说明它是第一行
  415.                 {
  416.                         TA.head->next = CurNode->next;//要删除第一行,就得先移动头节点的next
  417.                         CurNode->next->priv = nullptr;//把它的下一行(它的下一行即将成为第一行)的priv置空
  418.                         TA.first = CurNode->next;//第一行的指针指向新的第一行
  419.                         Node *Temp = CurNode;
  420.                         while (CurNode->next)//行号减一
  421.                         {
  422.                                 CurNode = CurNode->next;
  423.                                 CurNode->LineNum--;
  424.                         }
  425.                         delete Temp;
  426.                         TA.LineCount--;//总行数减一
  427.                         cout << "删除成功!" << endl;
  428.                         return;
  429.                 }
  430.         }
  431.         else//要删除的行没有next,证明它是最后一行
  432.         {
  433.                 if (CurNode->priv)//如果它有priv,证明它不是"既是最后一行又是第一行"
  434.                 {
  435.                         CurNode->priv->next = nullptr;//只需要把它的前一行的next置空
  436.                         delete CurNode;
  437.                         TA.LineCount--;//总行数减一
  438.                         cout << "删除成功!" << endl;
  439.                         return;
  440.                 }
  441.                 else//此处既没有next也没有priv,那它就是唯一的一行,所以不能删掉
  442.                 {
  443.                         memset(CurNode->content, 0, char_num);//只需清空内容即可
  444.                         cout << "删除成功!" << endl;
  445.                         return;
  446.                 }
  447.         }
  448. }
]]>