Browse Source

Added description-ll support.

r50
keep-around/c8703c509368e1805e513d61f98a9d17d2cdd9cc
Peter Novodvorsky 22 years ago
parent
commit
97c95df7a0
  1. 28
      main-menu.c
  2. 1
      main-menu.h
  3. 13
      status.c

28
main-menu.c

@ -120,13 +120,24 @@ struct package_t *show_main_menu(struct package_t *packages) {
s = menutext;
for (p = head; p; p = p->next) {
if (p->installer_menu_item) {
strcpy(s, p->description);
s += strlen(p->description);
if (p->description_ll) {
strcpy(s, p->description_ll);
s += strlen(p->description_ll);
}
else
{
strcpy(s, p->description);
s += strlen(p->description);
}
*s++ = ',';
*s++ = ' ';
if (! menudefault && isdefault(p))
menudefault = p->description;
if (! menudefault && isdefault(p)) {
if (p->description_ll)
menudefault = p->description_ll;
else
menudefault = p->description;
}
}
}
/* Trim trailing ", " */
@ -146,8 +157,13 @@ struct package_t *show_main_menu(struct package_t *packages) {
/* Figure out which menu item was selected. */
for (p = head; p; p = p->next) {
if (p->installer_menu_item && strcmp(p->description, s) == 0)
return p;
if (p->description_ll) {
if (p->installer_menu_item && strcmp(p->description, s) == 0)
return p;
}
else
if (p->installer_menu_item && strcmp(p->description_ll, s) == 0)
return p;
}
return 0;
}

1
main-menu.h

@ -26,6 +26,7 @@ struct package_t {
char *package;
int installer_menu_item;
char *description; /* short only, and only for menu items */
char *description_ll;
char *depends[DEPENDSMAX];
int status;
int processed;

13
status.c

@ -14,7 +14,7 @@
*/
struct package_t *status_read(void) {
FILE *f;
char *b, buf[BUFSIZE];
char *b, buf[BUFSIZE], *lang_code, *lingua;
int i;
struct package_t *found, *newp, *p = 0;
@ -22,6 +22,8 @@ struct package_t *status_read(void) {
perror(STATUSFILE);
return 0;
}
lingua = getenv("LINGUA");
while (fgets(buf, BUFSIZE, f) && !feof(f)) {
buf[strlen(buf)-1] = 0;
@ -52,6 +54,15 @@ struct package_t *status_read(void) {
*/
p->description = strdup(buf+13);
}
else if (strstr(buf, "Description-") == buf && lingua) {
if (strlen(buf) >= 16 && buf[14] == ':') {
lang_code = (char *) malloc(3);
memcpy(lang_code, buf + 12, 2);
if (strcmp(lang_code, lingua) == 0)
p->description_ll = strdup(buf + 16);
free(lang_code);
}
}
else if (strstr(buf, "Depends: ") == buf) {
/*
* Basic depends line parser. Can ignore versioning

Loading…
Cancel
Save