#include "crc.h"
#include "getopt-min.h"
-#define DEBUG_ENV 1 /* set to 1 to debug */
+#define DEBUG_ENV 0 /* set to 1 to debug */
#define debug_env(fmt, args...) \
debug_cond(DEBUG_ENV, fmt, ##args)
ENV_CPM3_SYSFILE "=" CONFIG_CPM3_SYSFILE DELIM
ENV_PINALIAS "=" "0:PG5,1:PG4,2:PB4,3:PB5,4:PB6,5:PB7,"
"6:PG3,7:PG2,8:PG1,9:PG0,10:PE7" DELIM
- ENV_STARTADDRESS "=" "0" DELIM
+ //ENV_STARTADDRESS "=" "0" DELIM
"pins" "=" "2,8 low 9 high 3 2" DELIM
DELIM
};
char data[ENV_SIZE]; /* Environment data */
} env_t;
-#if 0
-/* */
-typedef struct env_item_s {
- char * envvar;
-} env_item_t;
-
-
-static uint8_t env_valid;
-static env_item_t env_list[CONFIG_ENVVAR_MAX];
-static int entrycount;
-#endif
static uint8_t env_valid;
static char env_list[ENV_SIZE];
{
char *next = ep + strlen(ep) + 1;
char *end = next;
- while (*end++ != 0);
+ while (*end++ != 0)
while (*end++ != 0);
memmove(ep, next, end - next);
return 0;
}
+static int envcmp(const char *s1, const char *s2)
+{
+ const unsigned char *u1 = (const unsigned char *)s1;
+ const unsigned char *u2 = (const unsigned char *)s2;
+ unsigned char c1, c2;
+
+ do {
+ c1 = *u1++; c2 = *u2++;
+ if (c1 == '=') c1 = '\0';
+ if (c2 == '=') c2 = '\0';
+ } while (c1 != 0 && c1 - c2 == 0);
+
+ return c1 - c2;
+}
+
static char *envlist_search(const MEMX char *name)
{
char key[CONFIG_SYS_ENV_NAMELEN + 1];
key[keylen++] = c;
key[keylen] = '\0';
-debug_env("### len: %d, key: \"%s\"\n", keylen, key);
-
for (char *lp = env_list; *lp != 0; ++lp) {
- if (strncmp(lp, key, keylen) == 0)
+ if (envcmp(lp, key) == 0)
return lp;
while (*lp != 0)
{
char *dstp = pos + strlen(envstr) + 1;
char *end = pos;
- while (*end++ != 0);
+ while (*end++ != 0)
while (*end++ != 0);
if (end > env_list + ENV_SIZE)
for (lp = env_list; *lp != 0; ++lp) {
- rc = strncmp(lp, ep, len);
+ rc = envcmp(lp, ep);
if (rc >= 0)
break;