hal: Branch 'master'
Richard Hughes
hughsient at kemper.freedesktop.org
Mon Nov 3 01:07:55 PST 2008
hald/util.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
New commits:
commit 96aafd9be0bdd8f5e41cf3ec1e6f744ccdbd67eb
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Nov 3 09:07:09 2008 +0000
remove the forced removal of the trailing newline to fix OLPC probing
While doing some patches for OLPC, all the OFW firmware strings are not
terminated with \n\0 just with \0.
This means that we get results like OLP when we should be getting
OLPC.
data = OLPC0
index = 01234
len = 4
data[len-1] = C
data = IBMn0
index = 01234
len = 4
data[len-1] = \n
Now, the isspace check checks for \n, so we can remove the explicit \0
termination, and rely on the code three lines down. Removing the
explicit code allows non-newline terminated strings to be got with
hal_util_get_string_from_file().
diff --git a/hald/util.c b/hald/util.c
index 81060e4..c7f80ab 100644
--- a/hald/util.c
+++ b/hald/util.c
@@ -305,13 +305,14 @@ hal_util_get_string_from_file (const gchar *directory, const gchar *file)
//HAL_ERROR (("Cannot read from '%s'", path));
goto out;
}
-
+
+ /* blank file, no data */
len = strlen (buf);
- if (len>0)
- buf[len-1] = '\0';
+ if (len == 0)
+ goto out;
- /* Clear remaining whitespace */
- for (i = len - 2; i >= 0; --i) {
+ /* clear remaining whitespace */
+ for (i = len - 1; i >= 0; --i) {
if (!g_ascii_isspace (buf[i]))
break;
buf[i] = '\0';
More information about the hal-commit
mailing list