You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by se...@apache.org on 2006/03/12 01:05:14 UTC
svn commit: r385211 - /incubator/stdcxx/trunk/tests/src/char.cpp
Author: sebor
Date: Sat Mar 11 16:05:12 2006
New Revision: 385211
URL: http://svn.apache.org/viewcvs?rev=385211&view=rev
Log:
2006-03-11 Martin Sebor <se...@roguewave.com>
* char.cpp (copy, move, rw_widen): Corrected logic errors.
Modified:
incubator/stdcxx/trunk/tests/src/char.cpp
Modified: incubator/stdcxx/trunk/tests/src/char.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/src/char.cpp?rev=385211&r1=385210&r2=385211&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/src/char.cpp (original)
+++ incubator/stdcxx/trunk/tests/src/char.cpp Sat Mar 11 16:05:12 2006
@@ -129,7 +129,8 @@
++n_calls_ [MemFun::copy];
- for (size_t i = 0; i != n; dst [i] = src [i]);
+ for (size_t i = 0; i != n; i++)
+ dst [i] = src [i];
return dst;
}
@@ -143,7 +144,14 @@
++n_calls_ [MemFun::move];
- for (; n--; dst [n] = src [n]);
+ if (dst < src) {
+ for (size_t i = 0; i != n; ++i)
+ dst [i] = src [i];
+ }
+ else {
+ while (n--)
+ dst [n] = src [n];
+ }
return dst;
}
@@ -223,21 +231,21 @@
char*
rw_widen (char *dst, const char *src, size_t len)
{
- // dst must point to an array of at least 1 element
- RW_ASSERT (0 != dst);
-
// allow src to be null
if (0 == src)
src = "";
// compute the length of src if not specified
if (_RWSTD_SIZE_MAX == len)
- len = src ? strlen (src) : 0;
+ len = src ? strlen (src) + 1 : 0;
// copy src into dst
- if (len)
+ if (len) {
+ RW_ASSERT (0 != dst);
+
memcpy (dst, src, len);
- else
+ }
+ else if (dst)
*dst = '\0';
return dst;
@@ -250,26 +258,29 @@
wchar_t*
rw_widen (wchar_t *dst, const char *src, size_t len)
{
- // dst must point to an array of at least 1 element
- RW_ASSERT (0 != dst);
-
// allow src to be null
if (0 == src)
src = "";
// compute the length of src if not specified
if (_RWSTD_SIZE_MAX == len)
- len = src ? strlen (src) : 0;
+ len = src ? strlen (src) + 1 : 0;
- // widen src into dst one element at a time
- for (size_t i = 0; ; ++i) {
- typedef unsigned char UChar;
+ // if len is non-zero dst must be non-0 as well
+ RW_ASSERT (0 == len || 0 != dst);
- // always NUL-terminate dst
- dst [i] = wchar_t (UChar (src [i]));
+ if (dst) {
+ // widen src into dst one element at a time
+ for (size_t i = 0; ; ++i) {
+ typedef unsigned char UChar;
+
+ if (i == len) {
+ dst [i] = L'\0';
+ break;
+ }
- if (i == len)
- break;
+ dst [i] = wchar_t (UChar (src [i]));
+ }
}
return dst;
@@ -291,18 +302,24 @@
// compute the length of src if not specified
if (_RWSTD_SIZE_MAX == len)
- len = src ? strlen (src) : 0;
+ len = src ? strlen (src) + 1 : 0;
- // widen src into dst one element at a time
- for (size_t i = 0; ; ++i) {
- typedef unsigned char UChar;
-
- // always NUL-terminate dst
- dst [i].f = 0;
- dst [i].c = UChar (src [i]);
+ // if len is non-zero dst must be non-0 as well
+ RW_ASSERT (0 == len || 0 != dst);
- if (i == len)
- break;
+ if (dst) {
+ // widen src into dst one element at a time
+ for (size_t i = 0; ; ++i) {
+ typedef unsigned char UChar;
+
+ if (i == len) {
+ dst [i] = UserChar::eos ();
+ break;
+ }
+
+ dst [i].f = 0;
+ dst [i].c = UChar (src [i]);
+ }
}
return dst;
Re: VACPP 8.0 builds with custom compiler cfg file
Posted by Liviu Nicoara <ni...@roguewave.com>.
Martin Sebor wrote:
> Liviu Nicoara wrote:
>> Martin Sebor wrote:
>>
>>> Liviu Nicoara wrote:
>>>
>> The options are discarded and the build fails with the compiler looking
>> for the config file in /etc/... . I would like to have the ability to
>> pass -F as an option.
>
> Did you quote the whole thing:
>
> gmake CXXOPTS="-F <config-file>" LDOPTS="-F <config-file>" ...
Of course I did. :-)
Liviu
Re: VACPP 8.0 builds with custom compiler cfg file
Posted by Martin Sebor <se...@roguewave.com>.
Liviu Nicoara wrote:
> Martin Sebor wrote:
>
>>>Liviu Nicoara wrote:
>>>A cursory look at toplevel GNUMakefile shows that CXXOPTS, CPPOPTS and
>>>LDOPTS values are not saved in makefile.in. The easiest fix would be to
>>>append their values to the corresponding ~FLAGS variables. I have not
>>>tested it and I am not aware of any adverse effects.
>>>
>>>What do you think?
>>
>>I'm not sure. This is what we used to do but I changed it because
>>they get appended in makefile.common adding them to CXXFLAGS in
>>makefile.in will end up duplicated. I'll have to think about how
>>to do what you want w/o duplicating the options.
>
>
> The reason I believe we should address this and avoid manual
> modification of makefile.in is that all invocations of the compiler
> before makefile.in is created are failing with consequences like
> choosing the wrong build model (tempinc vs template registry).
Yeah, I know. It has bitten me several times already. If you put
together a patch that solves w/o duplicating the options later on
I'll be glad to accept it :)
Martin
Re: VACPP 8.0 builds with custom compiler cfg file
Posted by Liviu Nicoara <ni...@roguewave.com>.
Martin Sebor wrote:
>> Liviu Nicoara wrote:
>> A cursory look at toplevel GNUMakefile shows that CXXOPTS, CPPOPTS and
>> LDOPTS values are not saved in makefile.in. The easiest fix would be to
>> append their values to the corresponding ~FLAGS variables. I have not
>> tested it and I am not aware of any adverse effects.
>>
>> What do you think?
>
> I'm not sure. This is what we used to do but I changed it because
> they get appended in makefile.common adding them to CXXFLAGS in
> makefile.in will end up duplicated. I'll have to think about how
> to do what you want w/o duplicating the options.
The reason I believe we should address this and avoid manual
modification of makefile.in is that all invocations of the compiler
before makefile.in is created are failing with consequences like
choosing the wrong build model (tempinc vs template registry).
Liviu
Re: VACPP 8.0 builds with custom compiler cfg file
Posted by Martin Sebor <se...@roguewave.com>.
Liviu Nicoara wrote:
> Martin Sebor wrote:
>
>>Liviu Nicoara wrote:
>>
>>>Martin Sebor wrote:
>>
>>Did you quote the whole thing:
>>
>> gmake CXXOPTS="-F <config-file>" LDOPTS="-F <config-file>" ...
>
>
> A cursory look at toplevel GNUMakefile shows that CXXOPTS, CPPOPTS and
> LDOPTS values are not saved in makefile.in. The easiest fix would be to
> append their values to the corresponding ~FLAGS variables. I have not
> tested it and I am not aware of any adverse effects.
>
> What do you think?
I'm not sure. This is what we used to do but I changed it because
they get appended in makefile.common adding them to CXXFLAGS in
makefile.in will end up duplicated. I'll have to think about how
to do what you want w/o duplicating the options.
Martin
Re: VACPP 8.0 builds with custom compiler cfg file
Posted by Liviu Nicoara <ni...@roguewave.com>.
Martin Sebor wrote:
> Liviu Nicoara wrote:
>> Martin Sebor wrote:
> Did you quote the whole thing:
>
> gmake CXXOPTS="-F <config-file>" LDOPTS="-F <config-file>" ...
A cursory look at toplevel GNUMakefile shows that CXXOPTS, CPPOPTS and
LDOPTS values are not saved in makefile.in. The easiest fix would be to
append their values to the corresponding ~FLAGS variables. I have not
tested it and I am not aware of any adverse effects.
What do you think?
Liviu
Re: VACPP 8.0 builds with custom compiler cfg file
Posted by Martin Sebor <se...@roguewave.com>.
Liviu Nicoara wrote:
> Martin Sebor wrote:
>
>>Liviu Nicoara wrote:
>>
>>>I tried to make a build with VACPP 8.0 on a SUSE box. The setting of "-F
>>><value>" (compiler config location) via compiler/linker options as
>>>explained in the README:
>>>
>>> "To change preprocessor, compiler, or linker options you can
>>> either set the make variables CPPOPTS, CXXOPTS, and LDOPTS on the
>>> command line (recommended, except with HP aCC) or modify
>>> ${BUILDDIR}/makefile.in. The second option is recommended when
>>> compiling with HP aCC (as the compiler looks for environment
>>> variables with the same names)."
>>>
>>>does not work.
>>
>>I haven't tried it. What's the problem?
>
>
> The options are discarded and the build fails with the compiler looking
> for the config file in /etc/... . I would like to have the ability to
> pass -F as an option.
Did you quote the whole thing:
gmake CXXOPTS="-F <config-file>" LDOPTS="-F <config-file>" ...
Martin
Re: VACPP 8.0 builds with custom compiler cfg file
Posted by Liviu Nicoara <ni...@roguewave.com>.
Martin Sebor wrote:
> Liviu Nicoara wrote:
>> I tried to make a build with VACPP 8.0 on a SUSE box. The setting of "-F
>> <value>" (compiler config location) via compiler/linker options as
>> explained in the README:
>>
>> "To change preprocessor, compiler, or linker options you can
>> either set the make variables CPPOPTS, CXXOPTS, and LDOPTS on the
>> command line (recommended, except with HP aCC) or modify
>> ${BUILDDIR}/makefile.in. The second option is recommended when
>> compiling with HP aCC (as the compiler looks for environment
>> variables with the same names)."
>>
>> does not work.
>
> I haven't tried it. What's the problem?
The options are discarded and the build fails with the compiler looking
for the config file in /etc/... . I would like to have the ability to
pass -F as an option.
>
>> I looked in JIRA and there seems to be no incident describing this
>> situation. I do not want to go the way of modifying makefile.in.
>>
>> Has anyone tried a build like this on such a system?
>
> Yes. You can edit makefile.in after the initial build craps out and
> add -F there.
I am going to look into why this doesn't work.
Thanks,
Liviu
Re: VACPP 8.0 builds with custom compiler cfg file
Posted by Martin Sebor <se...@roguewave.com>.
Liviu Nicoara wrote:
> I tried to make a build with VACPP 8.0 on a SUSE box. The setting of "-F
> <value>" (compiler config location) via compiler/linker options as
> explained in the README:
>
> "To change preprocessor, compiler, or linker options you can
> either set the make variables CPPOPTS, CXXOPTS, and LDOPTS on the
> command line (recommended, except with HP aCC) or modify
> ${BUILDDIR}/makefile.in. The second option is recommended when
> compiling with HP aCC (as the compiler looks for environment
> variables with the same names)."
>
> does not work.
I haven't tried it. What's the problem?
>
> I looked in JIRA and there seems to be no incident describing this
> situation. I do not want to go the way of modifying makefile.in.
>
> Has anyone tried a build like this on such a system?
Yes. You can edit makefile.in after the initial build craps out and
add -F there.
Martin
VACPP 8.0 builds with custom compiler cfg file
Posted by Liviu Nicoara <ni...@roguewave.com>.
I tried to make a build with VACPP 8.0 on a SUSE box. The setting of "-F
<value>" (compiler config location) via compiler/linker options as
explained in the README:
"To change preprocessor, compiler, or linker options you can
either set the make variables CPPOPTS, CXXOPTS, and LDOPTS on the
command line (recommended, except with HP aCC) or modify
${BUILDDIR}/makefile.in. The second option is recommended when
compiling with HP aCC (as the compiler looks for environment
variables with the same names)."
does not work.
I looked in JIRA and there seems to be no incident describing this
situation. I do not want to go the way of modifying makefile.in.
Has anyone tried a build like this on such a system?
Thanks,
Liviu