From 64d042cb08cd724baa3f60889436d9e0e0a69263 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 19 Aug 2009 14:30:02 +0200 Subject: [PATCH] avoid build failure due to Haskell keyword clash * src/generator.ml: Fix this particular problem by renaming the "module" parameter to "modulename". Avoid the general problem by ensuring that no parameter name is in the set of nearly all Haskell, OCaml and C reserved words. (zfile): Adjust one more offender: s/method/meth/. --- src/generator.ml | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/generator.ml b/src/generator.ml index 230be80..7b5b9d0 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -2968,7 +2968,7 @@ were rarely if ever used anyway. See also C and the L manpage."); - ("zfile", (RString "description", [String "method"; Pathname "path"]), 140, [DeprecatedBy "file"], + ("zfile", (RString "description", [String "meth"; Pathname "path"]), 140, [DeprecatedBy "file"], [], "determine file type inside a compressed file", "\ @@ -3560,7 +3560,7 @@ an external journal on the journal with UUID C. See also C."); - ("modprobe", (RErr, [String "module"]), 194, [], + ("modprobe", (RErr, [String "modulename"]), 194, [], [InitNone, Always, TestRun [["modprobe"; "ext2"]]], "load a kernel module", "\ @@ -4050,7 +4050,36 @@ let check_functions () = if n = "i" || n = "n" then failwithf "%s has a param/ret called 'i' or 'n', which will cause some conflicts in the generated code" name; if n = "argv" || n = "args" then - failwithf "%s has a param/ret called 'argv' or 'args', which will cause some conflicts in the generated code" name + failwithf "%s has a param/ret called 'argv' or 'args', which will cause some conflicts in the generated code" name; + + (* List Haskell, OCaml and C keywords here. + * http://www.haskell.org/haskellwiki/Keywords + * http://caml.inria.fr/pub/docs/manual-ocaml/lex.html#operator-char + * http://en.wikipedia.org/wiki/C_syntax#Reserved_keywords + * Formatted via: cat c haskell ocaml|sort -u|grep -vE '_|^val$' \ + * |perl -pe 's/(.+)/"$1";/'|fmt -70 + * Omitting _-containing words, since they're handled above. + * Omitting the OCaml reserved word, "val", is ok, + * and saves us from renaming several parameters. + *) + let reserved = [ + "and"; "as"; "asr"; "assert"; "auto"; "begin"; "break"; "case"; + "char"; "class"; "const"; "constraint"; "continue"; "data"; + "default"; "deriving"; "do"; "done"; "double"; "downto"; "else"; + "end"; "enum"; "exception"; "extern"; "external"; "false"; "float"; + "for"; "forall"; "foreign"; "fun"; "function"; "functor"; "goto"; + "hiding"; "if"; "import"; "in"; "include"; "infix"; "infixl"; + "infixr"; "inherit"; "initializer"; "inline"; "instance"; "int"; + "land"; "lazy"; "let"; "long"; "lor"; "lsl"; "lsr"; "lxor"; + "match"; "mdo"; "method"; "mod"; "module"; "mutable"; "new"; + "newtype"; "object"; "of"; "open"; "or"; "private"; "qualified"; + "rec"; "register"; "restrict"; "return"; "short"; "sig"; "signed"; + "sizeof"; "static"; "struct"; "switch"; "then"; "to"; "true"; "try"; + "type"; "typedef"; "union"; "unsigned"; "virtual"; "void"; + "volatile"; "when"; "where"; "while"; + ] in + if List.mem n reserved then + failwithf "%s has param/ret using reserved word %s" name n; in (match fst style with -- 1.8.3.1