Mercurial > hg > octave-lojdl
changeset 7895:f1a1f6dd7fac
avoid using gensub in genprops.awk
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 20 Jun 2008 23:38:44 +0200 |
parents | 72c332d2db3c |
children | 92c26470fe56 |
files | src/ChangeLog src/genprops.awk |
diffstat | 2 files changed, 20 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2008-06-23 Jaroslav Hajek <highegg@gmail.com> + + * genprops.awk (emit_source): Avoid gensub for portability. + (BEGIN): Ditto. + 2008-06-20 Jaroslav Hajek <highegg@gmail.com> * DLD-FUNCTIONS/regexp.cc (octregexp_list): Make "once" an output
--- a/src/genprops.awk +++ b/src/genprops.awk @@ -465,9 +465,16 @@ { dval = defval[i]; if (type[i] == "radio_property" || type[i] == "color_property") - dval = gensub (/^.*\{(.*)\}.*$/, "\"\\1\"", "g", dval); - if (! dval) - dval = "octave_value ()"; + { + k = index (dval, "{"); + dval = substr (dval, k+1); + l = index (dval, "}"); + if (k > 0 && l > 0) + dval = "\"" + substr (dval, 1, l-1) + "\""; + else + dval = "octave_value ()"; + } + printf (" m[\"%s\"] = %s%s;\n", name[i], dval, (type[i] == "handle_property" ? ".as_octave_value ()" : "")) >> filename; } @@ -490,7 +497,11 @@ /BEGIN_PROPERTIES\(.*\)/ { gather = 1; idx = 0; - class_name = gensub (/^.*BEGIN_PROPERTIES\((.*)\)/, "\\1", "g"); + str = $0; + k = index (str, "BEGIN_PROPERTIES("); + str = substr (str, k + 17); + l = index (str, ")"); + class_name = substr (str, 1, l-1); next; }