Detab source code.

This commit is contained in:
Lukhnos Liu 2012-10-31 22:12:50 -07:00
parent e68845381c
commit c300e9cc10
1 changed files with 32 additions and 33 deletions

View File

@ -53,24 +53,23 @@ bool FastLM::open(const char *path)
return false; return false;
} }
fd = ::open(path, O_RDONLY); fd = ::open(path, O_RDONLY);
if (fd == -1) { if (fd == -1) {
return false; return false;
} }
struct stat sb; struct stat sb;
if (fstat(fd, &sb) == -1) { if (fstat(fd, &sb) == -1) {
return false; return false;
} }
length = (size_t)sb.st_size; length = (size_t)sb.st_size;
data = mmap(NULL, length, PROT_WRITE, MAP_PRIVATE, fd, 0); data = mmap(NULL, length, PROT_WRITE, MAP_PRIVATE, fd, 0);
if (!data) { if (!data) {
::close(fd); ::close(fd);
return false; return false;
} }
// Regular expression for parsing: // Regular expression for parsing:
// (\n*\w\w*\s\w\w*\s\w\w*)*$ // (\n*\w\w*\s\w\w*\s\w\w*)*$
@ -78,34 +77,34 @@ bool FastLM::open(const char *path)
// Expanded as DFA (in Graphviz): // Expanded as DFA (in Graphviz):
// //
// digraph finite_state_machine { // digraph finite_state_machine {
// rankdir = LR; // rankdir = LR;
// size = "10"; // size = "10";
// //
// node [shape = doublecircle]; End; // node [shape = doublecircle]; End;
// node [shape = circle]; // node [shape = circle];
// //
// Start -> End [ label = "EOF"]; // Start -> End [ label = "EOF"];
// Start -> Error [ label = "\\s" ]; // Start -> Error [ label = "\\s" ];
// Start -> Start [ label = "\\n" ]; // Start -> Start [ label = "\\n" ];
// Start -> 1 [ label = "\\w" ]; // Start -> 1 [ label = "\\w" ];
// //
// 1 -> Error [ label = "\\n, EOF" ]; // 1 -> Error [ label = "\\n, EOF" ];
// 1 -> 2 [ label = "\\s" ]; // 1 -> 2 [ label = "\\s" ];
// 1 -> 1 [ label = "\\w" ]; // 1 -> 1 [ label = "\\w" ];
// //
// 2 -> Error [ label = "\\n, \\s, EOF" ]; // 2 -> Error [ label = "\\n, \\s, EOF" ];
// 2 -> 3 [ label = "\\w" ]; // 2 -> 3 [ label = "\\w" ];
// //
// 3 -> Error [ label = "\\n, EOF "]; // 3 -> Error [ label = "\\n, EOF "];
// 3 -> 4 [ label = "\\s" ]; // 3 -> 4 [ label = "\\s" ];
// 3 -> 3 [ label = "\\w" ]; // 3 -> 3 [ label = "\\w" ];
// //
// 4 -> Error [ label = "\\n, \\s, EOF" ]; // 4 -> Error [ label = "\\n, \\s, EOF" ];
// 4 -> 5 [ label = "\\w" ]; // 4 -> 5 [ label = "\\w" ];
// //
// 5 -> Error [ label = "\\s, EOF" ]; // 5 -> Error [ label = "\\s, EOF" ];
// 5 -> Start [ label = "\\n" ]; // 5 -> Start [ label = "\\n" ];
// 5 -> 5 [ label = "\\w" ]; // 5 -> 5 [ label = "\\w" ];
// } // }
char *head = (char *)data; char *head = (char *)data;