1 --- ConsoleKit-0.4.1/src/ck-manager.c-orig Fri Jun 15 10:43:58 2012
2 +++ ConsoleKit-0.4.1/src/ck-manager.c Fri Jun 15 10:44:03 2012
5 #if (defined(sun) && defined(__SVR4))
6 #include <libscf_priv.h>
10 #if defined HAVE_POLKIT
11 @@ -1282,10 +1283,36 @@
13 #if (defined(sun) && defined(__SVR4))
15 +is_decimal_string(gchar *token, gint *indexp)
19 + for (i = 0; token[i] != 0; i++)
20 + if (!isdigit(token[i]))
25 + *indexp = strtol(token, 0, 10);
29 + /* If the string is empty, return failure */
34 + * The output of bootadm should be parsed intelligently; not based on
35 + * the order of lines, but based on the line semantics. We look for
36 + * the keyword "default" when looking for the default entry. Lines
37 + * that start with a number specify boot entries that should be
38 + * captured for display in the dialog's boot entry list.
41 parse_output (const gchar *output, GPtrArray **systems)
44 - gint default_id = -1;
45 + gint id, default_id = -1;
49 @@ -1292,45 +1319,40 @@
51 lines = g_strsplit (output, "\n", 0);
52 for (int i = 0; lines[i] != NULL; i++) {
56 - if (i == 0 || i == 2) {
57 - /* We do not care 1st & 2nd line. */
59 - } else if (i == 1) {
60 - /* default boot menu entry */
61 - index = strchr (lines[i], ' ');
62 - if (index && (index + 1)) {
63 - default_id = atol (index + 1);
67 - } else if (lines[i][0] != NULL && systems) {
68 - /* boot menu entries */
70 + /* Split lines into 2 tokens maximum */
71 + tokens = g_strsplit_set(lines[i], " \t", 2);
74 + } else if (tokens[0] == 0) {
79 - index = strchr (lines[i], ' ');
80 - if (index && (index + 1)) {
82 + if (tokens[1] != 0 && strcmp(tokens[0], "default") == 0) {
84 + default_id = strtol (tokens[1], 0, 10);
87 + } else if (is_decimal_string(tokens[0], &id) && systems) {
90 - id = atoi (lines[i]);
91 - g_value_init (&elem, OS_STRUCT_TYPE);
92 - g_value_take_boxed (&elem,
93 - dbus_g_type_specialized_construct (OS_STRUCT_TYPE));
94 - dbus_g_type_struct_set (&elem,
95 + /* boot menu entries */
98 + g_value_init (&elem, OS_STRUCT_TYPE);
99 + g_value_take_boxed (&elem,
100 + dbus_g_type_specialized_construct (OS_STRUCT_TYPE));
101 + dbus_g_type_struct_set (&elem,
106 + 3, (tokens[1] && tokens[1][0]) ? tokens[1] : "<no title specified>",
107 4, (default_id == id),
109 - g_ptr_array_add (*systems,
110 - g_value_get_boxed (&elem));
114 + g_ptr_array_add (*systems, g_value_get_boxed (&elem));
116 + g_strfreev(tokens);