]> cloudbase.mooo.com Git - z180-stamp.git/commitdiff
envlist_search
authorLeo C <erbl259-lmu@yahoo.de>
Mon, 25 Aug 2014 14:44:27 +0000 (16:44 +0200)
committerLeo C <erbl259-lmu@yahoo.de>
Sat, 30 Aug 2014 11:38:54 +0000 (13:38 +0200)
avr/env.c

index b1627675bdd7d21940744b47132d82eb6785310b..343d88204b4e2636cc21b878101d603aa0ff5564 100644 (file)
--- a/avr/env.c
+++ b/avr/env.c
@@ -321,10 +321,23 @@ int env_init(void)
 }      
 
 
-static
+
 env_item_t *envlist_search(const __memx char *name)
 {
-       return bsearch(name, env_list, entrycount, 
+       char *p = (char *) name;
+
+#ifdef __MEMX
+       char buf[CONFIG_SYS_ENV_NAMELEN+1];
+
+       if (__builtin_avr_flash_segment(name) != -1) {
+               p = buf;
+               while ((*p++ = *name++) != '\0')
+                       ;
+               p = buf;
+       }
+#endif /* __MEMX */
+
+       return bsearch(p, env_list, entrycount,
                                sizeof(env_item_t), comp_env_key_item);
 }
                        
@@ -569,7 +582,7 @@ int env_item_print(env_item_t *ep)
  * Returns -1 in case of error, or length of printed string
  */
 static 
-int env_print(char *name)
+int env_print(const __memx char *name)
 {
        int len = -1;
 
@@ -767,7 +780,7 @@ int setenv_ulong(const char *varname, unsigned long value)
  * @param value                Value to set it to
  * @return 0 if ok, 1 on error
  */
-int setenv_hex(const char *varname, unsigned long value)
+int setenv_hex(const __memx char *varname, unsigned long value)
 {
        char str[sizeof(unsigned long) *2 + 1];