Changeset 1168 in MondoRescue for branches/stable/monitas/from-mondo.c
- Timestamp:
- Feb 15, 2007, 12:27:39 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/monitas/from-mondo.c
r353 r1168 6 6 7 7 #include "structs.h" 8 #include "mr_str.h" 8 9 9 10 … … 13 14 bool does_file_exist (char *); 14 15 int make_hole_for_file (char *); 15 void strip_spaces(char*);16 16 17 17 … … 53 53 pclose (fin); 54 54 } 55 strip_spaces (result);55 mr_strip_spaces (result); 56 56 return (result); 57 57 } … … 124 124 incoming[i]='\0'; 125 125 */ 126 strip_spaces (incoming);126 mr_strip_spaces (incoming); 127 127 log_it (debug, incoming); 128 128 } … … 204 204 } 205 205 206 207 208 209 210 211 212 213 214 /*************************************************************************215 * strip_spaces() -- Hugo Rabson *216 * rewitten Stefan Huebner *217 * *218 * Purpose: remove leading whitespaces and control characters, replace *219 * TABs by SPACES, remove previous char when followed with BS,*220 * skip control chars, terminate string with '\0' when CR or *221 * NL is detected *222 * afterwards remove trailing whitespace *223 * Called by: *224 * Returns: *225 *************************************************************************/226 void227 strip_spaces (char *in_out)228 {229 char *r, *w;230 r = w = in_out; // initialize read and write pointer231 232 while ( *r && *r <= ' ' )233 ++r; // skip leading whitespace and control chars234 235 for ( ; *r ; ++r ) // until end of existing string do:236 {237 if (*r == '\t') // TAB238 { *w++ = ' '; // write SPACE instead239 continue; }240 if (*r == (char) 8) // BACKSPACE241 { if (w > in_out) --w; // remove previous character (if any ;-)242 continue; }243 if (*r == '\n' || *r == '\r') // CR and LF244 break; // terminate copying245 if (*r < ' ') // Control chars246 continue; // are ignored (skipped)247 *w++ = *r; // all other chars are copied248 }249 // all characters are copied250 *w = '\0'; // terminate the copied string251 for (--w; w>in_out && *w == ' '; --w)252 *w = '\0'; // remove trailing whitespaces253 return;254 /** buffers ******************************************************/255 // char tmp[MAX_STR_LEN+1];256 257 /** pointers *****************************************************/258 // char *p;259 260 /** int *********************************************************/261 // int i;262 263 /** end vars ****************************************************/264 /* for (i = 0; in_out[i] <= ' ' && i < strlen (in_out); i++);265 strcpy (tmp, in_out + i);266 for (i = strlen (tmp); i>0 && tmp[i - 1] <= 32; i--);267 tmp[i] = '\0';268 for (i = 0; i < 80; i++)269 {270 in_out[i] = ' ';271 }272 in_out[i] = '\0';273 i = 0;274 p = tmp;275 while (*p != '\0')276 {277 in_out[i] = *(p++);278 in_out[i + 1] = '\0';279 if (in_out[i] < 32 && i > 0)280 {281 if (in_out[i] == 8)282 {283 i--;284 }285 else if (in_out[i] == 9)286 {287 in_out[i++] = ' ';288 }289 else if (in_out[i] == '\t')290 {291 for (i++; i % 5; i++);292 }293 else if (in_out[i] >= 10 && in_out[i] <= 13)294 {295 break;296 }297 else298 {299 i--;300 }301 }302 else303 {304 i++;305 }306 }307 in_out[i] = '\0';308 */309 /* for(i=strlen(in_out); i>0 && in_out[i-1]<=32; i--) {in_out[i-1]='\0';} */310 }311 312 313 314 315 316 317 318 319 320 321
Note:
See TracChangeset
for help on using the changeset viewer.