cmdline (merge-intel): fix whitespaces
[libcmdline.git] / src / lib / cmdline_parse_string.c
index eb4553b..7ac2892 100644 (file)
@@ -47,15 +47,15 @@ struct cmdline_token_ops cmdline_token_string_ops = {
 static unsigned int
 get_token_len(const char *s)
 {
-        char c;
+       char c;
        unsigned int i=0;
 
        c = s[i];
-        while (c!='#' && c!='\0') {
-                i++;
+       while (c!='#' && c!='\0') {
+               i++;
                c = s[i];
        }
-        return i;
+       return i;
 }
 
 static const char *
@@ -68,7 +68,7 @@ get_next_token(const char *s)
        return NULL;
 }
 
-int 
+int
 cmdline_parse_string(cmdline_parse_token_hdr_t *tk, const char *buf, void *res)
 {
        struct cmdline_token_string *tk2 = (struct cmdline_token_string *)tk;
@@ -79,51 +79,51 @@ cmdline_parse_string(cmdline_parse_token_hdr_t *tk, const char *buf, void *res)
        if (! *buf)
                return -1;
 
-        /* fixed string */
-        if (sd->str) {
+       /* fixed string */
+       if (sd->str) {
                str = sd->str;
-                do {
-                        token_len = get_token_len(str);
-                        
-                        /* if token is too big... */
-                        if (token_len >= STR_TOKEN_SIZE - 1) {
+               do {
+                       token_len = get_token_len(str);
+
+                       /* if token is too big... */
+                       if (token_len >= STR_TOKEN_SIZE - 1) {
                                continue;
-                        }
-                        
-                        if ( strncmp(buf, str, token_len) ) {
+                       }
+
+                       if ( strncmp(buf, str, token_len) ) {
                                continue;
-                        }
-                        
-                        if ( !cmdline_isendoftoken(*(buf+token_len)) ) {
+                       }
+
+                       if ( !cmdline_isendoftoken(*(buf+token_len)) ) {
                                continue;
-                        }
+                       }
 
-                        break;
-                } while ( (str = get_next_token(str)) != NULL );
+                       break;
+               } while ( (str = get_next_token(str)) != NULL );
 
                if (!str)
                        return -1;
-        }
-        /* unspecified string */
-        else {
-                token_len=0;
-                while(!cmdline_isendoftoken(buf[token_len]) && 
-                      token_len < (STR_TOKEN_SIZE-1))
-                        token_len++;
-
-                /* return if token too long */
-                if (token_len >= STR_TOKEN_SIZE - 1) {
-                        return -1;
-                }
-        }
-        
+       }
+       /* unspecified string */
+       else {
+               token_len=0;
+               while(!cmdline_isendoftoken(buf[token_len]) &&
+                     token_len < (STR_TOKEN_SIZE-1))
+                       token_len++;
+
+               /* return if token too long */
+               if (token_len >= STR_TOKEN_SIZE - 1) {
+                       return -1;
+               }
+       }
+
        if (res) {
                /* we are sure that token_len is < STR_TOKEN_SIZE-1 */
                strncpy(res, buf, token_len);
                *((char *)res + token_len) = 0;
        }
 
-        return token_len;
+       return token_len;
 }
 
 int cmdline_complete_get_nb_string(cmdline_parse_token_hdr_t *tk)
@@ -143,7 +143,7 @@ int cmdline_complete_get_nb_string(cmdline_parse_token_hdr_t *tk)
        return ret;
 }
 
-int cmdline_complete_get_elt_string(cmdline_parse_token_hdr_t *tk, int idx, 
+int cmdline_complete_get_elt_string(cmdline_parse_token_hdr_t *tk, int idx,
                                    char *dstbuf, unsigned int size)
 {
        struct cmdline_token_string *tk2 = (struct cmdline_token_string *)tk;
@@ -175,7 +175,7 @@ int cmdline_get_help_string(cmdline_parse_token_hdr_t *tk, char *dstbuf,
        struct cmdline_token_string *tk2 = (struct cmdline_token_string *)tk;
        struct cmdline_token_string_data *sd = &tk2->string_data;;
        const char *s;
-       
+
        s = sd->str;
 
        if (s) {
@@ -189,7 +189,7 @@ int cmdline_get_help_string(cmdline_parse_token_hdr_t *tk, char *dstbuf,
        else {
                strncpy(dstbuf, ANYSTRING_HELP, size);
        }
-       
+
        dstbuf[size-1] = '\0';
 
        return 0;