Commit cbdefd1d authored by Pekka Pessi's avatar Pekka Pessi

msg/msg_parser.awk: fixed whitespace

darcs-hash:20081127232458-db55f-76adf5524d9c263fa37a9f8b2ecdc4a9284afb2f.gz
parent 0c0f3735
...@@ -49,7 +49,7 @@ BEGIN { ...@@ -49,7 +49,7 @@ BEGIN {
# Initialize these as arrays # Initialize these as arrays
split("", symbols); split("", symbols);
split("", names); split("", names);
split("", comments); split("", comments);
split("", hashes); split("", hashes);
split("", NAMES); split("", NAMES);
split("", Comments); split("", Comments);
...@@ -81,7 +81,7 @@ function name_hash (name) ...@@ -81,7 +81,7 @@ function name_hash (name)
{ {
hash = 0; hash = 0;
len = length(name); len = length(name);
for (i = 1; i <= len; i++) { for (i = 1; i <= len; i++) {
c = tolower(substr(name, i, 1)); c = tolower(substr(name, i, 1));
...@@ -112,7 +112,7 @@ function name_hash (name) ...@@ -112,7 +112,7 @@ function name_hash (name)
function protos (name, comment, hash, since) function protos (name, comment, hash, since)
{ {
NAME=toupper(name); NAME=toupper(name);
sub(/.*[\/][*][*][<][ ]*/, "", comment); sub(/.*[\/][*][*][<][ ]*/, "", comment);
sub(/[ ]*[*][\/].*/, "", comment); sub(/[ ]*[*][\/].*/, "", comment);
sub(/[ ]+/, " ", comment); sub(/[ ]+/, " ", comment);
...@@ -132,12 +132,12 @@ function protos (name, comment, hash, since) ...@@ -132,12 +132,12 @@ function protos (name, comment, hash, since)
if (name2 != name && name2 != tprefix "_" name) { if (name2 != name && name2 != tprefix "_" name) {
print name " mismatch with " comment " (" real ")" > "/dev/stderr"; print name " mismatch with " comment " (" real ")" > "/dev/stderr";
} }
hash = name_hash(parts[1]); hash = name_hash(parts[1]);
hashed[name] = hash; hashed[name] = hash;
if (comment !~ /header/) { if (comment !~ /header/) {
comment = comment " header"; comment = comment " header";
} }
} }
...@@ -149,13 +149,13 @@ function protos (name, comment, hash, since) ...@@ -149,13 +149,13 @@ function protos (name, comment, hash, since)
COMMENT = toupper(comment); COMMENT = toupper(comment);
# Store the various forms into an array for the footer processing # Store the various forms into an array for the footer processing
N++; N++;
hashes[N] = hash; hashes[N] = hash;
names[N] = name; names[N] = name;
NAMES[N] = NAME; NAMES[N] = NAME;
comments[N] = comment; comments[N] = comment;
Comments[N] = comment; Comments[N] = comment;
COMMENTS[N] = COMMENT; COMMENTS[N] = COMMENT;
symbols[name] = comment; symbols[name] = comment;
if (since) { if (since) {
...@@ -165,8 +165,8 @@ function protos (name, comment, hash, since) ...@@ -165,8 +165,8 @@ function protos (name, comment, hash, since)
expr = (without_experimental > 0 && do_hash); expr = (without_experimental > 0 && do_hash);
if (expr) { if (expr) {
printf "%s is experimental\n", Comment; printf "%s is experimental\n", Comment;
} }
experimental[N] = expr; experimental[N] = expr;
if (PR) { if (PR) {
...@@ -190,7 +190,7 @@ function replace (p, hash, name, NAME, comment, Comment, COMMENT, since) ...@@ -190,7 +190,7 @@ function replace (p, hash, name, NAME, comment, Comment, COMMENT, since)
# #
if (p) { if (p) {
gsub(/#hash#/, hash, p); gsub(/#hash#/, hash, p);
gsub(/#xxxxxx#/, name, p); gsub(/#xxxxxx#/, name, p);
gsub(/#XXXXXX#/, NAME, p); gsub(/#XXXXXX#/, NAME, p);
gsub(/#xxxxxxx_xxxxxxx#/, comment, p); gsub(/#xxxxxxx_xxxxxxx#/, comment, p);
gsub(/#Xxxxxxx_Xxxxxxx#/, Comment, p); gsub(/#Xxxxxxx_Xxxxxxx#/, Comment, p);
...@@ -203,17 +203,17 @@ function replace (p, hash, name, NAME, comment, Comment, COMMENT, since) ...@@ -203,17 +203,17 @@ function replace (p, hash, name, NAME, comment, Comment, COMMENT, since)
# Remove line with #version# # Remove line with #version#
gsub(/\n[^#\n]*#version#[^\n]*/, "", p); gsub(/\n[^#\n]*#version#[^\n]*/, "", p);
} }
print p > PR; print p > PR;
} }
} }
# #
# Repeat each line in the footer containing the magic replacement # Repeat each line in the footer containing the magic replacement
# pattern with an instance of all headers # pattern with an instance of all headers
# #
function process_footer (text) function process_footer (text)
{ {
if (!match(tolower(text), /#(xxxxxx(x_xxxxxxx)?|hash)#/)) { if (!match(tolower(text), /#(xxxxxx(x_xxxxxxx)?|hash)#/)) {
n = length(text); n = length(text);
while (substr(text, n) == "\n") { while (substr(text, n) == "\n") {
...@@ -224,7 +224,7 @@ function process_footer (text) ...@@ -224,7 +224,7 @@ function process_footer (text)
print text > PR; print text > PR;
return; return;
} }
n = split(text, lines, RS); n = split(text, lines, RS);
for (i = 1; i <= n; i++) { for (i = 1; i <= n; i++) {
...@@ -247,7 +247,7 @@ function process_footer (text) ...@@ -247,7 +247,7 @@ function process_footer (text)
gsub(/#xxxxxxx_xxxxxxx#/, comments[j], l); gsub(/#xxxxxxx_xxxxxxx#/, comments[j], l);
gsub(/#Xxxxxxx_Xxxxxxx#/, Comments[j], l); gsub(/#Xxxxxxx_Xxxxxxx#/, Comments[j], l);
gsub(/#XXXXXXX_XXXXXXX#/, COMMENTS[j], l); gsub(/#XXXXXXX_XXXXXXX#/, COMMENTS[j], l);
gsub(/#xxxxxx#/, names[j], l); gsub(/#xxxxxx#/, names[j], l);
gsub(/#XXXXXX#/, NAMES[j], l); gsub(/#XXXXXX#/, NAMES[j], l);
print l > PR; print l > PR;
} }
...@@ -272,7 +272,7 @@ function read_header_flags (flagfile, line, tokens, name, value) ...@@ -272,7 +272,7 @@ function read_header_flags (flagfile, line, tokens, name, value)
if (line ~ /^#/ || line ~ /^$/) if (line ~ /^#/ || line ~ /^$/)
continue; continue;
split(line, tokens, /[ \t]*=[ \t]*/); split(line, tokens, /[ \t]*=[ \t]*/);
name = tolower(tokens[1]); name = tolower(tokens[1]);
gsub(/-/, "_", name); gsub(/-/, "_", name);
gsub(/,/, " ", name); gsub(/,/, " ", name);
...@@ -297,7 +297,7 @@ function read_header_flags (flagfile, line, tokens, name, value) ...@@ -297,7 +297,7 @@ function read_header_flags (flagfile, line, tokens, name, value)
function templates () function templates ()
{ {
if (!auto) { if (!auto) {
auto = FILENAME; auto = FILENAME;
if (!prefix) { prefix = module; } if (!prefix) { prefix = module; }
if (!tprefix) { tprefix = prefix; } if (!tprefix) { tprefix = prefix; }
...@@ -369,11 +369,11 @@ function templates () ...@@ -369,11 +369,11 @@ function templates ()
/^#### EXTRA HEADER LIST STARTS HERE ####$/ { HLIST=1; templates(); } /^#### EXTRA HEADER LIST STARTS HERE ####$/ { HLIST=1; templates(); }
HLIST && /^#### DEFAULT HEADER LIST ENDS HERE ####$/ { basic=total; } HLIST && /^#### DEFAULT HEADER LIST ENDS HERE ####$/ { basic=total; }
HLIST && /^#### EXPERIMENTAL HEADER LIST STARTS HERE ####$/ { HLIST && /^#### EXPERIMENTAL HEADER LIST STARTS HERE ####$/ {
without_experimental = total; } without_experimental = total; }
HLIST && /^[a-z]/ { protos($1, $0, 0, $2); HLIST && /^[a-z]/ { protos($1, $0, 0, $2);
headers[total++] = $1; headers[total++] = $1;
Extra[$1] = extra++; Extra[$1] = extra++;
} }
/^#### EXTRA HEADER LIST ENDS HERE ####$/ { HLIST=0; } /^#### EXTRA HEADER LIST ENDS HERE ####$/ { HLIST=0; }
...@@ -383,14 +383,14 @@ HLIST && /^[a-z]/ { protos($1, $0, 0, $2); ...@@ -383,14 +383,14 @@ HLIST && /^[a-z]/ { protos($1, $0, 0, $2);
PT && /^ *\/\* === Hash headers end here \*\// { in_header_list=0;} PT && /^ *\/\* === Hash headers end here \*\// { in_header_list=0;}
in_header_list && /^ (sip|rtsp|http|msg|mp)_[a-z_0-9]+_t/ { in_header_list && /^ (sip|rtsp|http|msg|mp)_[a-z_0-9]+_t/ {
n=$0 n=$0
sub(/;.*$/, "", n); sub(/;.*$/, "", n);
sub(/^ *(sip|rtsp|http|msg|mp)_[a-z0-9_]*_t[ ]*/, "", n); sub(/^ *(sip|rtsp|http|msg|mp)_[a-z0-9_]*_t[ ]*/, "", n);
sub(/^[*](sip|rtsp|http|msg|mp)_/, "", n); sub(/^[*](sip|rtsp|http|msg|mp)_/, "", n);
if ($0 !~ /[\/][*][*][<]/) { if ($0 !~ /[\/][*][*][<]/) {
getline; getline;
} }
if ($0 !~ /[\/][*][*][<]/) { if ($0 !~ /[\/][*][*][<]/) {
printf "msg_protos.awk: header %s is malformed\n", n; printf "msg_protos.awk: header %s is malformed\n", n;
...@@ -446,7 +446,7 @@ function print_parser_table(struct, scope, name, N, N_EXPERIMENTAL) ...@@ -446,7 +446,7 @@ function print_parser_table(struct, scope, name, N, N_EXPERIMENTAL)
len = split("request status separator payload unknown error", unnamed, " "); len = split("request status separator payload unknown error", unnamed, " ");
for (i = 1; i <= len; i++) { for (i = 1; i <= len; i++) {
printf(" {{ %s_%s_class, msg_offsetof(%s_t, %s_%s) }},\n", printf(" {{ %s_%s_class, msg_offsetof(%s_t, %s_%s) }},\n",
tprefix, unnamed[i], module, prefix, unnamed[i]) > PT; tprefix, unnamed[i], module, prefix, unnamed[i]) > PT;
} }
if (multipart) { if (multipart) {
...@@ -456,7 +456,7 @@ function print_parser_table(struct, scope, name, N, N_EXPERIMENTAL) ...@@ -456,7 +456,7 @@ function print_parser_table(struct, scope, name, N, N_EXPERIMENTAL)
printf(" {{ NULL, 0 }},\n") > PT; printf(" {{ NULL, 0 }},\n") > PT;
} }
if (MC_SHORT_SIZE) { if (MC_SHORT_SIZE) {
printf(" %s_short_forms, \n", module) > PT; printf(" %s_short_forms, \n", module) > PT;
} }
else { else {
printf(" NULL, \n") > PT; printf(" NULL, \n") > PT;
...@@ -488,11 +488,11 @@ function print_parser_table(struct, scope, name, N, N_EXPERIMENTAL) ...@@ -488,11 +488,11 @@ function print_parser_table(struct, scope, name, N, N_EXPERIMENTAL)
if (i >= ordinary) { if (i >= ordinary) {
printf(" { %s_%s_class,\n" \ printf(" { %s_%s_class,\n" \
" msg_offsetof(struct %s, extra[%u])%s }%s\n", " msg_offsetof(struct %s, extra[%u])%s }%s\n",
tprefix, n, struct, Extra[n], flags, c) > PT; tprefix, n, struct, Extra[n], flags, c) > PT;
} }
else { else {
printf(" { %s_%s_class, msg_offsetof(%s_t, %s_%s)%s }%s\n", printf(" { %s_%s_class, msg_offsetof(%s_t, %s_%s)%s }%s\n",
tprefix, n, module, prefix, n, flags, c) > PT; tprefix, n, module, prefix, n, flags, c) > PT;
} }
...@@ -520,7 +520,7 @@ END { ...@@ -520,7 +520,7 @@ END {
if (multipart) if (multipart)
protos("multipart", "/**< Multipart payload */", -7); protos("multipart", "/**< Multipart payload */", -7);
} }
if (PR) { if (PR) {
process_footer(footer); process_footer(footer);
} }
...@@ -547,17 +547,17 @@ END { ...@@ -547,17 +547,17 @@ END {
if (MC_SHORT_SIZE) { if (MC_SHORT_SIZE) {
printf("static msg_href_t const " \ printf("static msg_href_t const " \
"%s_short_forms[MC_SHORT_SIZE] = \n{\n", "%s_short_forms[MC_SHORT_SIZE] = \n{\n",
module) > PT; module) > PT;
for (i = 1; i <= MC_SHORT_SIZE; i = i + 1) { for (i = 1; i <= MC_SHORT_SIZE; i = i + 1) {
c = (i == MC_SHORT_SIZE) ? "" : ","; c = (i == MC_SHORT_SIZE) ? "" : ",";
if (i in shorts) { if (i in shorts) {
n = shorts[i]; n = shorts[i];
flags = header_flags[n]; if (flags) flags = ",\n " flags; flags = header_flags[n]; if (flags) flags = ",\n " flags;
printf(" { /* %s */ %s_%s_class, msg_offsetof(%s_t, %s_%s)%s }%s\n", printf(" { /* %s */ %s_%s_class, msg_offsetof(%s_t, %s_%s)%s }%s\n",
substr(lower_case, i, 1), substr(lower_case, i, 1),
tprefix, n, module, prefix, n, flags, c) \ tprefix, n, module, prefix, n, flags, c) \
> PT; > PT;
} }
...@@ -566,7 +566,7 @@ END { ...@@ -566,7 +566,7 @@ END {
> PT; > PT;
} }
} }
printf("};\n\n") > PT; printf("};\n\n") > PT;
} }
# printf("extern msg_hclass_t msg_multipart_class[];\n\n") > PT; # printf("extern msg_hclass_t msg_multipart_class[];\n\n") > PT;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment