aboutsummaryrefslogtreecommitdiffstats
path: root/layout.c
diff options
context:
space:
mode:
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2004-02-01 18:08:50 +0000
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2004-02-01 18:08:50 +0000
commit92b42b9fa4a085cf62728379c144ccd6583895d6 (patch)
tree8543186fad3e5075b5a7f904318a416dd2c1d949 /layout.c
parentb115ee6dd90b5ba9588ab1814144946598901e85 (diff)
downloadlcd4linux-92b42b9fa4a085cf62728379c144ccd6583895d6.tar.gz
[lcd4linux @ 2004-02-01 18:08:50 by reinelt]
removed strtok() from layout processing (took me hours to find this bug) further strtok() removind should be done! git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@351 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'layout.c')
-rw-r--r--layout.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/layout.c b/layout.c
index 01ff9ed..7fb01de 100644
--- a/layout.c
+++ b/layout.c
@@ -1,4 +1,4 @@
-/* $Id: layout.c,v 1.7 2004/01/30 20:57:56 reinelt Exp $
+/* $Id: layout.c,v 1.8 2004/02/01 18:08:50 reinelt Exp $
*
* new layouter framework
*
@@ -23,6 +23,10 @@
*
*
* $Log: layout.c,v $
+ * Revision 1.8 2004/02/01 18:08:50 reinelt
+ * removed strtok() from layout processing (took me hours to find this bug)
+ * further strtok() removind should be done!
+ *
* Revision 1.7 2004/01/30 20:57:56 reinelt
* HD44780 patch from Martin Hejl
* dmalloc integrated
@@ -89,8 +93,7 @@ int layout_addItem (char *name, int row, int col)
int layout_init (char *layout)
{
char *section;
- char *list;
- char *key;
+ char *list, *l;
char *widget;
int row, col;
@@ -101,22 +104,27 @@ int layout_init (char *layout)
section=malloc(strlen(layout)+8);
strcpy(section, "Layout:");
strcat(section, layout);
-
+
+ // get a list of all keys in this section
list=cfg_list(section);
- key=strtok(list, "|");
- while (key!=NULL) {
+
+ // map to lower char for scanf()
+ for (l=list; *l!='\0'; l++) *l=tolower(*l);
+
+ while (list!=NULL) {
+ char *pipe;
int i, n;
- char *k;
- // map to lower char for scanf()
- for (k=key; *k!='\0'; k++) *k=tolower(*k);
- i=sscanf (key, "row%d.col%d%n", &row, &col, &n);
- if (i==2 && key[n]=='\0') {
- widget=cfg_get(section, key, NULL);
+ // list is delimited by |
+ if ((pipe=strchr(list, '|'))!=NULL) *pipe='\0';
+ i=sscanf (list, "row%d.col%d%n", &row, &col, &n);
+ if (i==2 && list[n]=='\0') {
+ widget=cfg_get(section, list, NULL);
if (widget!=NULL && *widget!='\0') {
layout_addItem (widget, row, col);
}
}
- key=strtok(NULL, "|");
+ // next field
+ list=pipe?pipe+1:NULL;
}
free (list);