forked from coq/coq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add small deprecate_file script in dev/tools
- Loading branch information
1 parent
8d0d361
commit 78677b8
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/sh | ||
usage() | ||
{ | ||
cat 1>&2 <<EOF | ||
Usage: $0 FILE VERSION NOTE | ||
Write deprecation attributes in a Coq source file for all commands that | ||
support it. | ||
Example: $0 Heap.v 8.3 "Use mergesort.v" | ||
EOF | ||
} | ||
|
||
case $# in | ||
3) ;; | ||
*) usage; exit 1 | ||
esac | ||
|
||
file=$1 | ||
vers=$2 | ||
note=$3 | ||
|
||
if ! [ -f "$file" ]; then | ||
printf '%s: %s: No such file\n' "$0" "$file" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
attr="((Local|Global|Program|Canonical)[[:space:]]+)" | ||
|
||
deprable="Theorem|Lemma|Fact|Corollary|Proposition|Property|\ | ||
Definition|Example|Fixpoint|\ | ||
Instance|Axiom|Parameter|Notation|Coercion" | ||
|
||
annot="#[deprecated(since=\"$vers\", note=\"$note\")]" | ||
|
||
tmp="$file".depr | ||
|
||
sed -E "s/(^[[:space:]]*)(($attr)*($deprable).*\$)/\\1$annot\\n\\1\\2/" \ | ||
"$file" >"$tmp" | ||
mv "$tmp" "$file" |