X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=tools%2Fcpkg2c.mll;fp=tools%2Fcpkg2c.mll;h=8b3105d9a5fb0ae63cff8f85202c846c0de7b9c7;hp=835519987821e3f4999c193a2c47724359e4bc5d;hb=20392fc3c433909de76c676c235524acd96bec60;hpb=16534e98723674fa391e3fc29d2a07ce419c13dd diff --git a/tools/cpkg2c.mll b/tools/cpkg2c.mll index 8355199..8b3105d 100644 --- a/tools/cpkg2c.mll +++ b/tools/cpkg2c.mll @@ -31,6 +31,14 @@ let put_line = printf "#line %d \"%s\"\n" + let isspace = function |' '|'\t' -> true | _ -> false + + let strip s = + let l = ref 0 and r = ref (String.length s) in + while (isspace s.[!l] && !l < !r) do incr l done; + while (isspace s.[!r - 1] && !l < !r) do decr r done; + String.sub s !l (!r - !l) + (* @types related {{{ *) type typedef = @@ -91,9 +99,9 @@ | [t] -> (false, type_find lpos fpos t) | _ -> assert false in - match s with + match strip s with | "void" -> [] - | s -> List.map aux (Str.split (Str.regexp "[ \t]+,[ \t]+") s) + | s -> List.map aux (Str.split (Str.regexp "[ \t]*,[ \t]*") s) let parse_args lpos fpos s = let aux t = @@ -102,9 +110,9 @@ | [t; n] -> ((false, type_find lpos fpos t), n) | _ -> assert false in - match s with + match strip s with | "void" -> [] - | s -> List.map aux (Str.split (Str.regexp "[ \t]+,[ \t]+") s) + | s -> List.map aux (Str.split (Str.regexp "[ \t]*,[ \t]*") s) (* }}} *) (* parsing helpers {{{ *)