Very old versions for history.
[opsoft_archive.git] / silentbob / silentbob-1.1 / src / sblib / inline.h
blobe09950e644d6e39d90c4b2381b378892006e2c08
1 #ifndef DEFINE_INLINE_H
2 #define DEFINE_INLINE_H
4 inline bool ww_call_cmp (char * d_op, char * d_cmp, int d_len)
6 if (!strncmp (d_op, d_cmp, d_len)
7 && (d_op[d_len] == '(' || d_op[d_len+1] == '('))
8 return true;
10 return false;
13 inline bool ww_case_cmp (char * d_op, char * d_cmp, int d_len)
15 if (!strncmp (d_op, d_cmp, d_len)
16 && (d_op[d_len] == ':' || d_op[d_len+1] == ':'))
17 return true;
19 return false;
22 inline bool local_ftest (char *S) // test for pair "()"
24 int d_count1 = 0;
25 int d_count2 = 0;
27 while (*S) {
28 if (*S == '(')
29 d_count1++;
31 if (*S == ')')
32 d_count2++;
34 if (!d_count1 || (d_count1 == d_count2)) {
35 if (*S == '[')
36 return false;
37 if (*S == ']')
38 return false;
39 if (*S == '=')
40 return false;
42 S++;
45 return d_count1 && d_count2;
48 inline char last_ch (char *S)
50 S = &S[strlen (S)] - 1;
51 while (if_digit (S) || if_abc(S) || *S == '_')
52 S--;
53 if (*S == ' ')
54 S--;
55 return *S;
58 inline char ww_after_word (char *S)
60 while (true) {
61 if (! (if_abc (S) || *S =='_' || if_digit (S)))
62 break;
63 S++;
65 if (*S == ' ')
66 S++;
68 return *S;
71 inline void free_cword (c_word * word)
73 free (word->S);
74 free (word);
77 inline struct c_word * new_cword (char *word, char sym)
79 c_word * Ret = CNEW (c_word, 1);
80 Ret->S = strdup (word);
81 Ret->ch = sym;
82 return Ret;
85 inline char * ww_first_word (char * word)
87 char *S = word;
89 while (true) {
90 if (!if_abc (S) &&
91 !if_digit (S) &&
92 *S != '_')
93 break;
94 S++;
97 return Dstrndup (word, S-word);
100 inline int ww_nsyms_r (char * begin, char * end, char sym)
102 char * S;
103 int count = 0;
104 S = end;
105 while (S != begin && *S == sym) {
106 ++count;
107 --S;
109 return count;
112 #endif