Very old versions for history.
[opsoft_archive.git] / silentbob / silentbob-1.1 / src / sblib / make_pattern.cpp
blobffc1b4e55ad5e64fb72d796e4da3e49fb7fef174
1 /*
2 * (c) Oleg Puchinin 2006
3 * graycardinalster@gmail.com
5 */
7 #include <dlib.h>
9 char * make_pattern (char *op)
11 int i;
12 char * pt;
13 char *pos;
15 pt = CNEW (char, 128);
16 i = 0;
17 pos = pt;
18 *pos = '/';
19 ++pos;
20 while (op[i] && i < 64) {
21 if (if_abc (&op[i]) || if_digit (&op[i]) || op[i] == '_')
22 *pos = op[i];
23 else if (op[i] == ' ') {
24 *pos = '\\';
25 ++pos;
26 *pos = 's';
27 } else {
28 *pos = '.';
31 ++i;
32 ++pos;
35 if (pos[-1] == 's')
36 pos -= 2;
37 *pos = '/';
38 ++pos;
39 *pos = '\0';
40 return pt;