[ragel-users] Re: Primitive lookahead question
Wincent Colaiuta
w... at wincent.com
Thu Sep 20 19:57:28 UTC 2007
El 20/9/2007, a las 21:30, Adrian Thurston escribió:
> Hi Wincent,
>
> I would suggesting using your first solution, then manually shorten
> the
> from_file by 2 characters. It's a simple solution which avoids more
> elaborate backtracking/scanning approaches.
>
> What does git produce if the from file contains " b/"?
Ah, excellent question... let's see...
$ mkdir test
$ cd test
$ git init
Initialized empty Git repository in .git/
$ mkdir "a b"
$ echo "content" > "a b/file"
$ git add "a b/file"
$ git commit -m "Initial content"
Created initial commit def76f9: Initial content
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 a b/file
$ echo "more content" >> "a b/file"
$ git diff
diff --git a/a b/file b/a b/file
index d95f3ad..86436d0 100644
--- a/a b/file
+++ b/a b/file
@@ -1 +1,2 @@
content
+more content
Geez... couldn't be worse, could it? I can barely parse it myself and
I'm not even an automata. Hehe.
I think that really makes this question about lookahead to be moot:
the simplest thing to do will be to just ignore everything from "diff
--git" up to the next newline, because the path information is
redundantly available further down anyway (in the lines starting with
"---" and "+++") where it is much less difficult to extract.
Thanks a lot for the help, Adrian. Your question has short-circuited
a painful side trip.
Cheers,
Wincent
More information about the ragel-users
mailing list