]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - lib/hashtable.c
spi: omap3_spi: add am43xx support to omap3_spi
[karo-tx-uboot.git] / lib / hashtable.c
index c5a2b08becf4e9e0ebfac9708f178b8575812ffe..18ed5901ec284b63150435bf5af9b8db6b42d373 100644 (file)
@@ -564,7 +564,7 @@ static int match_entry(ENTRY *ep, int flag,
        int arg;
        void *priv = NULL;
 
-       for (arg = 1; arg < argc; ++arg) {
+       for (arg = 0; arg < argc; ++arg) {
 #ifdef CONFIG_REGEX
                struct slre slre;
 
@@ -776,7 +776,7 @@ static int drop_var_from_set(const char *name, int nvars, char * vars[])
 
 int himport_r(struct hsearch_data *htab,
                const char *env, size_t size, const char sep, int flag,
-               int nvars, char * const vars[])
+               int crlf_is_lf, int nvars, char * const vars[])
 {
        char *data, *sp, *dp, *name, *value;
        char *localvars[nvars];
@@ -841,6 +841,21 @@ int himport_r(struct hsearch_data *htab,
                }
        }
 
+       if(!size)
+               return 1;               /* everything OK */
+       if(crlf_is_lf) {
+               /* Remove Carriage Returns in front of Line Feeds */
+               unsigned ignored_crs = 0;
+               for(;dp < data + size && *dp; ++dp) {
+                       if(*dp == '\r' &&
+                          dp < data + size - 1 && *(dp+1) == '\n')
+                               ++ignored_crs;
+                       else
+                               *(dp-ignored_crs) = *dp;
+               }
+               size -= ignored_crs;
+               dp = data;
+       }
        /* Parse environment; allow for '\0' and 'sep' as separators */
        do {
                ENTRY e, *rv;