diff options
Diffstat (limited to 'hal-0.5.11-patches/0028-remove-the-forced-removal-of-the-trailing-newline-to.patch')
-rw-r--r-- | hal-0.5.11-patches/0028-remove-the-forced-removal-of-the-trailing-newline-to.patch | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/hal-0.5.11-patches/0028-remove-the-forced-removal-of-the-trailing-newline-to.patch b/hal-0.5.11-patches/0028-remove-the-forced-removal-of-the-trailing-newline-to.patch new file mode 100644 index 00000000..1065c41e --- /dev/null +++ b/hal-0.5.11-patches/0028-remove-the-forced-removal-of-the-trailing-newline-to.patch @@ -0,0 +1,58 @@ +From 12a6d7c88cfb32cd3f811146d1f9af614d90fec2 Mon Sep 17 00:00:00 2001 +From: Richard Hughes <richard@hughsie.com> +Date: Mon, 3 Nov 2008 09:07:09 +0000 +Subject: [PATCH 28/48] 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(). +--- + hald/util.c | 11 ++++++----- + 1 files changed, 6 insertions(+), 5 deletions(-) + +diff --git a/hald/util.c b/hald/util.c +index 51f5d8a..44645a4 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'; +-- +1.6.1.2 + |