195b7b453SJohn Marino /* Removes leading and/or trailing whitespaces 2*09d4459fSDaniel Fojt Copyright (C) 2006, 2009-2020 Free Software Foundation, Inc. 395b7b453SJohn Marino 495b7b453SJohn Marino This program is free software: you can redistribute it and/or modify 595b7b453SJohn Marino it under the terms of the GNU General Public License as published by 695b7b453SJohn Marino the Free Software Foundation; either version 3 of the License, or 795b7b453SJohn Marino (at your option) any later version. 895b7b453SJohn Marino 995b7b453SJohn Marino This program is distributed in the hope that it will be useful, 1095b7b453SJohn Marino but WITHOUT ANY WARRANTY; without even the implied warranty of 1195b7b453SJohn Marino MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1295b7b453SJohn Marino GNU General Public License for more details. 1395b7b453SJohn Marino 1495b7b453SJohn Marino You should have received a copy of the GNU General Public License 15*09d4459fSDaniel Fojt along with this program. If not, see <https://www.gnu.org/licenses/>. */ 1695b7b453SJohn Marino 1795b7b453SJohn Marino /* Written by Davide Angelocola <davide.angelocola@gmail.com> */ 1895b7b453SJohn Marino 1995b7b453SJohn Marino /* Trim mode. */ 2095b7b453SJohn Marino #define TRIM_TRAILING 0 2195b7b453SJohn Marino #define TRIM_LEADING 1 2295b7b453SJohn Marino #define TRIM_BOTH 2 2395b7b453SJohn Marino 2495b7b453SJohn Marino /* Removes trailing and leading whitespaces. */ 2595b7b453SJohn Marino #define trim(s) trim2(s, TRIM_BOTH) 2695b7b453SJohn Marino 2795b7b453SJohn Marino /* Removes trailing whitespaces. */ 2895b7b453SJohn Marino #define trim_trailing(s) trim2(s, TRIM_TRAILING) 2995b7b453SJohn Marino 3095b7b453SJohn Marino /* Removes leading whitespaces. */ 3195b7b453SJohn Marino #define trim_leading(s) trim2(s, TRIM_LEADING) 3295b7b453SJohn Marino 3395b7b453SJohn Marino char *trim2 (const char *, int); 34