mirror of
https://github.com/VincentWei/minigui-docs.git
synced 2025-10-23 18:38:56 +08:00
Feynman Software -> FMSoft
This commit is contained in:
41
programming-guide/include_source.awk
Normal file
41
programming-guide/include_source.awk
Normal file
@@ -0,0 +1,41 @@
|
||||
BEGIN { }
|
||||
|
||||
# %INCLUDE{"%ATTACHURL%/helloworld.c.txt" pattern="^.*?// START_OF_INCS(.*?)// END_OF_INCS.*"}%
|
||||
|
||||
{
|
||||
if (match ($0, /^%INCLUDE\{"%ATTACHURL%\/(\w+)\W/, fields)) {
|
||||
source_file = "samples/" fields[1] ".c"
|
||||
if (match ($0, /.+pattern=".+ START_OF_([A-Z]+)\W.+ END_OF_([A-Z]+)\W/, fields)) {
|
||||
start_tag = "START_OF_" fields[1]
|
||||
end_tag = "END_OF_" fields[2]
|
||||
# print "Include source between " start_tag " and " end_tag " from " source_file " here..."
|
||||
|
||||
started = 0
|
||||
while ((getline line < source_file) > 0) {
|
||||
|
||||
if (index (line, start_tag) != 0) {
|
||||
started = 1
|
||||
continue
|
||||
}
|
||||
else if (index (line, end_tag) != 0) {
|
||||
started = 0
|
||||
}
|
||||
|
||||
if (started) {
|
||||
print line
|
||||
}
|
||||
}
|
||||
|
||||
close (source_file)
|
||||
}
|
||||
else {
|
||||
# print "Include all source from " source_file " here..."
|
||||
while ((getline line < source_file) > 0)
|
||||
print line
|
||||
close (source_file)
|
||||
}
|
||||
}
|
||||
else
|
||||
print $0
|
||||
}
|
||||
|
Reference in New Issue
Block a user