1 /* stripslash.c -- remove trailing slashes from a string 2 Copyright (C) 1990 Free Software Foundation, Inc. 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2, or (at your option) 7 any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. */ 13 14 #ifdef HAVE_CONFIG_H 15 #include "config.h" 16 #endif 17 18 #if STDC_HEADERS || HAVE_STRING_H 19 #include <string.h> 20 /* An ANSI string.h and pre-ANSI memory.h might conflict. */ 21 #if !STDC_HEADERS && HAVE_MEMORY_H 22 #include <memory.h> 23 #endif /* not STDC_HEADERS and HAVE_MEMORY_H */ 24 #else /* not STDC_HJEADERS and not HAVE_STRING_H */ 25 #include <strings.h> 26 /* memory.h and strings.h conflict on some systems. */ 27 #endif /* not STDC_HEADERS and not HAVE_STRING_H */ 28 29 /* Remove trailing slashes from PATH. */ 30 31 void 32 strip_trailing_slashes (path) 33 char *path; 34 { 35 int last; 36 37 last = strlen (path) - 1; 38 while (last > 0 && path[last] == '/') 39 path[last--] = '\0'; 40 } 41