00001
00008
00009
00010 #include "NMETest.h"
00011
00020 static NMEErr encodeURLFunNull(NMEConstText link, NMEInt linkLen,
00021 NMEContext *context, void *data)
00022 {
00023 return kNMEErrOk;
00024 }
00025
00036 static NMEErr encodeCharFunNull(NMEConstText src, NMEInt srcLen, NMEInt *srcIx,
00037 NMEContext *context,
00038 void *data)
00039 {
00040 (*srcIx)++;
00041 return kNMEErrOk;
00042 }
00043
00044 NMEOutputFormat const NMEOutputFormatTest =
00045 {
00046 "",
00047 0,
00048 10,
00049 '%',
00050 "+;%{L}\n", "-;%{L}\n",
00051 10,
00052 "+%%{l} %%H %{l} %{i};%{L}\n", "-%%{l} %%H %{l} %{i};%{L}\n",
00053 "+ par;%{L}\n", "- par;%{L}\n",
00054 "",
00055 "+ pre;%{L}\n", "- pre;%{L}\n",
00056 "+ preline;%{L}\n", "- preline;%{L}\n",
00057 FALSE,
00058 "+%%{l} %%U %{l};%{L}\n", "-%%{l} %%U %{l};%{L}\n",
00059 "+%%{l} %%u %{l} %{i};%{L}\n", "-%%{l} %%u %{l} %{i};%{L}\n",
00060 "+%%{l} %%O %{l};%{L}\n", "-%%{l} %%O %{l};%{L}\n",
00061 "+%%{l} %%o %{l} %{i};%{L}\n", "-%%{l} %%o %{l} %{i};%{L}\n",
00062 "+%%{l} %%D %{l};%{L}\n", "-%%{l} %%D %{l};%{L}\n",
00063 "+%%{l} %%t %{l} %{i};%{L}\n", "-%%{l} %%t %{l} %{i};%{L}\n",
00064 "",
00065 "+%%{l} %%d %{l} %{i};%{L}\n", "-%%{l} %%d %{l} %{i};%{L}\n",
00066 "+%%{l} %%I %{l};%{L}\n", "-%%{l} %%I %{l};%{L}\n",
00067 "+%%{l} %%i %{l} %{i};%{L}\n", "-%%{l} %%i %{l} %{i};%{L}\n",
00068 "+ T;%{L}\n", "- T;%{L}\n",
00069 "+ t;%{L}\n", "- t;%{L}\n",
00070 "+ th;%{L}\n", "- th;%{L}\n",
00071 "+ td;%{L}\n", "- td;%{L}\n",
00072 "",
00073 "+*;%{L}\n", "-*;%{L}\n",
00074 "+/;%{L}\n", "-/;%{L}\n",
00075 "+_;%{L}\n", "-_;%{L}\n",
00076 "+^;%{L}\n", "-^;%{L}\n",
00077 "+,;%{L}\n", "-,;%{L}\n",
00078 "+#;%{L}\n", "-#;%{L}\n",
00079 "+a;%{L}\n", "", "-a;%{L}\n", FALSE,
00080 "+i;%{L}\n", "", "-i;%{L}\n", FALSE, TRUE,
00081 NULL,
00082 encodeURLFunNull, NULL,
00083 encodeCharFunNull, NULL,
00084 encodeCharFunNull, NULL,
00085 -1, NULL, NULL,
00086 NULL, NULL,
00087 NULL, NULL, NULL, NULL,
00088 NULL,
00089 NULL,
00090 NULL, NULL
00091 };
00092
00093 NMEErr NMETest(NMEConstText output, NMEInt outputLength, NMEInt *lineNumber)
00094 {
00095
00096
00097
00098
00099 NMEInt currentLine;
00100 NMEInt i;
00101
00102 #define kMaxDepth 32
00103
00104
00105 NMEInt startOffset[kMaxDepth];
00106 NMEInt depth;
00107
00108 for (currentLine = 0, depth = 0; currentLine < outputLength; )
00109 {
00110 if (output[currentLine] == '-')
00111 {
00112 if (depth < 0)
00113 return kNMEErrSuperfluousEndTag;
00114 currentLine++;
00115 for (i = 0;
00116 currentLine + i < outputLength
00117 && output[currentLine + i] != '\n' && output[currentLine + i] != ';';
00118 i++)
00119 if (output[currentLine + i] != output[startOffset[depth - 1] + i])
00120 return kNMEErrBadNesting;
00121 if (output[startOffset[depth - 1] + i] != output[currentLine + i])
00122 return kNMEErrBadNesting;
00123 currentLine += i;
00124 depth--;
00125 }
00126 else
00127 {
00128 if (depth >= kMaxDepth)
00129 return kNMEErrInternal;
00130 startOffset[depth++] = currentLine + 1;
00131
00132 while (currentLine < outputLength
00133 && output[currentLine] != '\n' && output[currentLine] != ';')
00134 currentLine++;
00135 }
00136
00137
00138 for (*lineNumber = 0;
00139 currentLine < outputLength && output[currentLine] != '\n';
00140 currentLine++)
00141 if (output[currentLine] >= '0' && output[currentLine] <= '9')
00142 *lineNumber = 10 * *lineNumber + output[currentLine] - '0';
00143 if (currentLine < outputLength && output[currentLine] == '\n')
00144 currentLine++;
00145 }
00146
00147 if (depth > 0)
00148 return kNMEErrMissingEndTag;
00149 else
00150 return kNMEErrOk;
00151 }