summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrien Nader <adrien@notk.org>2015-02-08 18:10:32 +0100
committerAdrien Nader <adrien@notk.org>2015-02-08 18:10:32 +0100
commita5c4cb232c626346fa5fec957948869c1ee56753 (patch)
tree0a936fa826aeb054cf91a117b4c5c326baf96d5e
parentb457ca398a68d05ef69e0e03b4f82b6d7d84f38d (diff)
ocamldoc/Makefile: replace remove_DEBUG script with a single awk invocation
Awk? The horror! Except standard awk has more features than standard sed and standard grep combined. This commit has been motivated by the difference between the .nt version of ocamldoc/Makefile: it is a mere "grep -v DEBUG" which does not preserve line information. It doesn't touch Makefile.nt since a subsequent commit is going to remove the Makefile.nt file completely (yay!). However it takes windows into account and removes one shell invocation (maybe one day OCaml will build without a posix shell, at least this commit goes into that direction).
-rw-r--r--ocamldoc/Makefile5
-rwxr-xr-xocamldoc/remove_DEBUG20
2 files changed, 4 insertions, 21 deletions
diff --git a/ocamldoc/Makefile b/ocamldoc/Makefile
index b1466818b..409142307 100644
--- a/ocamldoc/Makefile
+++ b/ocamldoc/Makefile
@@ -24,7 +24,10 @@ OCAMLYACC = $(ROOTDIR)/yacc/ocamlyacc
OCAMLLIB = $(LIBDIR)
OCAMLBIN = $(BINDIR)
-OCAMLPP=-pp './remove_DEBUG'
+# Pre-processor to strip lines with 'DEBUG', replacing them with lines
+# containing only a comment. Also adds a leading "#1 $1" line. The whole thing
+# should respect the cpp # lines annotation conventions.
+OCAMLPP=-pp "awk 'BEGIN { printf(\"# 1 %s\n\", ARGV[1]); } /DEBUG/ { printf(\"(* DEBUG statement removed *)\n\"); } !/DEBUG/ { print $$0; }'"
# For installation
##############
diff --git a/ocamldoc/remove_DEBUG b/ocamldoc/remove_DEBUG
deleted file mode 100755
index bca6ba049..000000000
--- a/ocamldoc/remove_DEBUG
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-
-#(***********************************************************************)
-#(* OCamldoc *)
-#(* *)
-#(* Damien Doligez, projet Moscova, INRIA Rocquencourt *)
-#(* *)
-#(* Copyright 2003 Institut National de Recherche en Informatique et *)
-#(* en Automatique. All rights reserved. This file is distributed *)
-#(* under the terms of the Q Public License version 1.0. *)
-#(* *)
-#(***********************************************************************)
-
-# usage: remove_DEBUG <file>
-# remove from <file> every line that contains the string "DEBUG",
-# respecting the cpp # line annotation conventions
-
-echo "# 1 \"$1\""
-LC_ALL=C sed -e '/DEBUG/c\
-(* DEBUG statement removed *)' "$1"