3 # (C) 1998, 2007 Free Software Foundation
4 # Originally by Alexandre Oliva <oliva@lsd.ic.unicamp.br>
6 # This gawk/shell script is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as published
8 # by the Free Software Foundation; either version 3, or (at your option)
11 # Given a preprocessed C/C++ code snippet, this script will replace any
12 # standard header files with an actual #include <...> directive.
16 # # 1 "/usr/include/stdio.h" 1 3
20 # main() { printf("Hello world!\n"); }
25 # main() { printf("Hello world!\n"); }
28 # Header files whose pathnames contain any of the following patterns
29 # are considered as standard headers: usr/include, g++-include,
30 # include/g++, include/c++/<version>, gcc-lib/<anything>/include.
32 gawk
${EXCLUDEPATT+-vexclude="$EXCLUDEPATT"} \
33 ${INCLUDEPATT+-vinclude="$INCLUDEPATT"} '
36 cppline = "^# [0-9]+ \"[^\"]*/(usr/include|g\\+\\+-include|include/g\\+\\+|include/c\\+\\+/[^/]+|gcc-lib/[^\"]+/include|gcc/include)/([^\"]+)\"( [1-4])*$"
38 !skipping && $0 ~ cppline &&
39 (exclude == "" || $3 !~ exclude) && (include == "" || $3 ~ include) {
41 printf "%s\n", "#include <" gensub(cppline, "\\2", "", $0) ">"
44 skipping && /^# [0-9]+ / && $3 == lastincluded {
48 !skipping && /^# [0-9]+ / {