DragonFly submit List (threaded) for 2004-12
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
usr.bin/make fix code were we lie about const.
Instead of modifying a const string parameter, we just calculate
the length of the string instead of null terminating and using strlen().
Max
--- var_modify.c.orig Sat Nov 27 06:08:10 2004
+++ var_modify.c Sat Nov 27 06:11:39 2004
@@ -70,9 +70,7 @@
if (addSpace) {
Buf_AddByte (buf, (Byte)' ');
}
- *slash = '\0';
- Buf_AddBytes (buf, strlen (word), (Byte *)word);
- *slash = '/';
+ Buf_AddBytes (buf, slash - word, (Byte *)word);
return (TRUE);
} else {
/*
@@ -105,7 +103,7 @@
Boolean
VarTail (const char *word, Boolean addSpace, Buffer buf, void *dummy __unused)
{
- char *slash;
+ const char *slash;
if (addSpace) {
Buf_AddByte (buf, (Byte)' ');
@@ -113,9 +111,8 @@
slash = strrchr (word, '/');
if (slash != NULL) {
- *slash++ = '\0';
+ slash++;
Buf_AddBytes (buf, strlen(slash), (Byte *)slash);
- slash[-1] = '/';
} else {
Buf_AddBytes (buf, strlen(word), (Byte *)word);
}
@@ -139,16 +136,15 @@
Boolean
VarSuffix (const char *word, Boolean addSpace, Buffer buf, void *dummy __unused)
{
- char *dot;
+ const char *dot;
dot = strrchr (word, '.');
if (dot != NULL) {
if (addSpace) {
Buf_AddByte (buf, (Byte)' ');
}
- *dot++ = '\0';
+ dot++;
Buf_AddBytes (buf, strlen (dot), (Byte *)dot);
- dot[-1] = '.';
addSpace = TRUE;
}
return (addSpace);
@@ -180,9 +176,7 @@
dot = strrchr (word, '.');
if (dot != NULL) {
- *dot = '\0';
- Buf_AddBytes (buf, strlen (word), (Byte *)word);
- *dot = '.';
+ Buf_AddBytes (buf, dot - word, (Byte *)word);
} else {
Buf_AddBytes (buf, strlen(word), (Byte *)word);
}
@@ -214,7 +208,7 @@
Buf_AddByte(buf, (Byte)' ');
}
addSpace = TRUE;
- Buf_AddBytes(buf, strlen(word), (Byte *)word);
+ Buf_AddBytes(buf, strlen(word), word);
}
return(addSpace);
}
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]