--- trunk/grubby/grubby.c 2016/06/30 10:17:00 2972 +++ trunk/grubby/grubby.c 2016/06/30 10:30:31 2986 @@ -222,6 +222,7 @@ .mbHyperFirst = 1, .mbInitRdIsModule = 1, .mbAllowExtraInitRds = 1, + .titlePosition = 1, }; struct keywordTypes grub2Keywords[] = { @@ -594,6 +595,7 @@ .needsBootPrefix = 1, .argsInQuotes = 1, .mbConcatArgs = 1, + .titlePosition = 1, }; struct configFileInfo liloConfigType = { @@ -602,6 +604,7 @@ .entryStart = LT_KERNEL, .argsInQuotes = 1, .maxTitleLength = 15, + .titlePosition = 1, }; struct configFileInfo yabootConfigType = { @@ -612,6 +615,7 @@ .argsInQuotes = 1, .maxTitleLength = 15, .mbAllowExtraInitRds = 1, + .titlePosition = 1, }; struct configFileInfo siloConfigType = { @@ -621,6 +625,7 @@ .needsBootPrefix = 1, .argsInQuotes = 1, .maxTitleLength = 15, + .titlePosition = 1, }; struct configFileInfo ziplConfigType = { @@ -640,6 +645,7 @@ .maxTitleLength = 255, .mbAllowExtraInitRds = 1, .defaultIsUnquoted = 1, + .titlePosition = 1, }; struct grubConfig { @@ -828,13 +834,18 @@ } /* extract the title from within brackets (for zipl) */ -static char * extractTitle(struct singleLine * line) { - /* bracketed title... let's extract it (leaks a byte) */ +static char * extractTitle(struct grubConfig *cfg, struct singleLine * line) { + /* bracketed title... let's extract it */ char * title = NULL; if (line->type == LT_TITLE) { - title = strdup(line->elements[0].item); - title++; - *(title + strlen(title) - 1) = '\0'; + char *tmp = line->elements[cfg->cfi->titlePosition].item; + if (cfg->cfi->titleBracketed) { + tmp++; + title = strdup(tmp); + *(title + strlen(title) - 1) = '\0'; + } else { + title = strdup(tmp); + } } else if (line->type == LT_MENUENTRY) title = strdup(line->elements[1].item); else @@ -1442,7 +1453,7 @@ line->elements[1].item)) break; } else if (line) { if (!strcmp(defaultLine->elements[1].item, - extractTitle(line))) break; + extractTitle(cfg, line))) break; } i++; entry = NULL; @@ -1493,7 +1504,7 @@ if (!line) line = getLineByType(LT_TITLE, entry->lines); if (line) { - title = extractTitle(line); + title = extractTitle(cfg, line); if (title) cfg->cfi->setEnv(cfg->cfi, "saved_entry", title); } @@ -1531,7 +1542,7 @@ else if (line && (line->numElements == 1) && cfg->cfi->titleBracketed) { fprintf(out, "%sdefault%s%s\n", indent, separator, - extractTitle(line)); + extractTitle(cfg, line)); } } } @@ -3333,7 +3344,7 @@ if (!line) continue; - linetitle = extractTitle(line); + linetitle = extractTitle(cfg, line); if (!linetitle) continue; if (strcmp(title, linetitle)) { @@ -3387,7 +3398,7 @@ if (!line) continue; - linetitle = extractTitle(line); + linetitle = extractTitle(cfg, line); if (!linetitle) continue; if (strcmp(title, linetitle)) { @@ -4413,9 +4424,11 @@ } if (!cfi) { - if (grub2FindConfig(&grub2ConfigType)) + if (grub2FindConfig(&grub2ConfigType)) { cfi = &grub2ConfigType; - else + if (envPath) + cfi->envFile = envPath; + } else #ifdef __ia64__ cfi = &eliloConfigType; #elif __powerpc__