]> git.webhop.me Git - lcd4linux.git/commitdiff
[lcd4linux @ 2004-02-01 18:08:50 by reinelt]
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Sun, 1 Feb 2004 18:08:50 +0000 (18:08 +0000)
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Sun, 1 Feb 2004 18:08:50 +0000 (18:08 +0000)
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

cfg.c
layout.c

diff --git a/cfg.c b/cfg.c
index 0593c3684df9a53d4607c0339c6de21e0925ede5..fd94052541fe47e0dba50460a154c945a4a980db 100644 (file)
--- a/cfg.c
+++ b/cfg.c
@@ -1,4 +1,4 @@
-/* $Id: cfg.c,v 1.32 2004/01/30 20:57:55 reinelt Exp $^
+/* $Id: cfg.c,v 1.33 2004/02/01 18:08:50 reinelt Exp $^
  *
  * config file stuff
  *
  *
  *
  * $Log: cfg.c,v $
+ * Revision 1.33  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.32  2004/01/30 20:57:55  reinelt
  * HD44780 patch from Martin Hejl
  * dmalloc integrated
@@ -393,7 +397,7 @@ char *l4l_cfg_list (char *section)
   for (i=0; i<nConfig; i++) {
     if (strncasecmp(Config[i].key, key, len)==0) {
       list=realloc(list, strlen(list)+strlen(Config[i].key)-len+2);
-      strcat (list, "|");
+      if (*list!='\0') strcat (list, "|");
       strcat (list, Config[i].key+len);
     }
   }
index 01ff9ed0add17878affc09c4a6e744fde50ce2d5..7fb01de4d5f02cad8950201c5cd2c0abf611d1af 100644 (file)
--- 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
  *
  *
  *
  * $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);