Branch: Tag:

2000-02-17

2000-02-17 18:05:16 by Martin Nilsson <mani@lysator.liu.se>

Added trim_whites and trim_all_whites.

Rev: lib/modules/String.pmod:1.9

171:       return fuzz;   } +  + string trim_whites( string what ) + { +  if (stringp (what)) { +  sscanf(what, "%*[ \t]%s", what); +  string rev = reverse(what); +  sscanf(rev, "%*[ \t]%s", rev); +  return what[..strlen(rev) - 1]; +  } +  +  return what; + } +  + string trim_all_whites( string what ) + { +  if (stringp (what)) { +  sscanf(what, "%*[ \t\r\n]%s", what); +  string rev = reverse(what); +  sscanf(rev, "%*[ \t\r\n]%s", rev); +  return what[..strlen(rev) - 1]; +  } +  +  return what; + }