root/trunk/freewrt/package/busybox/patches/970-ifupdown-whitespace.patch

Revision 3296, 1.4 kB (checked in by tg, 5 years ago)

sent these to upstream

  • busybox-1.4.2/networking/ifupdown.c

    old new  
    658658        while ((buf = xmalloc_getline(f)) != NULL) { 
    659659                char *buf_ptr = buf; 
    660660 
     661                /* skip comments -- tg@freewrt.org */ 
     662                { 
     663                        unsigned char inquote = 0; 
     664 skipcommloop: 
     665                        if (inquote == 0) 
     666                                switch (*buf_ptr) { 
     667                                case '\'': 
     668                                case '\\': 
     669                                case '"': 
     670                                        inquote = *buf_ptr; 
     671                                        break; 
     672                                case '#': 
     673                                        *buf_ptr = '\0'; 
     674                                        goto skipcommend; 
     675                                } 
     676                        else if (inquote == '\\') 
     677                                inquote = 0; 
     678                        else if ((inquote == '\'') && (*buf_ptr == '\'')) 
     679                                inquote = 0; 
     680                        else if (inquote == '"') 
     681                                switch (*buf_ptr) { 
     682                                case '"': 
     683                                        inquote = 0; 
     684                                        break; 
     685                                case '\\': 
     686                                        /* escape one via backslash inside " */ 
     687                                        inquote = '!'; 
     688                                        break; 
     689                                } 
     690                        else if (inquote == '!') 
     691                                inquote = '"'; 
     692                        buf_ptr++; 
     693                        if (*buf_ptr) 
     694                                goto skipcommloop; 
     695 skipcommend:           /* required */; 
     696                } 
     697 
     698                /* rtrim -- tg@freewrt.org */ 
     699                buf_ptr = buf + strlen(buf) - 1; 
     700                while ((buf_ptr >= buf) && /* can't be '\n' */ 
     701                    ((*buf_ptr == ' ') || (*buf_ptr == '\t'))) 
     702                        --buf_ptr; 
     703                *++buf_ptr = '\0'; 
     704 
     705                buf_ptr = buf; 
    661706                firstword = next_word(&buf_ptr); 
    662707                if (firstword == NULL) { 
    663708                        free(buf); 
Note: See TracBrowser for help on using the browser.