Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
954 B

  1. /*
  2. * REVISIONS:
  3. * ane11Dec92: Changed true and false to TRUE and FALSE, added os/2 includes
  4. * rct27Jan93: Fixed problem with comments
  5. * pcy16Feb93: Fixed removing trailing blanks from null strings ("")
  6. * cad18Nov93: Fix for EOF returned but not feof()
  7. * mholly06Oct98 : removed dead code, macros, and #defines - are left with
  8. * only the StripTrailingWhiteSpace function
  9. */
  10. extern "C" {
  11. #include <ctype.h>
  12. #include <string.h>
  13. }
  14. #include "scan.h"
  15. // Macro definitions...
  16. #define NEWLINE_SYMBOL '\n'
  17. #define isNewline(c) (c == NEWLINE_SYMBOL)
  18. #define isBlank(c) (isspace(c) && !isNewline(c))
  19. //-------------------------------------------------------------------
  20. // Removes trailing whitespace from the string
  21. void StripTrailingWhiteSpace(char * aString)
  22. {
  23. int index = (strlen(aString)-1);
  24. while (isBlank(aString[index]) && index >= 0) {
  25. index--;
  26. }
  27. aString[index+1] = NULL;
  28. }