From: Shao Miller <sha0 at terminus.zytor.com> Date: Sat, 12 Jun 2010 08:03:28 -0700 Subject: [PATCH] ifcpuXX: Support multiple parameters with labels =20 The ifcpu.c32 and ifcpu64.c32 modules take arguments including the form <true_label> -- <false_label>. It is convenient to allow these labels to be not just a single word, but to include parameters. This is useful for <TAB>-editing and modifying the command-line to include parameters you''d like to pass. =20 Not-yet-tested: Shao Miller <shao.miller at yrdsb.edu.on.ca> --- com32/modules/ifcpu.c | 9 ++++++--- com32/modules/ifcpu64.c | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) =20 diff --git a/com32/modules/ifcpu.c b/com32/modules/ifcpu.c index 8a9a5f4..1e57f08 100644 --- a/com32/modules/ifcpu.c +++ b/com32/modules/ifcpu.c @@ -71,20 +71,23 @@ static unsigned char sleep(unsigned int msec) /* XXX: this really should be librarized */ static void boot_args(char **args) { - int len =3D 0; + int len =3D 0, a =3D 0; char **pp; const char *p; char c, *q, *str; =20 for (pp =3D args; *pp; pp++) - len +=3D strlen(*pp); + len +=3D strlen(*pp) + 1; =20 - q =3D str =3D alloca(len + 1); + q =3D str =3D alloca(len); for (pp =3D args; *pp; pp++) { p =3D *pp; while ((c =3D *p++)) *q++ =3D c; + *q++ =3D '' ''; + a =3D 1; } + q -=3D a; *q =3D ''\0''; =20 if (!str[0]) diff --git a/com32/modules/ifcpu64.c b/com32/modules/ifcpu64.c index 6d566a2..e123922 100644 --- a/com32/modules/ifcpu64.c +++ b/com32/modules/ifcpu64.c @@ -73,20 +73,23 @@ static bool __constfunc cpu_has_feature(int x) /* XXX: this really should be librarized */ static void boot_args(char **args) { - int len =3D 0; + int len =3D 0, a =3D 0; char **pp; const char *p; char c, *q, *str; =20 for (pp =3D args; *pp; pp++) - len +=3D strlen(*pp); + len +=3D strlen(*pp) + 1; =20 - q =3D str =3D alloca(len + 1); + q =3D str =3D alloca(len); for (pp =3D args; *pp; pp++) { p =3D *pp; while ((c =3D *p++)) *q++ =3D c; + *q++ =3D '' ''; + a =3D 1; } + q -=3D a; *q =3D ''\0''; =20 if (!str[0]) --=20 1.7.0.1 =20 ------_=_NextPart_001_01CB0A41.E8F5B860 Content-Type: application/octet-stream; name="0001-ifcpuXX-Support-multiple-parameters-with-labels.patch" Content-Transfer-Encoding: base64 Content-Description: 0001-ifcpuXX-Support-multiple-parameters-with-labels.patch Content-Disposition: attachment; filename="0001-ifcpuXX-Support-multiple-parameters-with-labels.patch" RnJvbSBjYzcwZDBmYTU1ZTM1ZmFiZjI1MGY0ZGNjYmFlZDJmYTQ0ZjU2ZGE3IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBTaGFvIE1pbGxlciA8c2hhMEB0ZXJtaW51cy56eXRvci5jb20+ CkRhdGU6IFNhdCwgMTIgSnVuIDIwMTAgMDg6MDM6MjggLTA3MDAKU3ViamVjdDogW1BBVENIXSBp ZmNwdVhYOiBTdXBwb3J0IG11bHRpcGxlIHBhcmFtZXRlcnMgd2l0aCBsYWJlbHMKClRoZSBpZmNw dS5jMzIgYW5kIGlmY3B1NjQuYzMyIG1vZHVsZXMgdGFrZSBhcmd1bWVudHMgaW5jbHVkaW5nCnRo ZSBmb3JtIDx0cnVlX2xhYmVsPiAtLSA8ZmFsc2VfbGFiZWw+LiAgSXQgaXMgY29udmVuaWVudCB0 bwphbGxvdyB0aGVzZSBsYWJlbHMgdG8gYmUgbm90IGp1c3QgYSBzaW5nbGUgd29yZCwgYnV0IHRv IGluY2x1ZGUKcGFyYW1ldGVycy4gIFRoaXMgaXMgdXNlZnVsIGZvciA8VEFCPi1lZGl0aW5nIGFu ZCBtb2RpZnlpbmcgdGhlCmNvbW1hbmQtbGluZSB0byBpbmNsdWRlIHBhcmFtZXRlcnMgeW91J2Qg bGlrZSB0byBwYXNzLgoKTm90LXlldC10ZXN0ZWQ6IFNoYW8gTWlsbGVyIDxzaGFvLm1pbGxlckB5 cmRzYi5lZHUub24uY2E+Ci0tLQogY29tMzIvbW9kdWxlcy9pZmNwd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dpdCBhL2NvbTMyL21vZHVsZXMvaWZjcHU2NC5jIGIvY29tMzIvbW9kdWxlcy9p ZmNwdTY0LmMKaW5kZXggNmQ1NjZhMi4uZTEyMzkyMiAxMDA2NDQKLS0tIGEvY29tMzIvbW9kdWxl cy9pZmNwdTY0LmMKKysrIGIvY29tMzIvbW9kdWxlcy9pZmNwdTY0LmMKQEAgLTczLDIwICs3Mywy MyBAQCBzdGF0aWMgYm9vbCBfX2NvbnN0ZnVuYyBjcHVfaGFzX2ZlYXR1cmUoaW50IHgpCiAvKiBY WFg6IHRoaXMgcmVhbGx5IHNob3VsZCBiZSBsaWJyYXJpemVkICovCiBzdGF0aWMgdm9pZCBib290 X2FyZ3MoY2hhciAqKmFyZ3MpCiB7Ci0gICAgaW50IGxlbiA9IDA7CisgICAgaW50IGxlbiA9IDAs IGEgPSAwOwogICAgIGNoYXIgKipwcDsKICAgICBjb25zdCBjaGFyICpwOwogICAgIGNoYXIgYywg KnEsICpzdHI7CiAKICAgICBmb3IgKHBwID0gYXJnczsgKnBwOyBwcCsrKQotCWxlbiArPSBzdHJs ZW4oKnBwKTsKKwlsZW4gKz0gc3RybGVuKCpwcCkgKyAxOwogCi0gICAgcSA9IHN0ciA9IGFsbG9j YShsZW4gKyAxKTsKKyAgICBxID0gc3RyID0gYWxsb2NhKGxlbik7CiAgICAgZm9yIChwcCA9IGFy Z3M7ICpwcDsgcHArKykgewogCXAgPSAqcHA7CiAJd2hpbGUgKChjID0gKnArKykpCiAJICAgICpx KysgPSBjOworCSpxKysgPSAnICc7CisJYSA9IDE7CiAgICAgfQorICAgIHEgLT0gYTsKICAgICAq cSA9ICdcMCc7CiAKICAgICBpZiAoIXN0clswXSkKLS0gCjEuNy4wLjEKCg= ------_=_NextPart_001_01CB0A41.E8F5B860--