cleanname.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * This file is part of Jehanne.
  3. *
  4. * Copyright (C) 2016 Giacomo Tesio <giacomo@tesio.it>
  5. *
  6. * Jehanne is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, version 2 of the License.
  9. *
  10. * Jehanne is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with Jehanne. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <u.h>
  19. #include <lib9.h>
  20. void
  21. main(void)
  22. {
  23. char buf[256], *s;
  24. strcpy(buf, "#abcde");
  25. s = cleanname(buf);
  26. if(s != buf || strcmp("#abcde", buf)){
  27. print("FAIL, cleanname(#abcde) = %s\n", s);
  28. exits("FAIL");
  29. }
  30. strcpy(buf, "#abcde/fg/../hi");
  31. s = cleanname(buf);
  32. if(s != buf || strcmp("#abcde/hi", buf)){
  33. print("FAIL, cleanname(#abcde/fg/../hi) = %s\n", s);
  34. exits("FAIL");
  35. }
  36. strcpy(buf, "#abcde/fg/./hi/");
  37. s = cleanname(buf);
  38. if(s != buf || strcmp("#abcde/fg/hi", buf)){
  39. print("FAIL, cleanname(#abcde/fg/./hi) = %s\n", s);
  40. exits("FAIL");
  41. }
  42. print("PASS\n");
  43. exits("PASS");
  44. }