Re: MergeLog.awk
- From: Gonzalo Paniagua Javier <gonzalo gnome-db org>
- To: gnome-hackers gnome org
- Subject: Re: MergeLog.awk
- Date: Fri, 18 Jan 2002 10:04:04 +0100
* [ Maciej Stachowiak <mjs noisehavoc org>
* Fri, 18 Jan 2002 09:52:08 +0100 ]
> Date merging should be pretty easy with a bit of appropriate perl
> hackery. I think it would be nicer to keep things date sorted.
Perl? No thanks.
Here goes a AWK script that does the job. I tested it with
libgda and it works fine.
To merge all the logs under libgda, I exec'd:
gawk -f MergeLog.awk `find -name ChangeLog` > FullLog
It prepends the directory name of each ChangeLog to the file
names after a "^\t\*( )+".
Use it at your own risk. Improve it if you want. Share it if you
find it useful.
Hope you like it.
BEGIN {
count = 1;
separator = "##%%##";
}
/^[12]/ {
dirname = FILENAME;
if (gsub ("/ChangeLog$", "/", dirname) == 0){
dirname = ""; # For executing in just one dir.
}
if (dirname == "./") dirname = "";
idx_entry = $0 dirname ;
if (length(entry[idx_entry]) != 0){
# Somebody has to entries with same name, same date,... in the same
# directory.
old_content = entry[last_entry];
entry[last_entry] = old_content separator $0;
} else {
_index[count] = idx_entry;
last_entry = idx_entry;
entry[idx_entry] = $0;
dirs[idx_entry] = dirname;
count++;
}
}
! /^[12]/{
old_content = entry[last_entry];
entry[last_entry] = old_content separator $0;
}
END {
asort(_index);
for (i=count - 1; i>0; i--){
idx = _index[i];
final = split (entry[idx], lines, separator);
subst_str = "\t* " dirs[idx];
last_line_length = 0;
for (k=1; k <= final; k++) {
gsub ("^\t\\*( )+", subst_str, lines[k]);
print lines[k];
last_line_length = length (lines[k]);
}
# Add a blank line between entries that doesn't have one
if (last_line_length != 0) print "";
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]