00001
00002
00003
00004
00005
00006 #include <ctype.h>
00007 #include <string.h>
00008 #include <stdlib.h>
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 char *fits_str_cull (char *str)
00022 {
00023 char *p, *d;
00024 int flg, n;
00025
00026
00027
00028 if ((str == NULL) || ((n = strlen(str)) <= 0)) return str;
00029
00030
00031
00032 flg = 0;
00033 p = str;
00034 while (*p != '\0')
00035 {
00036 if ((*p == '\"') || (*p == '\''))
00037 {
00038 flg = 1;
00039 *p = ' ';
00040 break;
00041 }
00042 ++p;
00043 }
00044
00045
00046
00047
00048 p = str + n - 1;
00049 while (--n >= 0)
00050 {
00051 if (isspace(*p) != 0)
00052 {
00053 *(p--) = '\0';
00054 continue;
00055 }
00056 if ((flg != 0) && ((*p == '\"') || (*p == '\'')))
00057 {
00058 *(p--) = '\0';
00059 continue;
00060 }
00061 break;
00062 }
00063
00064
00065
00066 n = 0;
00067 d = p = str;
00068 while ((*p != '\0') && (isspace(*p) != 0)) ++p;
00069 if (*p == '\0') return str;
00070 while (*p != '\0') *d++ = *p++;
00071 *d = '\0';
00072
00073 return str;
00074 }