Optimize field splitting code
@@ -1,6 +1,6 @@ | ||
1 | 1 | /* Yash: yet another shell */ |
2 | 2 | /* expand.c: word expansion */ |
3 | -/* (C) 2007-2020 magicant */ | |
3 | +/* (C) 2007-2021 magicant */ | |
4 | 4 | |
5 | 5 | /* This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
@@ -1625,20 +1625,19 @@ | ||
1625 | 1625 | continue; |
1626 | 1626 | } |
1627 | 1627 | |
1628 | - /* Now the current char is either null or a IFS non-whitespace. */ | |
1628 | + /* Now the current char is either null or an IFS non-whitespace. */ | |
1629 | 1629 | |
1630 | 1630 | if (!afterfield) |
1631 | 1631 | add_empty_field(dest, &s[index]); |
1632 | 1632 | |
1633 | - /* skip (only one) IFS non-whitespace */ | |
1634 | - if (is_ifs_char(s[index], cc[index], ifs)) { | |
1635 | - index++; | |
1636 | - afterfield = false; | |
1637 | - continue; | |
1638 | - } | |
1633 | + if (s[index] == L'\0') | |
1634 | + break; | |
1639 | 1635 | |
1640 | - /* Now the current char is null. We're done. */ | |
1641 | - break; | |
1636 | + /* skip (only) one IFS non-whitespace */ | |
1637 | + assert(is_ifs_char(s[index], cc[index], ifs)); | |
1638 | + assert(!is_ifs_whitespace(s[index], cc[index], ifs)); | |
1639 | + index++; | |
1640 | + afterfield = false; | |
1642 | 1641 | } |
1643 | 1642 | |
1644 | 1643 | /* remove the empty last field */ |