summaryrefslogtreecommitdiffstats
path: root/vidix
diff options
context:
space:
mode:
authordiego <diego@b3059339-0415-0410-9bf9-f77b7e298cf2>2009-12-20 17:01:47 +0000
committerdiego <diego@b3059339-0415-0410-9bf9-f77b7e298cf2>2009-12-20 17:01:47 +0000
commit7046f2cd1666418771f2af8693a4b2952379cf0e (patch)
tree8aa01d9f9d3928a53f1b4132b9a3e9df129f61a7 /vidix
parent2d4a819ef505973aa2ad58b37af65c7b11e7e6ae (diff)
downloadmpv-7046f2cd1666418771f2af8693a4b2952379cf0e.tar.bz2
mpv-7046f2cd1666418771f2af8693a4b2952379cf0e.tar.xz
Move code to write multiple inclusion guards to generated files into functions.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30083 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'vidix')
-rwxr-xr-xvidix/pci_db2c.awk43
1 files changed, 28 insertions, 15 deletions
diff --git a/vidix/pci_db2c.awk b/vidix/pci_db2c.awk
index ccab1c6708..0ca5f32cfd 100755
--- a/vidix/pci_db2c.awk
+++ b/vidix/pci_db2c.awk
@@ -45,18 +45,12 @@ BEGIN {
print_head(name_h_file);
print_head(dev_ids_file);
print_includes(dev_ids_file);
- print "#ifndef MPLAYER_PCI_VENDORS_H" > vendor_file
- print "#define MPLAYER_PCI_VENDORS_H" > vendor_file
- print "" > vendor_file
- print "#ifndef MPLAYER_PCI_IDS_H" > ids_file
- print "#define MPLAYER_PCI_IDS_H" > ids_file
- print "" > ids_file
+ print_guards_start(vendor_file);
+ print_guards_start(name_h_file);
+ print_guards_start(ids_file);
print "#include \"pci_vendors.h\"" > ids_file
print "" > ids_file
- print "#ifndef MPLAYER_PCI_NAMES_H" > name_h_file
- print "#define MPLAYER_PCI_NAMES_H" > name_h_file
- print "" > name_h_file
print_name_struct(name_h_file);
print "#include <stddef.h>" > name_file
print "#include \"pci_names.h\"" > name_file
@@ -110,18 +104,37 @@ BEGIN {
}
}
#print "Total lines parsed:", line;
- print "" > vendor_file
- print "#endif /* MPLAYER_PCI_VENDORS_H */" > vendor_file
- print "" > ids_file
- print "#endif /* MPLAYER_PCI_IDS_H */" > ids_file
- print "" > name_h_file
- print "#endif /* MPLAYER_PCI_NAMES_H */" > name_h_file
+ print_guards_end(vendor_file);
+ print_guards_end(name_h_file);
+ print_guards_end(ids_file);
if (with_pci_db) print "};" > name_file
print "{ 0xFFFF, NULL }" > dev_ids_file;
print "};" > dev_ids_file
print_func_bodies(name_file);
}
+function construct_guard_name(out_file)
+{
+ split(out_file, path_components, "/");
+ sub(".h","_h", path_components[2]);
+ return "MPLAYER_" toupper(path_components[2]);
+}
+
+function print_guards_start(out_file)
+{
+ guard_name = construct_guard_name(out_file);
+ printf("#ifndef %s\n", guard_name) > out_file
+ printf("#define %s\n", guard_name) > out_file
+ print "" > out_file
+}
+
+function print_guards_end(out_file)
+{
+ guard_name = construct_guard_name(out_file);
+ print "" > out_file
+ printf("#endif /* %s */\n", guard_name) > out_file
+}
+
function print_includes(out_file)
{
print "#include <stdlib.h>" > out_file;